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

换掉了cin,cout,过了。。。

Posted by rezero at 2016-08-12 07:58:12 on Problem 1002
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
#include <cctype>

#define MAX_SIZE 10000000

using namespace std;

int htable[MAX_SIZE];

int main(int argc , char **argv) {
    int n;
    char line[128];

    scanf("%d" , &n);
    while(n--) {
        scanf("%s" , line);    
        int sum = 0;
        for(int i = 0 ; line[i] ; ++i) {
            if(line[i] == '-') continue;
            if(isdigit(line[i])) {
                sum = sum * 10 + line[i] - '0';
            } else {
                sum = sum * 10 + (line[i] - 'A' - (line[i] > 'Q')) / 3 + 2;
            }
        }
        ++htable[sum];
    }

    bool is_duplicated = false;
    for(int i = 0 ; i < MAX_SIZE; ++i) {
        if(htable[i] > 1) {
            is_duplicated = true;
            printf("%03d-%04d" , i/10000 , i%10000);
            printf(" %d\n" , htable[i]);
        }
    }

    if(!is_duplicated) printf("No duplicates.\n");
    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