标签:div 时间 std style using iostream turn clu out
#include "iostream" using namespace std; int fun(int A,int B,int n) { int x = 1,y = 1,z; if (n == 1 || n == 2) return 1; else { z = (A*y +B*x )%7; for(int i=2;i<n;i++) { int t = z; z = (A*z +B*y )%7; x = y; y = t; } return y; } } int main() { int A,B,n; int a[100]; int i = 0; cin >> A >> B >> n; while(A != 0 ||B != 0||n != 0) { a[i] = fun(A,B,n%48); i++; cin >> A >> B >> n; } for(int j=0;j<i;j++) { cout << a[j] <<"\n"; } }
第一次交的时候时间超了,然后知道还有循环一说。
标签:div 时间 std style using iostream turn clu out
原文地址:http://www.cnblogs.com/cunyusup/p/7668203.html