思想: 写题时一直出现超时,没想到是有规律的;哗~~!
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#include <sstream>
#include <set>
#include <string>
#include <stack>
#include <vector>
using namespace std;
const int N = 50;
typedef long long LL;
const int inf = 0x3f3f3f3f;
int main()
{
LL str[N];
LL a,b,n;
ios::sync_with_stdio(false);
while(cin>>a>>b>>n&&a)
{
str[0]=1;
str[1]=1;
for(int i=2;i<48;i++)
str[i]=(a*str[i-1]+b*str[i-2])%7;
cout<<str[(n-1)%48]<<endl;
}
return 0;
}