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)