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

题目来源

ACM-ICPC 2018 沈阳赛区网络预赛

一个数包含他的子串都是素数

[1,2,3,5,7,11,13,17,23,31,37,53,71,73,113,131,137,
173,311,313,317,373,1373,3137]

一个数包含他的子序列都是素数

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的更多相关文章

  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 沈阳赛区网络预赛 K题

    题目链接: https://nanti.jisuanke.com/t/31452 AC代码(看到不好推的定理就先打表!!!!): #include<bits/stdc++.h> using ...

  4. 【ACM-ICPC 2018 沈阳赛区网络预赛 K】Supreme Number

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然每个数字只可能是1,3,5,7 然后如果3,5,7这些数字出现两次以上.显然两个3||5||7都能被11整除. 然后1的话最多能 ...

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

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

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

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

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

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

随机推荐

  1. Codeforces Round #533(Div. 2) A.Salem and Sticks

    链接:https://codeforces.com/contest/1105/problem/A 题意: 给n个数,找到一个数t使i(1-n)∑|ai-t| 最小. ai-t 差距1 以内都满足 思路 ...

  2. Vue初始化

    Vue上面的函数怎么来的 vue的打包路径 在web中使用的vue打包路径: npm run build 打包生成vue.js 下面是依次引入: src/platforms/web/entry-run ...

  3. 解决 openSUSE 中 Sublime Text 3 的中文显示和输入问题

    测试环境 系统版本:openSUSE Leap 42.2 桌面环境:KDE Plasma 5输入法:fcitx-rime (中州韵) 见周围用 Windows 和 macOS 的小伙伴几乎都在用简单强 ...

  4. Spark无法创建新线程

    Spark提交程序报错,无法创建新的线程 原因是因为这台公用机器上跑的进程太多了,需要修改Linux参数,允许用户最大进程数 查看允许用户最大进程数配置 ulimit -a 修改允许用户最大进程数配置 ...

  5. 别让CDN的回源把你的服务器拖垮,采用正确的回源策略

    我们有一台服务器提供的服务主要是以动态页面为主,静态页面都是固定的内容平时更新的很少,最近这台服务器的应用升级到了新版本访问量增大了不少,随之的问题就来了,最近每天一到9点负载就超过警戒值,然后负载持 ...

  6. 初始Mybatis,好累,自己感觉自己快坚持不了了

    Mybatis1.持久化 持久化,就是内存数据和硬盘数据状态的转换 2.ORM思想Object Relation Mapping 对象关系映射 3.MyBatis入门案例 3.1导入jar包 依赖 & ...

  7. Java 8新特性--Lambda表达式作为返回值

    lambda表达式作为方法的返回值:

  8. volatile双重锁实现单例

    双重锁实现单例时遭到质疑,既是:双重锁也无法保证单例模式! 原因是:指令会重排序,普通的变量仅仅会保证该方法在执行时,所有依赖的赋值结果是正确的,但不会保证执行顺序! 为什么会重排序:指令重排序是指c ...

  9. ES-windos环境搭建(2)

    下载 打开elasticsearch官网.选择downloads. 选择elasticsearch,并单击Download. 这里我们不选择最新版,而是选择靠前的版本,下拉选择past release ...

  10. 跨平台C++开源代码的两种常用编译方式

    作者:朱金灿 来源:http://blog.csdn.net/clever101 跨平台C++开源代码为适应各种编译器的编译,采用了两种方式方面来适配.一种是makefile方式.以著名的空间数据格式 ...