fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. #define fast ios_base::sync_with_stdio(0),cin.tie(0);
  5. ll a[205][100];
  6.  
  7. void ok(){
  8. for(int x=2;x<=200;x++)
  9. a[x][0]=1;
  10.  
  11. for(int x=2;x<=200;x++){
  12. for(int y=1;y<=60;y++){
  13. a[x][y]=a[x][y-1]*x;
  14. if(a[x][y]>1e18) break;
  15. }
  16. }
  17.  
  18. }
  19. ll f(ll x,ll y){
  20. ll k=pow(x,y)-1;
  21. return k;
  22.  
  23. }
  24. void siu(){
  25. ll n;
  26. cin>>n;
  27. ll y=60,kt=0;
  28. for(int x=2;x<=200;x++){
  29. if( x*x-1>=n*(x-1)) break;
  30. while(a[x][y]>n) y--;
  31.  
  32. if(a[x][y]*x-1==n*(x-1)) {
  33. kt=1;
  34. cout<<x<<" "<<y<<"\n";
  35. return;
  36. }
  37.  
  38. }
  39. if(kt==0 && n<=200) {
  40. cout<<"-1\n";
  41. return;
  42. }
  43. ll res=1e19;
  44.  
  45. for(int y=2;y<=7;y++){
  46. ll l=1,r=n;
  47. while(l<=r){
  48. ll x=l+r>>1;
  49. if( f(x,y)>=n*(x-1)){
  50. res=min(res,x);
  51. r=x-1;
  52. }
  53. else l=x+1;
  54. }
  55. }
  56. if(res==1e19){
  57. cout<<-1<<"\n";
  58. return;
  59. }
  60.  
  61. ll k=1,res1=res;
  62. while(res<n){
  63. k++;
  64. res1*=res;
  65. }
  66. cout<<res<<" "<<k<<"\n";
  67.  
  68. }
  69. int main(){
  70. fast
  71. ok();
  72. ll t;
  73.  
  74. siu();
  75.  
  76. return 0;
  77. }
  78.  
Success #stdin #stdout 0s 5292KB
stdin
62625250501
stdout
9223372036854775807 1