[辽宁省程序设计竞赛]C 轮到谁了?
C-轮到谁了?_2020 年第一届辽宁省大学生程序设计竞赛 (nowcoder.com)https://ac.nowcoder.com/acm/contest/8440/C
#include<iostream>
#include<cstring>
using namespace std;
const int N = 1010;
int f[N];
int main()
{
int t;
cin >> t;
int n,m;
while(t --)
{
memset(f, 0, sizeof f);
cin >> n >> m;
for(int i = 2; i < n; i ++){
f[i] = (f[i-1]+f[i-2]+1)%m;
}
cout << f[n-1] << endl;
}
return 0;
}
本文来自博客园,作者:泥烟,CSDN同名, 转载请注明原文链接:https://www.cnblogs.com/Knight02/p/15799071.html