jakaria_hossain

lightoj-110-False Ordering

Aug 21st, 2019
122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define f first
  4. #define se second
  5. vector<pair<int,int> > v(1001);
  6. bool cmp(pair<int,int>a,pair<int,int>b)
  7. {
  8. if(a.f<b.f)return 1;
  9. if(a.f>b.f) return 0;
  10. if(a.se>b.se)return 1;
  11. return 0;
  12. }
  13.  
  14. int main()
  15. {
  16. int t;
  17. for(int i=1;i<=1000;i++)
  18. {
  19. v[i].f=0;
  20. v[i].se=i;
  21. }
  22. for(int i=1;i<=1000;i++)
  23. {
  24. for(int j=i;j<=1000;j+=i)
  25. {
  26. v[j].f++;
  27. }
  28. }
  29. sort(v.begin(),v.end(),cmp);
  30. cin>>t;
  31. for(int c=1;c<=t;c++)
  32. {
  33. int x;
  34. cin>>x;
  35. printf("Case %d: %d\n",c,v[x].se);
  36. }
  37. }
RAW Paste Data