Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:我要无语了,多少组测试数据都发现不了错误,大牛们帮帮忙In Reply To:我要无语了,多少组测试数据都发现不了错误,大牛们帮帮忙 Posted by:cuero at 2009-02-13 22:34:00 > #include <iostream> > using namespace std; > > long long a[40000]; > > void solve(int t, int j) > { > int tem = t-a[j], tempo; > if (tem < 10) > { > printf("%d\n",tem); > return; > } > else if (tem >= 10 && tem < 190) > { > tempo = tem-9; > tempo = (tempo+1)/2+9; > if (tem%2) > { > printf("%d\n",tempo%10); > return; > } > else > { > printf("%d\n",tempo/10); > return; > } > } > else if (tem >= 190 && tem < 2890) > { > tempo = tem-189; > tempo = (tempo+2)/3+99; > switch(tem%3) > { > case 0: > printf("%d\n",tempo%10); > return; > case 1: > printf("%d\n",tempo/100); > return; > case 2: > printf("%d\n",tempo/10%10); > return; > default: return; > } > } > else if (tem >= 2890 && tem < 38890) > { > tempo = tem-2889; > tempo = (tempo+3)/4+999; > switch(tem%4) > { > case 2: > printf("%d\n",tempo/1000); > return; > case 3: > printf("%d\n",tempo/100%10); > return; > case 0: > printf("%d\n",tempo/10%10); > return; > case 1: > printf("%d\n",tempo%10); > return; > default: return; > } > } > else > { > tempo = tem - 38889; > tempo = (tempo+4)/5 + 9999; > switch(tem%5) > { > case 0: > printf("%d\n",tempo/10000); > return; > case 1: > printf("%d\n",tempo/1000%10); > return; > case 2: > printf("%d\n",tempo/100%10); > return; > case 3: > printf("%d\n",tempo/10%10); > return; > case 4: > printf("%d\n",tempo%10); > return; > } > } > } > int main() > { > int N, t; > unsigned int i, j; > scanf("%d",&N); > a[0] = 0; > for (i = 1; i < 10; i++) > { > a[i] = a[i-1]+i; > } > for (i = 10; i < 100; i++) > { > a[i] = a[i-1]+2*i-9; > } > for (i = 100; i < 1000; i++) > { > a[i] = a[i-1]+3*(i-99)+189; > } > for (i = 1000; i < 10000; i++) > { > a[i] = a[i-1]+4*(i-999)+2889; > } > for (i = 10000; a[i-1] <= 2147483647; i++) > { > a[i] = a[i-1]+4*(i-9999)+38889; > } > for (int i = 0; i < N; i++) > { > scanf("%d",&t); > if (t < 230348388) > { > for (j = 0;; j++) > { > if (t>a[j] && t <= a[j+1]) > { > solve(t, j); > break; > } > } > } > else if (t>=230348388 && t < 944193388) > { > for (j = 10999;; j++) > { > if (t>a[j] && t <= a[j+1]) > { > solve(t, j); > break; > } > } > } > else if (t >= 944193388) > { > for (j = 21999;; j++) > { > if (t>a[j] && t <= a[j+1]) > { > solve(t, j); > break; > } > } > } > } > return 0; > } 我貌似用得和lz差不多的算法,discuss里的数据也都测过,自己打印大量数据也没发现问题,可就是。。。wa。 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator