Advertisement
a53

escape

a53
Jan 30th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include <fstream>
  2. #define NN 100001
  3. using namespace std;
  4. ifstream f("escape.in");
  5. ofstream g("escape.out");
  6. int n,x,frp[11],fr[11],y,tip,pct,cam[11],nro[11],pctmax1,pctmax2;
  7. bool v[NN];
  8. void Ciur()
  9. {
  10. v[0]=v[1]=true;
  11. for(int i=2;i*i<NN;++i)
  12. if(v[i]==false)
  13. for(int j=2;i*j<NN;++j)
  14. v[i*j]=true;
  15. }
  16. int main()
  17. {
  18. int i,j;
  19. Ciur();
  20. f>>tip>>n;
  21. for(i=1;i<=9;++i)
  22. nro[i]=i;
  23. for(i=1;i<=n;++i)
  24. {
  25. f>>x;
  26. pct=x%100;
  27. x/=100;
  28. y=x%9;
  29. if(y==0)
  30. y=9;
  31. ++cam[y];
  32. if(!v[x])
  33. frp[y]+=pct;
  34. else
  35. fr[y]+=pct;
  36. }
  37. if(tip==1)
  38. {
  39. for(i=1;i<10;++i)
  40. if(frp[i]>pctmax1)
  41. pctmax1=frp[i];
  42. for(i=1;i<10;++i)
  43. if(fr[i]>pctmax2)
  44. pctmax2=fr[i];
  45. g<<pctmax1<<' '<<pctmax2;
  46. return 0;
  47. }
  48. for(i=1;i<9;++i)
  49. for(j=i+1;j<=9;++j)
  50. if(cam[i]<cam[j])
  51. swap(cam[i],cam[j]),swap(nro[i],nro[j]);
  52. else
  53. if(cam[i]==cam[j]&&nro[i]>nro[j])
  54. swap(nro[i],nro[j]);
  55. for(i=1;i<=9;++i)
  56. if(cam[i]!=0)
  57. g<<nro[i]<<' ';
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement