Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哈哈,勉强到了170MS,各位大侠帮看看咋还能更快的?

Posted by alawing at 2006-12-28 01:33:15 on Problem 2602
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator