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

CODE

Posted by lus at 2014-02-23 20:45:22 on Problem 1013 and last updated at 2014-05-02 17:46:38
#include <cstdio>
#define N 1000
char ch1[3][N],ch2[3][N],ch3[3][N];
bool check(int a,int v)
{
    char A=a+'A';
    for(int i=0;i<3;++i)
    {
        int sum1=0,sum2=0;
        for(int j=0;ch1[i][j];++j) sum1+=(ch1[i][j]==A ? v : 1 );
        for(int j=0;ch2[i][j];++j) sum2+=(ch2[i][j]==A ? v : 1 );
        if(ch3[i][0]=='e' && sum1!=sum2) return 0;
        if(ch3[i][0]=='u' && sum1<=sum2) return 0;
        if(ch3[i][0]=='d' && sum1>=sum2) return 0;
    }
    return 1;
}
void work()
{
    for(int i=0;i<3;++i) scanf("%s%s%s",ch1[i],ch2[i],ch3[i]);
    for(int i=0;i<26;++i)
    {
        if(check(i,0)) printf("%c is the counterfeit coin and it is light. \n",char(i+'A'));
        if(check(i,2)) printf("%c is the counterfeit coin and it is heavy. \n",char(i+'A'));
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--) work();
}

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