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

……似乎代码都很长

Posted by Yoki_Wisa at 2012-10-26 22:55:22 on Problem 1002
贴一段AC的短代码……调了半天结果忘记输出No......

#include <cstdio>
#define ll 10000
#define maxn 10000000

using namespace std;

const int w[27] = {0, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9};
int t[maxn + 5] = {0};
int n, p, k, i, tt;
char c;

int Deal(char c)
{
    int t = 0; 
    if (c >= 65  &&  c <= 90)  t = 1, k = k * 10 + w[c - 64];
    if (c >= 48  &&  c <= 57)  t = 1, k = k * 10 + c - '0';
    return t;
}
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    for (scanf("%d", &n); n--; )
      {
         p = 7; k = 0;
         while (p) c = getchar(), p -= Deal(c);
         while (c != '\n')  if (c = getchar())  break;
         t[k]++;             
      }
    for (i = 0; i < maxn; ++i)
      if (t[i] > 1)  printf("%03d-%04d %d\n", i / ll, i % ll, t[i]), tt = 1;
    if (!tt)  printf("No duplicates.");
    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