Advertisement
a53

lumini1

a53
Feb 9th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. //Virga Liliana
  2. #include <fstream>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. ifstream fin("lumini.in");
  8. ofstream fout("lumini.out");
  9.  
  10. int f[65538],n,nd,ndm,nrbec,copil,o;
  11.  
  12. struct led
  13. {
  14. int nd;
  15. char nume[24];
  16. } C[5001];
  17.  
  18. int nrdiv (int n)
  19. {
  20. int nd=1;
  21.  
  22. for(int d=2; d*d<=n; d++)
  23. {
  24. int p=0;
  25. while(n%d==0)
  26. {
  27. n=n/d;
  28. p++;
  29. }
  30. if(p!=0)
  31. nd=nd*(p+1);
  32. }
  33.  
  34. if(n!=1)
  35. nd=nd*2;
  36.  
  37. return nd;
  38. }
  39.  
  40. void diviz()
  41. {
  42. for(int i=1; i<=65536; i++)
  43. {
  44. int nd=nrdiv(i);
  45. if (f[nd]==0)
  46. f[nd]=i;
  47. }
  48. }
  49.  
  50. int main()
  51. {
  52. diviz();
  53.  
  54. fin >> o;
  55.  
  56. fin >> n;
  57.  
  58. for(int i=1; i<=n; i++)
  59. {
  60. fin >> C[i].nd >> C[i].nume;
  61.  
  62. if (f[(C[i].nd)] > nrbec)
  63. {
  64. nrbec = f[(C[i].nd)];
  65. copil=i;
  66. }
  67. }
  68.  
  69. if (o==1)
  70. fout << nrbec << endl;
  71.  
  72. if (o==2)
  73. fout << C[copil].nume<< endl;
  74.  
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement