fork download
  1. #include<cstdio>
  2. #include<cstdlib>
  3. #include<cstring>
  4. #include<algorithm>
  5. #include "cgdzlib.h"
  6. #include<iostream>
  7. #include<fstream>
  8. #include<map>
  9. #include<ctime>
  10. #include<set>
  11. #include<queue>
  12. #include<cmath>
  13. #include<vector>
  14. #include<bitset>
  15. #include<functional>
  16. #define x first
  17. #define y second
  18. #define mp make_pair
  19. #define pb push_back
  20. #define REP(i,l,r) for((i)=(l);(i)<=(r);++(i))
  21. #define REP2(i,l,r) for((i)=(l);(i)!=(r);++(i))
  22. using namespace std;
  23.  
  24. typedef long long LL;
  25. typedef double ld;
  26.  
  27. /*
  28.   M(n)
  29.   若n==1 M(n)=0
  30.   否则M(n)=1...找到能被n-1整除的两个数即可
  31.   */
  32.  
  33. const int MAX=1000000+10;
  34. int n,num[MAX],tmp[MAX];
  35.  
  36. pair<int,int> work(int l,int r,int one)
  37. {
  38. if(l==r)
  39. return mp(num[l],num[r]);
  40. int tl=l,tr=r;
  41. int i;
  42. for(i=l;i<=r;++i)
  43. if(f(num[i],num[l],one*2))
  44. tmp[tl++]=num[i];
  45. else tmp[tr--]=num[i];
  46. REP(i,l,r)
  47. num[i]=tmp[i];
  48. pair<int,int> L=work(l,tl-1,one*2);
  49. pair<int,int> R=work(tl,r,one*2);
  50. int need=one*(r-l);
  51. int top=0;
  52. tmp[++top]=L.x;
  53. if(L.y!=L.x)
  54. tmp[++top]=L.y;
  55. tmp[++top]=R.x;
  56. if(R.y!=R.x)
  57. tmp[++top]=R.y;
  58. REP(i,1,top)
  59. for(int j=i+1;j<=top;++j)
  60. if(f(tmp[i],tmp[j],need))
  61. return mp(tmp[i],tmp[j]);
  62. return mp(0,0);
  63. }
  64.  
  65. int main()
  66. {
  67. #ifndef ONLINE_JUDGE
  68. // freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  69. #endif
  70. n=inicjuj();
  71. int i;
  72. REP(i,1,n)
  73. num[i]=i;
  74. pair<int,int> L=work(1,n,1);
  75. if(L.x==L.y)
  76. odpowiedz(L.x);
  77. else
  78. odpowiedz(g(L.x,L.y)?L.y:L.x);
  79. return 0;
  80. }
  81.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:21: fatal error: cgdzlib.h: No such file or directory
 #include "cgdzlib.h"
                     ^
compilation terminated.
stdout
Standard output is empty