Hangzhou Electric HDU ACM 1562 Guess the number

Source: Internet
Author: User

Guess the number Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 3035 Accepted Submission (s): 2281


Problem Descriptionhappy New Year to everybody!
Now, I want your to guess a minimum number x BETWWN and 9999
(1) x% A = 0;
(2) (x+1)% B = 0;
(3) (x+2)% c = 0;
And A, B, c are integers between 1 and 100.
Given A,b,c, tell me what's the number of x?

Inputthe Number of test cases C is in the first line of input, then C test Cases Followed.every test contains three intege Rs A, B, C.
Outputfor each test case your program should output one and the minimal number x, you should remember that X is BETW Een and 9999. If There is no answer for X, Output "impossible".
Sample Input
244 38 4925) 56 3

Sample Output
Impossible2575

Author8600
Sourcehappy 2007 It's a waste of time doing the subject.
#include <iostream>using namespace Std;int main () {int N,a,b,c,i;cin>>n;while (n--) {cin>>a>>b >>c;for (i=1000;i<=9999;i++) if ((i%a==0) && ((i+1)%b==0) && ((i+2)%c==0)) {cout<<i< <endl;; break;} if (i>9999) cout<< "impossible" <<ENDL;} return 0;}

Hangzhou Electric HDU ACM 1562 Guess the number

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.