HDOJ1005

时间:2021-08-26 15:13:26
#include "iostream"
using namespace std; int fun(int A,int B,int n)
{
int x = ,y = ,z;
if (n == || n == )
return ;
else
{
z = (A*y +B*x )%;
for(int i=;i<n;i++)
{
int t = z;
z = (A*z +B*y )%;
x = y;
y = t;
}
return y;
} } int main()
{
int A,B,n;
int a[];
int i = ;
cin >> A >> B >> n;
while(A != ||B != ||n != )
{
a[i] = fun(A,B,n%);
i++;
cin >> A >> B >> n;
}
for(int j=;j<i;j++)
{
cout << a[j] <<"\n";
}
}

第一次交的时候时间超了,然后知道还有循环一说。