ACM-ICPC 2018 沈阳赛区网络预赛
Supreme Number
- 1000ms
- 131072K
A prime number (or a prime) is a natural number greater than 111 that cannot be formed by multiplying two smaller natural numbers.
Now lets define a number NNN as the supreme number if and only if each number made up of an non-empty subsequence of all the numeric digits of NNN must be either a prime number or 111.
For example, 171717 is a supreme number because 111, 777, 171717 are all prime numbers or 111, and 191919 is not, because 999 is not a prime number.
Now you are given an integer N (2≤N≤10100)N\ (2 \leq N \leq 10^{100})N (2≤N≤10100), could you find the maximal supreme number that does not exceed NNN?
Input
In the first line, there is an integer T (T≤100000)T\ (T \leq 100000)T (T≤100000) indicating the numbers of test cases.
In the following TTT lines, there is an integer N (2≤N≤10100)N\ (2 \leq N \leq 10^{100})N (2≤N≤10100).
Output
For each test case print "Case #x: y"
, in which xxx is the order number of the test case and yyy is the answer.
样例输入
2
6
100
样例输出
Case #1: 5
Case #2: 73
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[] = {,,,,,,,,,,,,,,,,,,,
};
int s;
int t,count = ;
cin >> t;
while(t--)
{
cin >> s;
cout << "Case #" << count++ << ": " ;
if(s >= )
{
cout << a[] << endl;
continue;
}
else
{
for(int i = ; i >= ; i --)
{
if(s >= a[i])
{
cout << a[i] << endl;
break;
}
}
}
}
return ;
}
ACM-ICPC 2018 沈阳赛区网络预赛的更多相关文章
- 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 沈阳赛区网络预赛-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 沈阳赛区网络预赛 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. Supreme Number
A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph
"Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a ...
- Fantastic Graph 2018 沈阳赛区网络预赛 F题
题意: 二分图 有k条边,我们去选择其中的几条 每选中一条那么此条边的u 和 v的度数就+1,最后使得所有点的度数都在[l, r]这个区间内 , 这就相当于 边流入1,流出1,最后使流量平衡 解析: ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F Fantastic Graph(贪心或有源汇上下界网络流)
https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. ...
- ACM-ICPC 2018 沈阳赛区网络预赛 B Call of Accepted(表达式求值)
https://nanti.jisuanke.com/t/31443 题意 给出一个表达式,求最小值和最大值. 表达式中的运算符只有'+'.'-'.'*'.'d',xdy 表示一个 y 面的骰子 ro ...
随机推荐
- php 面试常问 基础知识
字符串都是海针 数组是针海 输出及打印 echo 8%(-2); //输出结果为0 模后的正负号可无视 模前的有用 echo date('Y-m-d H:i:s',strtotime('-1 day' ...
- Ubuntu16.04安装CDH5.14.2
一.安装cloudera manager(下文简称cm) (一).环境及软件准备: 1.环境:Ubuntu16.04 desktop x 3 台 ip分别为:10.132.226.121,10.132 ...
- python-类(1)
·类(Class) 笔记: Python是一种面向对象(Object Oriented)的编程语言,类(Class)是Python的核心概念.在Python中,不管是列表.字符串.函数和类都是对象. ...
- C语言 编程练习22
一.题目 1.编一个程序,输入x的值,按下列公式计算并输出y值: 2.已知数A与B,由键盘输入AB的值,交换它们的值,并输出. 3.给一个不多于5位的正整数,要求:一.求它是几位数,二.逆序打印出各位 ...
- 笔记(assert 断言)
并发:在同一个时间段交替执行多个任务并行:在同一个时间点同时执行多个任务串行:同时执行的多个任务按顺序执行(换句话说就是一个任务执行完后才能执行下一个任务) #mysql limit用法: selec ...
- SAP SM13 V2更新队列批量执行
SE38输入程序名RSM13005 Function Module 输入MCEX_UPDATE_03 Client 输入800 其他默认 执行
- Oracle入门第三天(上)——多表查询与分组函数
一.多表查询 所有的连接分析,参考之前随笔:http://www.cnblogs.com/jiangbei/p/7420136.html 1.笛卡尔积 select last_name, depart ...
- 20155215 2016-2017-2 《Java程序设计》第4周学习总结
20155215 2016-2017-2 <Java程序设计>第X周学习总结 教材学习内容总结 第六章 继承,避免多个类间重复定义共同行为.子类继承父类,再扩充(extends)其他行为. ...
- 20155231 2016-2017-2 《Java程序设计》第3周学习总结
20155231 2016-2017-2 <Java程序设计>第3周学习总结 教材学习内容总结 学习目标 区分基本类型与类类型 理解对象的生成与引用的关系 掌握String类和数组 理解封 ...
- 分享daocloud联合创始人陈齐彦关于docker的一段阐述
罗比,本名陈齐彦,他在加入DaoCloud之前是EMC中国研究院的总架构师,云平台及应用实验室的创始人.谈及创业的初心,他激动了起来: 容器这东西和当年Hadoop一样,是互联网技术对企业IT技术的逆 ...