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 沈阳赛区网络预赛的更多相关文章

  1. ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)

    https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...

  2. 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 ...

  3. 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. ...

  4. 图上两点之间的第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 ...

  5. 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 ...

  6. 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 ...

  7. ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph

    "Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a ...

  8. Fantastic Graph 2018 沈阳赛区网络预赛 F题

    题意: 二分图 有k条边,我们去选择其中的几条 每选中一条那么此条边的u 和 v的度数就+1,最后使得所有点的度数都在[l, r]这个区间内 , 这就相当于 边流入1,流出1,最后使流量平衡 解析: ...

  9. ACM-ICPC 2018 沈阳赛区网络预赛 F Fantastic Graph(贪心或有源汇上下界网络流)

    https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. ...

  10. ACM-ICPC 2018 沈阳赛区网络预赛 B Call of Accepted(表达式求值)

    https://nanti.jisuanke.com/t/31443 题意 给出一个表达式,求最小值和最大值. 表达式中的运算符只有'+'.'-'.'*'.'d',xdy 表示一个 y 面的骰子 ro ...

随机推荐

  1. Delphi Compiler Bug?

    I found a Bug of Delphi XE3 Compiler,It may exists in XE4,XE5. Here is the code to show the bug proc ...

  2. ImageMagick命令执行学习笔记(常见于图片预览处)

    实验版本: ImageMagick版本:6.9.2 push graphic-context viewbox 0 0 640 480 fill 'url(https://"|whoami&q ...

  3. 20155325 2016-2017-2 《Java程序设计》课程总结

    (按顺序)每周作业链接汇总 预备作业1:浅谈对师生关系的看法以及对未来学习生活的展望 预备作业2:学习娄老师<做中学>系列文章.自身C语言情况.Java课程目标 预备作业3:安装虚拟机情况 ...

  4. 20155330 实验一《Java开发环境的熟悉》(Windows+IDEA)实验报告

    实验知识点 JVM.JRE.JDK的安装位置与区别: 命令行运行javac:java:javac -cp; java -cp: PATH,CLASSPATH,SOURCEPATH的设定方法与应用: 包 ...

  5. java开发划分级别的标准

    一.史诗序: java开发也有一段时间了,整天茫茫碌碌,除了偶尔的小有成就感,剩下的大部分好像都在重复,你是否也遇到了这样的情况? 遇到一个小细节问题,之前不久解决过,现在却是什么都记不起来了 面对每 ...

  6. day1 创建X00001文件1K

    要求:创建文件名为:X000001-X999999,大小为1K 的文件 版本1) import os #1.输入要创建的文件数量 nums = int(input("nums:") ...

  7. SaltStack入门篇(三)之数据系统Grains、Pillar

    1.什么是Grains? Grains是saltstack的组件,用于收集salt-minion在启动时候的信息,又称为静态信息.可以理解为Grains记录着每台Minion的一些常用属性,比如CPU ...

  8. python根据正则表达式的简单爬虫

    今天根据正则表达式简单的爬了一下大众点评,把北京的美食爬了爬,(店铺名,人均消费,地址) import re import urllib.request from urllib.request imp ...

  9. 文件批量加密重命名--python脚本AND mysql命令行导入数据库

    在考试中学生交上来的报告,需要进行一下文件名加密,这样阅卷老师就不知道是谁的报告了 在百度帮助下,完成了加密和解密脚本, 加密 #!/usr/bin/python # -*- coding: utf- ...

  10. php实现快速排序和冒泡排序

    快速排序 实现思路:把第一个元素作为标记,依次判断后续的值,如果小于它则放在左边,如果大于它则放右边,同理把左右两部分看成一个整体一直递归,最后再数组拼接起来 它的最优时间复杂度为O(nlogn)[以 ...