Saleh127

Live Archive 2189 / UVA 12085

May 10th, 2020 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. ll a[1000010];
  5. int main()
  6. {
  7. ll t,i,j,k,Case=1;
  8. while(cin>>t && t)
  9. {
  10. for(j=0; j<t; j++)
  11. {
  12. cin>>a[j];
  13. }
  14. cout<<"Case "<<Case++<<":\n";
  15. string n1,n2,n3;
  16. ll shuru,sesh,posi=0;
  17. for(i=0; i<t; i++)
  18. {
  19. shuru=i;
  20. while(i+1<t && a[i+1]==a[i]+1)
  21. {
  22. i++;
  23. }
  24. sesh=i;
  25. if(shuru==sesh)
  26. {
  27. cout<<"0"<<a[i]<<"\n";
  28. }
  29. else
  30. {
  31. cout<<"0"<<a[shuru]<<"-";
  32.  
  33. n1=to_string(a[shuru]);
  34. n2=to_string(a[sesh]);
  35. posi=0;
  36. while(n1[posi]==n2[posi])
  37. {
  38. posi++;
  39. }
  40. for(k=posi; k<n2.size(); k++)
  41. {
  42. cout<<n2[k];
  43. }
  44. cout<<endl;
  45. }
  46. }
  47. cout<<endl;
  48. }
  49. return 0;
  50. }
Add Comment
Please, Sign In to add comment