HDU 4551 birthday prediction (simple question)

Source: Internet
Author: User
Birthday Prediction

Time Limit: 3000/1000 MS (Java/others) memory limit: 65535/32768 K (Java/Others)
Total submission (s): 460 accepted submission (s): 176

Problem description James is very important to his birthday, because he can get a blessing, share happiness with his friends and family, and make a summary of his life, and he can receive many gifts!
James is a mysterious person and won't tell you his birthday easily. Now he has a way to guess the day of his birthday.

James will tell you the following information:

1. the maximum number of common appointments between the month of birth and the day of birth;
2. Minimum Public multiples of the birth month and date;
3. Year of birth;

I want you to guess James's birthday.

 

In the first line of input, enter a positive integer T, indicating that there are a total of T groups of data (T <= 200 );
For each group of data, input three numbers X, Y, Z,
X indicates the maximum number of common appointments between the month of birth and the day of birth (1 <= x <= 1000 );
Y indicates the minimum public multiple of the birth month and date (1 <= Y <= 1000 );
Z indicates the Year of birth (1900 <= z <= 2013 ).
Each group of input data occupies one row.

 

Output first outputs the number of cases for each group of data.
If the answer does not exist, output "-1 ";
If the answer exists but is not unique, "1" is output ";
If the answer is unique, the output date is in the format of yyyy/mm/DD;
Each group of outputs occupies one row. For the specific output format, see the example.

 

Sample input3
12 24 1992
3 70 1999
9 18 1999

 

Sample outputcase #1: 1992/12/24
Case #2:-1
Case #3:

 

Source2013 Jinshan xishanju creative game program challenge-Preliminary Round (3)

 

Recommendliuyiding
 // ========================================================== ==========================================  //  Name: A. cpp  //  Author:  //  Version:  //  Copyright: Your copyright notice  //  Description: Hello world in C ++, ANSI-style  //  ========================================================== ========================================== # Include <Iostream> # Include <Stdio. h> # Include < String . H> # Include <Algorithm> # Include <Map> # Include <Queue> # Include < Set > # Include <Vector> # Include < String ># Include <Math. h> Using   Namespace  STD;  Int Gcd ( Int A, Int  B ){  If (B = 0 ) Return  A;  Return Gcd (B, A % B );}  Int Day [] = {0 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31  };  Bool Check ( Int Y, Int M, Int  D ){  If (M> 12 ) Return   False  ;  If (M = 2  ){  If (Y % 400 = 0 | (Y %100 ! = 0 & Y % 4 = 0  )){  If (D> 29 ) Return   False  ;}  Else  {  If (D> 28 ) Return  False  ;}}  Else  {  If (D> day [m]) Return   False  ;}  Return   True  ;}  Int  Main (){  //  Freopen ("in.txt", "r", stdin );  // Freopen ("out.txt", "W", stdout );      Int  X, Y, Z;  Int  T; scanf (  "  % D  " ,& T );  Int Icase = 0  ;  While (T -- ) {Icase ++ ; Scanf ( "  % D  " , & X, & Y ,& Z); printf (  "  Case # % d:  "  , Icase );  Int TMP = x * Y;  Int Ans = 0  ;  Int  Ansm, anSd;  For ( Int I = 1 ; I <= 12 ; I ++ ){  If (TMP % I) Continue  ;  Int Temp = tmp/ I;  If (Gcd (I, temp) = x && Check (Z, I, temp) {ans ++ ; Ansm =I; anSd = Temp ;}}  If (ANS = 0 ) Printf ( "  -1 \ n  "  );  Else   If (ANS> 1 ) Printf ( "  1 \ n  "  ); Else Printf ( "  % D/% 02d/% 02d \ n  "  , Z, ansm, anSd );}  Return   0  ;} 

 

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.