ZOJ 3333 Guess The price

Source: Internet
Author: User

Title Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3758


Surface:


Guess the price Time limit: 1 Second Memory Limit: 32768 KB

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

Input

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

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

Output

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

Sample Input

310 8 720 20 19100 9 50

Sample Output

AAB

Test instructions: Find two prices which are closer to the actual price.

In fact, the problem is a bit flawed, only said PA!=PB, but the difference is probably equal, but the test sample did not.


Code:

#include <iostream> #include <cmath>using namespace Std;int main () {int t,p1,p2,p;    cin>>t;    while (t--)    {    cin>>p>>p1>>p2;    if (ABS (P-P1) <abs (P-P2)) cout<< "a\n";    else cout<< "b\n";    


ZOJ 3333 Guess The price

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.