URAL 2031. Overturned Numbers (枚举)

2031. Overturned Numbers

Time limit: 1.0 second

Memory limit: 64 MB

Little Pierre was surfing the Internet and came across an interesting puzzle:

What is the number under the car?

It took some time before Pierre solved the puzzle, but eventually he understood that there were overturned numbers 86, 88, 89, 90, and 91 in the picture and the answer was the number 87.

Now Pierre wants to entertain his friends with similar puzzles. He wants to construct a sequence of
n numbers such that its overturning produces a consecutive segment of the positive integers. Pierre intends to use one-digit integers supplemented with a leading zero and two-digit integers only.To avoid ambiguity, note that when the digits 0, 1, and
8 are overturned, they remain the same, the digits 6 and 9 are converted into each other, and the remaining digits become unreadable symbols.

Input

The only line contains the number n of integers in a sequence (1 ≤
n ≤ 99).

Output

If there is no sequence of length n with the above property, output “Glupenky Pierre” (“Silly Pierre” in Russian).Otherwise, output any of such sequences. The numbers in the sequence should be separated with a space.

Samples

input output
2
11 01
99
Glupenky Pierre

Problem Author: Nikita Sivukhin

Problem Source: Ural Regional School Programming Contest 2014

解析:题目要求翻转后为连续序列的序列,直接枚举就可以。

AC代码:

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    while(scanf("%d", &n) != EOF){
        if(n == 1) puts("01");
        else if(n == 2) puts("11 01");
        else if(n == 3) puts("06 68 88");
        else if(n == 4) puts("16 06 68 88");
        else puts("Glupenky Pierre");
    }
    return 0;
}
时间: 2024-10-11 11:16:04

URAL 2031. Overturned Numbers (枚举)的相关文章

递推DP URAL 1586 Threeprime Numbers

题目传送门 1 /* 2 题意:n位数字,任意连续的三位数字组成的数字是素数,这样的n位数有多少个 3 最优子结构:考虑3位数的数字,可以枚举出来,第4位是和第3位,第2位组成的数字判断是否是素数 4 所以,dp[i][j][k] 表示i位数字,最高位数字j,第二高位数字k 5 状态转移方程:dp[i][j][k] += dp[i-1][k][l] 6 注意:最高位从1开始枚举:) 7 详细解释:http://blog.csdn.net/zhangyanxing666/article/detai

URAL 1792. Hamming Code (枚举)

1792. Hamming Code Time limit: 1.0 second Memory limit: 64 MB Let us consider four disks intersecting as in the figure. Each of the three shapes formed by the intersectionof three disks will be called a petal. Write zero or one on each of the disks.

URAL 1500. Pass Licenses 枚举+位运算

1500. Pass Licenses Time limit: 2.5 second Memory limit: 64 MB A New Russian Kolyan believes that to spend his time in traffic jams is below his dignity. This is why he had put an emergency flashlight upon the roof of his Hummer and had no problems u

【线性筛】【筛法求素数】【约数个数定理】URAL - 2070 - Interesting Numbers

素数必然符合题意. 对于合数,如若它是某个素数x的k次方(k为某个素数y减去1),一定不符合题意.只需找出这些数. 由约数个数定理,其他合数一定符合题意. 就从小到大枚举素数,然后把它的素数-1次方都排除即可. #include<cstdio> #include<cmath> using namespace std; #define MAXP 1000100 #define EPS 0.00000001 typedef long long ll; ll L,R; bool isNo

Ural 1586 Threeprime Numbers(DP)

题目地址:Ural 1586 先定义一个prime三维数组来记录素数,若i*100+j*10+k为素数,则标记prime[i][j][k]为1,否则为0.这样对后面的处理很方便. 然后定义一个dp三维数组,dp[n][i][j]表示当前n位的十位数字为i,个位数字为j时的素数个数,这时候状态要从prime[k][i][j]为素数时转移过来,所以状态转移方程为: if(prime[j][k][h])         dp[i][k][h]+=dp[i-1][j][k] 代码如下: #include

URAL 2070 Interesting Numbers(数学)

题目地址:http://acm.timus.ru/problem.aspx?space=1&num=2070 思路:质数一定满足题意(满足条件一,因子数为2为质数).所以只需求出l到r中的合数且因子数为质数的数的个数.该数质因子只能为1(若大于一,则因子数为合数),所以枚举每个质数,若该质数的指数+1(因子数)为质数,则ans--. #include<cstdio> #include<vector> #include<cstring> #include<i

ural 1009 K-based Numbers

 1009. K-based Numbers Time limit: 1.0 second Memory limit: 64 MB Let's consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notation doesn't contain two successive zeros. For example: 1010230 is a va

ural 1009. K-based Numbers dp 高精度

点击打开链接 1009. K-based Numbers Time limit: 1.0 second Memory limit: 64 MB Let's consider K-based numbers, containing exactly N digits. We define a number to be valid if itsK-based notation doesn't contain two successive zeros. For example: 1010230 is a

ural 1118. Nontrivial Numbers

1118. Nontrivial Numbers Time limit: 2.0 secondMemory limit: 64 MB Specialists of SKB Kontur have developed a unique cryptographic algorithm for needs of information protection while transmitting data over the Internet. The main advantage of the algo