| ||||||||||
| 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 | |||||||||
我还以为一边读入一边输出快呢......接近超时......
#include <cstdio>
using namespace std;
int getdigit(){int a;while (a=getchar())if (a>='0' && a<='9')return a-'0';}
int main()
{
int before9,nine,N,a,b;
scanf("%d",&N);
before9=nine=0;
for (int i=0;i<N;i++){
a=getdigit();b=getdigit();
if (a+b>=10){
putchar(before9+'1');
for (int i=0;i<nine;i++)putchar('0');
nine=0;
before9=a+b-10;
}
else if (a+b<9){
if (i>nine)putchar(before9+'0');
for (int i=0;i<nine;i++)putchar('9');
nine=0;
before9=a+b;
}else nine++;
}
if (N>nine)putchar(before9+'0');
for (int i=0;i<nine;i++)putchar('9');
putchar(10);
getchar();getchar();
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator