ZOJ 3333 Guess the Price 3323 Somali Pirates 3322 Who is Older?(超级水)


Guess the Price

Time Limit: 1 Second                                     Memory Limit: 32768 KB                            

In the television program "Shopping Street" of CCTV-2, two people, A and B are guessing price of a given item. You are asked to decide whose price is closer to the real price.

Input

There are multiple test cases. The first line of input is an integer T (T <= 10) indicating the number of test cases.

Each case contains three integers in one line: P, PA, PB (0 <= PA, PB <= P <= 100, PA != PB), indicating the real price, the price A guesses and the price B guesses.

Output

For each case, output "A" or "B" according to whose price is closer to the real price.

Sample Input

3
10 8 7
20 20 19
100 9 50

Sample Output

A
A
B
 
闲着没事  贴几个前天省赛训练中的弱智题,被我队友三个题分分钟搞定。
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int t,p,pa,pb;
    cin>>t;
    while(t--)
    {
        cin>>p>>pa>>pb;
        printf("%c\n",abs(p-pa)<abs(p-pb)?'A':'B');

    }
    return 0;
}

 
 
 
Somali Pirates

Time Limit: 1 Second      Memory Limit: 32768 KB

It is said that the famous Somali Pirates hate digits. So their QQ passwords never contain any digit. Given some lines of candidate passwords, you are asked to delete all the digits in the passwords and print other characters in their original order. So the Somali Pirates can use them as their QQ passwords^^

Input

There are multiple test cases. The first line of input is an integer T (T <= 10) indicating the number of test cases.

Each case contains a line indicating a candidate password. The length of the password is between 1 and 20, inclusive. Besides, the password consists of only digits and English letters.

Output

For each candidate password, delete all the digits and print the remaining characters in a line.

Sample Input

2
BeatLA123
1plus1equals1

Sample Output

BeatLA
plusequals
 
 
 
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    int t;
    char cnt[30];
    cin>>t;
    while(t--)
    {
        memset(cnt,'\0',sizeof(cnt));
        scanf("%s",cnt);
        for(int i=0;i<strlen(cnt);i++)
        {
            if(isalpha(cnt[i]))
                cout<<cnt[i];
        }
        cout<<endl;
    }
    return 0;
}

Who is Older?

Time Limit: 1 Second      Memory Limit: 32768 KB

Javaman and cpcs are arguing who is older. Write a program to help them.

Input

There are multiple test cases. The first line of input is an integer T (0 < T <= 1000) indicating the number of test cases. Then T test cases follow. The i-th line of the next T lines contains two dates, the birthday of javaman and the birthday of cpcs. The format of the date is "yyyy mm dd". You may assume the birthdays are both valid.

Output

For each test case, output who is older in a single line. If they have the same birthday, output "same" (without quotes) instead.

Sample Input

3
1983 06 06 1984 05 02
1983 05 07 1980 02 29
1991 01 01 1991 01 01

Sample Output

javaman
cpcs
same
 
 
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    int t,x1,x2,x3,y1,y2,y3;
    cin>>t;
    while(t--)
    {
        cin>>x1>>x2>>x3>>y1>>y2>>y3;
        if(x1==y1)
        {
            if(x2==y2)
            {
                if(x3==y3)
                {
                    cout<<"same"<<endl;
                }
                else if(x3>y3)
                {
                    cout<<"cpcs"<<endl;
                }
                else
                    cout<<"javaman"<<endl;
            }
            else if(x2>y2)
            {
                cout<<"cpcs"<<endl;
            }
            else
            {
                cout<<"javaman"<<endl;
            }
        }
        else if(x1>y1)
        {
            cout<<"cpcs"<<endl;
        }
        else
        {
            cout<<"javaman"<<endl;
        }
    }
    return 0;
}
/*
3
1983 06 06 1984 05 02
1983 05 07 1980 02 29
1994 01 01 1993 01 21
*/

posted @ 2015-05-08 12:34  cbam  阅读(109)  评论(0)    收藏  举报