fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. int ans[25]={1};
  5. int now, n, la=0;
  6.  
  7. void m() {
  8. now=0;
  9. for(int i=0; i<n; i++){
  10. ans[now]*=4;
  11. for(int j=now+1;j<25;j++) {
  12. ans[j]*=4;
  13. ans[j]+=ans[j-1]/1000;
  14. ans[j-1]=ans[j-1]%1000;
  15.  
  16. }
  17. if(ans[now]%1000==0)
  18. n++;
  19. }
  20. }
  21. void d() {
  22. for(int now=24; now>0; now--){
  23. ans[now-1]+=ans[now]%3*1000;
  24. ans[now]/=3;
  25. }
  26. ans[0]/=3;
  27. }
  28. void s() {
  29. ans[0]--;
  30. for(int now=0; ans[now]<0; now++){
  31. ans[now+1]--;
  32. ans[now]=1000+ans[now];
  33. }
  34. }
  35. signed main(){
  36. cin>>n;
  37. m();
  38. s();
  39. d();
  40.  
  41. int i;
  42. for(i=24;i>=0;i--){
  43. if(ans[i]!=0)
  44. break;
  45. }
  46. cout<<ans[i];
  47. i--;
  48. for(;i>=0;i--){
  49. cout << setw(3) << setfill('0') <<ans[i];
  50. }
  51. return 0;
  52. }
Success #stdin #stdout 0s 5284KB
stdin
3
stdout
21