Hdoj topic 2554 N logarithm permutation problem (mathematics)

Source: Internet
Author: User

The permutation problem of n logarithmTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1269 Accepted Submission (s): 942


Problem description have n pairs of twins, their age is 1,2,3,......,n years old, they hand in line into a team into the wild to play, to go through a single-plank bridge, in order to safety, the requirements of the age and the age of small row together, so that the age of the protection of the younger age, Then from beginning to end, everyone reports their age and gets a sequence of ages. For example, there are 4 pairs of twins, the age sequence they quoted is: 41312432. Suddenly, the smartest among them, Xiao Ming found an interesting phenomenon, originally, the age sequence has a rule, two 1 in the middle has 1 numbers, two 2 in the middle has 2 numbers, two 3 in the middle has 3 numbers, two 4 in the middle has 4 numbers. However, if they are 2 pairs of twins, then no matter how they arrange the age sequence, can not satisfy the law.
Your task is, for a given n pairs of twins, whether there is an age sequence that satisfies this rule, if yes, output y, if not, Output n.


Input has several lines, one positive integer n<100000 per line, indicating the number of twins, or, if n=0, the end.
Output has several rows, one positive integer per line, indicating whether the corresponding input row has an age sequence that satisfies this rule, and if so, outputs Y, if not, the output n
Sample Input
4213090

Sample Output
Ynn

Authorcgf
Source2008 Hznu Programming Contest
Recommendlcy | We have carefully selected several similar problems for you:2556 2557 2559 2558 2517 ac code laughing Urine, looking for the law, actually really over
#include <stdio.h> #include <string.h>int main () {int n;while (scanf ("%d", &n)!=eof,n) {if (n%4==0| | (n+1)%4==0) printf ("y\n"); elseprintf ("n\n");}}


Hdoj topic 2554 N logarithm permutation problem (mathematics)

Related Article

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.