比赛 |
防止浮躁的小练习v0.4 |
评测结果 |
WTTTTTTTTW |
题目名称 |
eins |
最终得分 |
0 |
用户昵称 |
要要要不吃药 |
运行时间 |
8.001 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2016-10-13 17:36:05 |
显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int fib(int n)
{
int result[2] = {0,1};
if(n < 2)
return result[n];
int fibOne = 0;
int fibTwo = 1;
int fibN = 0;
int i = 0;
for(i = 2; i <= n; i++)
{
fibN = fibOne + fibTwo;
fibOne = fibTwo;
fibTwo = fibN;
}
return fibN;
}
int main(){
freopen("eins.in","r",stdin);
freopen("eins.out","w",stdout);
int n,a,q,pei,yu;
scanf("%d",&n);
for(int i=0;i<n;i++){
pei=0,yu=0;
scanf("%d%d",&a,&q);
pei=fib(a);
yu=pei%q;
printf("%d",yu);
}
return 0;
}