| ||||||||||
| 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 | |||||||||
方法虽然弱了点,测了很多数都对呀,但为什么老是WA...大牛们赐组数据吧,跪谢#include "stdio.h"
#include "string.h"
int n;
char strNum[15];
int main()
{
int i;
while(scanf("%d",&n)==1)
{
while(n--)
{
char s[12];
for(i=0; i<14; i++) strNum[i] = '0';
scanf("%s",s);
int len = strlen(s);
if(len==1)
{
printf("%s\n",s);
continue;
}
for(i=0; i<len; i++)
{
strNum[i+2] = s[i];
}
len += 2;
for(i=len-1; i>=0; i--)
{
if(strNum[i-1] != '0'&&strNum[i] < '5') strNum[i] = '0';
else
{
if(strNum[i-1]=='0') break;
strNum[i] = '0';
int j = i-1;
while(1)
{
strNum[j]++;
if(strNum[j] != ':') break;
strNum[j] = '0';
j--;
}
}
}
int j=0;
for(i=0; i<len; i++)
{
if(strNum[i] != '0') {j=i;break;}
}
for(i=j;i<len;i++)
printf("%c",strNum[i]);
printf("\n");
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator