BZOJ4725: [POI2017]Reprezentacje ró?nicowe
2018-05-24 21:55
183 查看
1 #include<stdio.h> 2 #include<string.h> 3 //#include<iostream> 4 #include<algorithm> 5 using namespace std; 6 7 #define LL long long 8 int qread() 9 { 10 char c; int s=0,t=1; while ((c=getchar())<'0' || c>'9') (c=='-') && (t=-1); 11 do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*t; 12 } 13 14 // 15 16 int tot; 17 #define maxn 233333 18 int a[maxn]; 19 struct Node 20 { 21 int x,y,v; 22 bool operator < (const Node &b) const {return v<b.v;} 23 }b[maxn]; int lb; 24 25 int main() 26 { 27 int Max=1100000000,n=2; 28 a[1]=1; a[2]=2; 29 b[++lb]=(Node){2,1,1}; 30 for (n=3;;n++) 31 { 32 if (n&1) a =a[n-1]<<1; else 33 { 34 for (int k=2;k<=lb;k++) if (b[k].v!=b[k-1].v+1) {a =b[k-1].v+1; break;} 35 if (!a ) a =b[lb].v+1; 36 a +=a[n-1]; 37 } 38 for (int i=1;i<n;i++) b[++lb]=(Node){n,i,a -a[i]}; 39 sort(b+1,b+1+lb); 40 if (a >Max) break; 41 } 42 int m=qread(); 43 while (m--) 44 { 45 int x=qread(),y; 46 if (b[y=lower_bound(b+1,b+1+lb,(Node){0,0,x})-b].v==x) printf("%d %d\n",b[y].x,b[y].y); 47 else 48 { 49 int p=x-(y-1); 50 printf("%d %d\n",n+p*2-1,n+p*2-2); 51 } 52 } 53 return 0; 54 }View Code
相关文章推荐
- BZOJ4725: [POI2017]Reprezentacje ró?nicowe
- BZOJ4725: [POI2017]Reprezentacje ró?nicowe
- bzoj 4725: [POI2017]Reprezentacje ró?nicowe 暴力
- 4725: [POI2017]Reprezentacje ró?nicowe
- 【BZOJ4725】【POI2017】Reprezentacje ró?nicowe
- BZOJ4726: [POI2017]Sabota?
- BZOJ4724 [POI2017]Podzielno
- 【POI2017||bzoj4726】Flappy Birds
- 【BZOJ4724】[POI2017]Podzielno 数学+二分
- BZOJ4723 [POI2017]Flappy Bird
- bzoj4726 [POI2017]Sabota?
- BZOJ 4726: [POI2017]Sabota?
- 【POI2017||bzoj4726】Sabota?
- [BZOJ]4726 [POI2017] Sabota? 树形Dp
- BZOJ_4726_[POI2017]Sabota?_树形DP
- BZOJ 4723: [POI2017]Flappy Bird
- 4726: [POI2017]Sabota?
- 4727: [POI2017]Turysta
- 【bzoj4724】[POI2017]Podzielno 二分
- BZOJ4723: [POI2017]Flappy Bird