标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 786 Accepted Submission(s): 505
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 100 const int inf=0x7fffffff; //无限大 ll n[maxn]; ll n2[maxn]; int N; int main() { int cas=1; int N; while(cin>>N) { if(N==0) break; for(int i=0;i<N;i++) { cin>>n[i]; n2[i]=n[i]; } ll ans=0; int flag=0; int kiss=0; for(int i=0;i<N;i++) { if(n[i]!=n[(i+1)%N]) { kiss=0; break; } if(i==N-1) kiss=1; } while(kiss==0&&ans<=1000) { for(int i=0;i<N;i++) { n[i]=fabs(n2[i]-n2[(i+1)%N]); } for(int i=0;i<N;i++) { n2[i]=n[i]; } ans++; for(int i=0;i<N;i++) { if(n[i]!=n[(i+1)%N]) { kiss=0; break; } if(i==N-1) kiss=1; } } if(kiss==1) printf("Case %d: %d iterations\n",cas,ans); else printf("Case %d: not attained\n",cas); cas++; } return 0; }
HDU 3161 Iterated Difference 暴力
标签:
原文地址:http://www.cnblogs.com/qscqesze/p/4254708.html