fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long l,r,x,k,t;
  4. void giai(int t)
  5. {
  6. cin>>l>>r;
  7. for (int k=39;k>=1;k--)
  8. {
  9. x=2;
  10. while (pow(x,k)<=r)
  11. x++;
  12. if (pow(x-1,k)>=l&&x>2)
  13. {
  14. cout<<"Case #"<<t<<": "<<k<<endl;
  15. return;
  16. }
  17. }
  18. }
  19. int main()
  20. {
  21. ios_base::sync_with_stdio(0);
  22. cin.tie(0);
  23. cout.tie(0);
  24. //freopen("power397.inp","r",stdin);
  25. //freopen("power397.out","w",stdout);
  26. cin>>t;
  27. for (int i=1;i<=t;i++)
  28. giai(i);
  29. }
Success #stdin #stdout 0.01s 5532KB
stdin
4
5 20
10 12
2 100
1000000000000 1000000000000
stdout
Case #1: 4
Case #2: 1
Case #3: 6
Case #4: 12