ACM-ICPC 2018 沈阳赛区网络预赛 K. Supreme Number
A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying two smaller natural numbers.
Now lets define a number NN as the supreme number if and only if each number made up of an non-empty subsequence of all the numeric digits of NN must be either a prime number or 11.
For example, 1717 is a supreme number because 11, 77, 1717 are all prime numbers or 11, and 1919 is not, because 99 is not a prime number.
Now you are given an integer N\ (2 \leq N \leq 10^{100})N (2≤N≤10100), could you find the maximal supreme number that does not exceed NN?
Input
In the first line, there is an integer T\ (T \leq 100000)T (T≤100000) indicating the numbers of test cases.
In the following TT lines, there is an integer N\ (2 \leq N \leq 10^{100})N (2≤N≤10100).
Output
For each test case print "Case #x: y", in which xx is the order number of the test case and yy is the answer.
样例输入复制
2
6
100
样例输出复制
Case #1: 5
Case #2: 73
题目来源
一个数包含他的子串都是素数
[1,2,3,5,7,11,13,17,23,31,37,53,71,73,113,131,137, |
一个数包含他的子序列都是素数
1,2,3,5,7,11,13,17,23,31,37,53,71,73,113,131,137,173,311,317,
ACM-ICPC 2018 沈阳赛区网络预赛 K. Supreme Number的更多相关文章
- ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)
https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...
- ACM-ICPC 2018 沈阳赛区网络预赛-K:Supreme Number
Supreme Number A prime number (or a prime) is a natural number greater than 11 that cannot be formed ...
- ACM-ICPC 2018 沈阳赛区网络预赛 K题
题目链接: https://nanti.jisuanke.com/t/31452 AC代码(看到不好推的定理就先打表!!!!): #include<bits/stdc++.h> using ...
- 【ACM-ICPC 2018 沈阳赛区网络预赛 K】Supreme Number
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然每个数字只可能是1,3,5,7 然后如果3,5,7这些数字出现两次以上.显然两个3||5||7都能被11整除. 然后1的话最多能 ...
- ACM-ICPC 2018 沈阳赛区网络预赛-D:Made In Heaven(K短路+A*模板)
Made In Heaven One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. ...
- 图上两点之间的第k最短路径的长度 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven
131072K One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. Howe ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph
"Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a ...
- ACM-ICPC 2018 沈阳赛区网络预赛 J树分块
J. Ka Chang Given a rooted tree ( the root is node 11 ) of NN nodes. Initially, each node has zero p ...
- ACM-ICPC 2018 焦作赛区网络预赛 K题 Transport Ship
There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry th ...
随机推荐
- python开篇随记
脚本环境,解释器处理 #!/usr/bin/env python # -*- coding:utf-8 -*- 变量 ■ 变量名只能由字母.数字和下划线组合 ■ 变量名不能以数字开头 ■ 关键字不能自 ...
- Spark Mllib里如何将数值特征字段用StandardScaler进行标准化(图文详解)
不多说,直接上干货! 首先,要明白为什么有时候,数值特征字段需要进行标准化? 答:因为,当我们若用回归分析算法时,必须将数值特征字段进行标准化,这是因为数值特征字段单位不同,数字差异很大,所以无法彼此 ...
- Error CS0579 Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute
今天在引入ClassLibraryQikuo的时候突然报错 Error CS0579 Duplicate 'System.Reflection.AssemblyTitleAttribute' attr ...
- Objective-C Data Encapsulation
All Objective-C programs are composed of the following two fundamental elements: Program statements ...
- 关于一个app中数据库的问题
如果是不同名字的数据库,可以有多个数据库操作dao 如果是同样名字的数据库,只能有一个数据库操作dao,创建表的语句可以写在一个oncreate方法里面 例如 public class Address ...
- SnowKiting 2017/1/24
原文 Let's go fly a kite...in the snow Your snowkiting checklist To snowkite safely,you'll need a litt ...
- Luogu P4609 [FJOI2016]建筑师&&CF 960G Bandit Blues
考虑转化题意,我们发现其实就是找一个长度为\(n\)的全排列,使得这个排列有\(A\)个前缀最大值,\(B\)个后缀最大值,求方案数 我们考虑把最大值拎出来单独考虑,同时定义一些数的顺序排列为单调块( ...
- Python基础篇 -- 运算符和编码
运算符 记熟 ! ! ! 2**1=2 2**2=4 2**3=8 2**4=16 2**5=32 2**6=64 2**7=128 2**8=256 2**9=512 2**10=1024 运算符 ...
- strchr函数
函数原型:extern char *strchr(char *str,char character) 参数说明:str为一个字符串的指针,character为一个待查找字符. 所在库名 ...
- luogu愚人节比赛划水记
先放链接:愚人节比赛 说好的 不毒瘤 呢?题目都太神奇了吧! 管理员的脑洞orz T1 这个可以说是蒙数据蒙出来的,直接输出"0",AC T2 本机房dalao成功发现" ...