Advertisement
erfanul007

UVa 294

Aug 23rd, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef unsigned long long int ull;
  5. typedef long long int ll;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scii(n,m) scanf("%d %d",&n,&m)
  17. #define scl(n) scanf("%lld",&n)
  18. #define scd(n) scanf("%lf",&n)
  19. #define scs(s) scanf("%s",s)
  20. #define pfi(n) printf("%d",n)
  21. #define pfl(n) printf("%lld",n)
  22. #define pff(n) cout<<n
  23. #define line printf("\n")
  24. #define spc printf(" ")
  25. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  26. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  27. #define cspf(i) printf("Case %d: ", i)
  28. #define vout(v) for(int w=0;w<v.size();w++){if(w) cout<<' '; cout<<v[w];}
  29. #define clr(a,x) memset(a,x,sizeof(a))
  30. #define pb push_back
  31. #define mp make_pair
  32. #define ff first
  33. #define ss second
  34. #define all(v) v.begin(),v.end()
  35. #define rall(v) v.rbegin(),v.rend()
  36. #define read() freopen("input.txt", "r", stdin)
  37. #define write() freopen("output.txt", "w", stdout)
  38. #define fastIO() ios_base::sync_with_stdio(false); cin.tie(NULL);
  39. /// Constants
  40. #define eps 1e-9
  41. #define PI acos(-1.0) // 3.1415926535897932
  42. #define MAX 1000000009
  43.  
  44.  
  45. int divcnt(ll n)
  46. {
  47. int divs=1;
  48. for(ll i=2;i*i<=n;i++){
  49. if(n%i==0){
  50. int cnt=1;
  51. while(n%i==0){
  52. n/=i;
  53. cnt++;
  54. }
  55. divs*=cnt;
  56. }
  57. }
  58. if(n>1){
  59. divs*=2;
  60. }
  61. //pfi(divs);spc;
  62. return divs;
  63. }
  64.  
  65. int main()
  66. {
  67. //read();
  68. //write();
  69. //fastIO();
  70. int n;
  71. sci(n);
  72. for(int i=1;i<=n;i++){
  73. ll l,u;
  74. sc("%lld %lld",&l,&u);
  75. ll in;
  76. int mx = 0;
  77. for(ll j=l;j<=u;j++){
  78. int divs = divcnt(j);
  79. if(mx<divs){
  80. in = j;
  81. mx = divs;
  82. }
  83. }
  84. pf("Between %lld and %lld, %lld has a maximum of %d divisors.\n",l,u,in,mx);
  85. }
  86. return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement