-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPTIT123B.cpp
More file actions
46 lines (42 loc) · 919 Bytes
/
PTIT123B.cpp
File metadata and controls
46 lines (42 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Ford(i, a, b) for(int i = a; i >= b; i--)
#define ll long long
#define here cout<<"i am here"<<endl;
const long long base= 1e9 + 7;
const int maxn = 1000000;
int main(void){
ios::sync_with_stdio(false);
int n,x = 1;
int a[100];
while(1){
cin>>n;
if(n == 0) break;
For(i, 1, n) cin>>a[i];
int res = 0, test;
while(1){
test = 1;
For(i, 1, n - 1){
if(a[i + 1] == a[i]) test++;
else break;
}
if(test == n){
cout<<"Case "<<x<<": "<<res<<" iterations"<<endl;
break;
}
if(res >= 1001){
cout<<"Case "<<x<<": not attained"<<endl;
break;
}
int key = a[1];
For(i, 1, n - 1){
a[i] = abs(a[i] - a[i+1]);
}
a[n] = abs(a[n] - key);
res++;
}
x++;
}
return 0;
}