/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100000 int main() { ios_base::sync_with_stdio(0);cin.tie(0); int tc, kk=1, n; long long arr[100000+2]; string s; char ch; while(cin>>n && n) { for(int i=0;i<n;i++) cin>>arr[i]; cout<<"Case "<<kk++<<":\n"; for(int i=0;i<n;i++) { int st=i; while(i+1<n && arr[i+1]==arr[i]+1) i++; int ed=i; if(st==ed) cout<<"0"<<arr[i]<<"\n"; else { cout<<"0"<<arr[st]<<"-"; string s1 = "0"+to_string(arr[st]); string s2 = "0"+to_string(arr[ed]); int pos=0; while(s1[pos]==s2[pos]) pos++; for(int j=pos;j<s2.size();j++) cout<<s2[j]; cout<<"\n"; } } cout<<"\n"; } return 0; }
Tuesday, 22 December 2015
Mobile Casanova (UVA 12085, UVALive 2189, Regionals 2006 >> Asia - Dhaka)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment