Advertisement
a53

album

a53
Mar 14th, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. int ap[100],n,x,y,v,r,c,ci[7];
  5. int main()
  6. {
  7. ifstream f("album.in");
  8. ofstream g("album.out");
  9. int i,j,k, ok,c1,c2,ct1,ct2,al=0,nrc;
  10.  
  11. f>>c;
  12. if(c==1)
  13. {f>>n;
  14. for(i=1;i<=n;i++) f>>x;
  15. c1=-1; c2=-1;
  16. while(x!=0) {if(x%10>=c1) {c2=c1; c1=x%10;}
  17. else if(x%10>c2) c2=x%10;
  18. x=x/10;}
  19. g<<c2<<' '<<c1;
  20. }
  21.  
  22. else
  23. { f>>n;
  24. for(i=1;i<=n;i++)
  25. {f>>x;
  26. y=x;
  27. nrc=0;
  28. while (y!=0) {nrc++;
  29. ci[nrc]=y%10;
  30. y=y/10;}
  31. do{ok=0;
  32. for(j=1;j<nrc;j++)
  33. if(ci[j]<ci[j+1]) {y=ci[j];
  34. ci[j]=ci[j+1];
  35. ci[j+1]=y;
  36. ok=1;}
  37.  
  38. } while(ok==1);
  39.  
  40. ok=0;
  41. c1=1000000;
  42. for(j=1;j<nrc;j++)
  43. for(k=j+1;k<=nrc;k++)
  44. {y=ci[j]*10+ci[k];
  45. if(ap[y]!=0) {ok=1;
  46. if(ap[y]<c1) {c1=ap[y];
  47. c2=y;}
  48. }
  49. }
  50. if(ok==0) {al++;
  51. ap[ci[1]*10+ci[2]]=al;
  52. if(al%2==1) v++;
  53. else r++;
  54. }
  55. else if(ap[c2]%2==1) v++;
  56. else r++;
  57. }
  58.  
  59. if(v>r) g<<'V'<<'\n'<<v;
  60. else if(v==r) g<<'V'<<' '<<'R'<<'\n'<<v;
  61. else g<<'R'<<'\n'<<r;
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement