Halloween Party Time limit: +Ms | Memory Limit:65535KB Difficulty:1
-
-
Describe
-
There is a party,xadillax on Halloween and obviously going to the fun. Because the number of people to join the fun is very large, dozens of W of the Order of magnitude bar, natural to enter the need to have tickets. Luckily, Xadillax got a real ticket! The rules of the ticket arrangement are strange:
Ticket number is a six-digit number made up of 0~6 (0~6 these numbers can be reused)
Each gate ticket number of each person can not have three consecutive identical numbers (such as 123335 is not possible)
Each door ticket is adjacent to the two-bit difference must be under four (≤4) (such as 016245 is not possible)
-
-
Input
-
-
The first line is an n, which represents the number of inputs
Next n rows, two digits x x, y (<= y) per line
-
-
Output
-
-
for each test, output the ticket number from X to Y. A blank line between the end of each test.
-
-
Sample input
-
-
2001001 001002001011 001012
-
-
Sample output
-
-
001001001002001011001012
-
-
The main topic: give two endpoints, output all the conditions of the ticket number, the ticket number is composed of 6 numbers, to meet each of the numbers are not more than 6, can not 3 the same necklace, no connection number can be greater than 4
Idea: The problem is really pit ah, the beginning of the array access out of bounds, always wrong = =,, alas, detailed comments
2014.12.14
-
-
#include <stdio.h> #include <math.h>int x[10];int main () {int N,I,J,A,B,P,V,G;//PVG is the flag scanf ("%d", &n); while (n--) {scanf ("%d%d", &a,&b), and for (i=a;i<=b;i++) {v=p=g=0;x[0]=i/100000;//put each bit into an array x[1]=i/10000%10;x[ 2]=i/1000%10;x[3]=i/100%10;x[4]=i/10%10;x[5]=i%10;for (j=0;j<6;j++)//judgment there is no greater than 6 number if (x[j]>6) {g=1;break;} for (j=0;j<4;j++)//To determine whether there are three numbers connected to the same, note that this can only go to j=3, otherwise it would be wrong if (x[j]==x[j+1]&&x[j+1]==x[j+2]) {v=1;break;} for (j=0;j<5;j++)//This can only go to j=5 if (Fabs (x[j]-x[j+1]) >4) {p=1;break;} if (v==0&&p==0&&g==0) {for (j=0;j<6;j++) printf ("%d", X[j]);p rintf ("\ n");}} printf ("\ n");} return 0;}
Nyoj 7.33 million Saints ' Day party