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 |
哈哈,勉强到了170MS,各位大侠帮看看咋还能更快的?#include <iostream> using namespace std; int main() { char a[1000000], b[1000000], j; long N, i; cin >> N; getchar(); for (i = 0; i < N; i++) { a[i] = getchar(); getchar(); b[i] = getchar(); getchar(); } j = 0; for (i = N - 1; i >= 0; i--) { a[i] += b[i] + j - 48; j = 0; if (a[i] > 57) { a[i] -= 10; j = 1; } } for (i = 0; i < N; i++) putchar(a[i]); cout << endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator