1005 ( Number Sequence )
1 #include <iostream> 2 3 #include <String> 4 5 using namespace std; 6 7 int main() 8 { 9 int a,b; 10 long n; 11 while(1){ 12 cin>>a>>b>>n; 13 if(0==a && 0==b &&0==n) 14 return 0; 15 16 int temp=1; 17 for(int temp1=1,temp2,i=0;i<n-2;i++){ 18 temp2=temp1; 19 temp1=temp; 20 temp=(a * temp1 +b * temp2)% 7; 21 } 22 cout<<temp<<endl; 23 } 24 25 }