ICPC2018Beijing Race D Frog and Portal site construction

Portal

 

A very interesting question structure, training with his teammates, has been considering, transmitted by k to k, set breakpoints, and then multiply each section principle, Fibonacci summation row to take items, like the idea of ​​the product, and wrong.

 

Some obvious conclusions.

Is equal to the total number of programs, the program number reaches 199, plus 198 reaches the number of programs. But we transferred to the k by k, the number of programs can be constructed behind are empty.

Transmitted from k to k, the scheme is not included in the total number of layers reaches the program.

Transmitted from k to 199, the total accounting program reaches into the double layer program.

Transmitted from k to k + 1, k + 1 is reached the program will be tired layer reaches added program-k layer.

 

We found that the above three configurations, and have a 0,1 + (2 fold relative ie simultaneously), we consider the n binary split.

 

N is 7 for example, split into 1,2,4.

1 to the total number of 199 + 1 = 0 Scheme 1 Scheme 1 starting from number 11123 .....

3 to 4 transferred from the beginning of the program number 11122 .....

5 to transmit the total number of 199 + 2 = 3 Scheme 1 Scheme 1 starting from the number 11122224 ...

7-8 transmitted from the beginning of the program number 111222244 ...

9 199 Total number of transmission schemes having 3 + 4 = 7 from Scheme 1 starting 111222244

From 10 to 10 transmits a start program number 11122224440000 .... sealed play effect

 

Another example n is 5, split into 4.

1 to the total number of 199 + 1 = 0 Scheme 1 Scheme 1 starting from Number 11123 ....

3 to 4 transferred from the beginning of the program number 11122 ...

5-5 transmitted from the beginning of the program number 11122224 ...

7-8 transmitted from the beginning of the program number 111222244 ...

199 Total number of transmitted Scheme 1 + 4 = 5 from Scheme 1 starting number 111222244

From 10 to 10 transmits a start program number 11122224440000 .... sealed play effect

 

Portals can be seen very regular in odd odd, to increase the current of a power of 2, or 0 increases. When an even number of techniques, used to double the power of 2. Finally, sealed with a portal.

 The code should be right, but has been submitted wa. Try some other blog in the ac wa code is also lost. Speculation evaluation machine pan.

 1 #include <cstdio>
 2 using namespace std;
 3 typedef long long ll;
 4 int ans,n;
 5 int main()
 6 {
 7     while (scanf("%lld",&n) > 0)
 8     {
 9         if (n == 0)
10         {
11             printf("2\n1 1\n2 1\n");
12             continue;
13         }
14         ans = 0;
15         for (int i = 31;i >= 0;i--)
16             if (n & (1ll << i))
17             {
18                 ans = i;
19                 break;
20             }
21         printf("%d\n",(ans + 1) * 2);
22         for (int i = 0;i <= ans;i++)
23         {
24             if (n & (1ll << i))
25                 printf("%d 199\n",i * 4 + 1);    
26             else
27                 printf("%d %d\n",i * 4 + 1,i * 4 + 1);
28             if (i != ans)
29                 printf("%d %d\n",i * 4 + 3,i * 4 + 4);
30             else
31                 printf("%d %d\n",i * 4 + 2,i * 4 + 2);
32         }
33     }
34     return 0;
35 }

 

Guess you like

Origin www.cnblogs.com/iat14/p/11628020.html