Nyoj---topic 7.33 million Saints ' Day party

Source: Internet
Author: User

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:

  1. Ticket number is a six-digit number made up of 0~6 (0~6 these numbers can be reused)

  2. Each gate ticket number of each person can not have three consecutive identical numbers (such as 123335 is not possible)

  3. 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
Source
NBOJ-1004
Uploaded by

Do not read the sentiment


Test instructions: Enter a 6-digit number, in this 6 digits can not appear more than three duplicates, can not make the adjacent two-digit difference between the value of more than 4, there is this six digits can not appear more than 6 of the number, the problem is a pit,

Do this kneeling n times ....

I have been wrong the code: because the condition is not considered the array control, the sample can be passed, has been submitted wrong n times

#include <iostream> #include <stdio.h> #include <math.h> #include <string> #include <       String.h>using namespace Std;int A[1000010];char b[10];int a1[10];bool Zhuanhua (char b[]) {for (int i=0;i<6;i++)   Convert again to reshape {a1[i]=b[i]-' 0 ';   } int flag=1;             for (int i=0;i<6;i++)//Wrong thought {if (a1[i]==a1[i+1]&&a1[i+1]==a1[i+2]) {flag=0;        Break           } if (Fabs (A1[i+1]-a1[i]) >4) {flag=0;       Break           } if (a1[i]>6) {flag=0;       Break    }} if (flag) return true; else return false;}    int main () {int n;    int x, y;    cin>>n;        while (n--) {memset (b,0,sizeof (b));        int t=0;        for (int i=x;i<=y;i++) {a[t++]=i;            } for (int i=0;i<t;i++) {sprintf (b, "%06d", A[i]); Converts an integer into a character array to store if (Zhuanhua (b)) printf ("%06d\n", A[i]);    } printf ("\ n"); } return 0;}
The correct code:

#include <iostream> #include <stdio.h> #include <math.h> #include <string> #include <        String.h>using namespace Std;int A[1000010];char b[10];int a1[10];bool Zhuanhua (char b[]) {for (int i=0;i<6;i++)   {a1[i]=b[i]-' 0 ';   } int flag=1;           for (int i=0;i<6;i++) {if (a1[i]>6) {flag=0;       Break            }} for (int i=0;i<4;i++) {if (a1[i]==a1[i+1]&&a1[i+1]==a1[i+2]) {flag=0;        Break            }} for (int i=0;i<5;i++) {if (Fabs (A1[i+1]-a1[i]) >4) {flag=0;        Break    }} if (flag) return true; else return false;}    int main () {int n;    int x, y;    cin>>n;        while (n--) {memset (b,0,sizeof (b));        int t=0;        cin>>x>>y;        for (int i=x;i<=y;i++) {a[t++]=i; } for (int i=0;i<t;i++) {sprintf (b, "%06d"), A[i]);        if (Zhuanhua (b)) printf ("%06d\n", A[i]);    } printf ("\ n"); } return 0;}




Nyoj---topic 7.33 million Saints ' Day party

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.