|
|
back to boardHow can we get 0.031 or 0.046? I got 0.218, 104Kb with this code: #include <cstdio> #include <cstdlib> int main() { char str[8]; gets (str); int n=atoi(str); char s,sum=0;
int count=0;
while (n) { gets(str); s=str[0]+str[2];
if (s==105) {putchar(57); --n;} else {sum=s; --n; break; } } if (!n) return 0;
for (int i=0; i<n; ++i) { gets(str); s=str[0]+str[2]; if (s==105) {++count;} else {
if (s<=104) { putchar(sum-48);
for (; count>0; --count) putchar(57);
sum=s;
} else { if (s>=106) { putchar(sum-47);
for (; count>0; --count) putchar(48);
sum=s-10;
} } } }
if (s==105) { putchar(sum-48);
for (; count>0; --count) putchar(57);
} else if (sum)
(s>=106)?putchar(s-58):putchar(s-48); } Could anyone tell me what should i do to make it faster? |
|
|