一道水题,就是别忘了开long long和对32767取模,然后上代码:
#include <iostream>
#include <cstdio>
typedef long long ll
;
using namespace std
;
int main()
{
freopen("pell.in", "r", stdin);
freopen("pell.out", "w", stdout);
int n
, k
;
ll a
[1000000 + 5] = {1, 2};
for (int i
= 2; i
< 1e6 + 5; i
++)
{
a
[i
] = (2 * a
[i
- 1] + a
[i
- 2]) % 32767;
}
cin
>> n
;
while (n
--)
{
cin
>> k
;
cout
<< a
[k
- 1] << endl
;
}
return 0;
}
转载请注明原文地址:https://blackberry.8miu.com/read-12666.html