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. Elasticsearch之入门知识

    elasticsearch是一个高度可扩展得开源全文搜索和分析的引擎.可以快速.近实时的存储,搜索和分析大量数据.通常用作底层引擎技术,为具有复杂搜索功能和要求的程序提供支持. 用处: • 运行网上商 ...

  2. HackerRank Super Six Substrings dp

    https://www.hackerrank.com/contests/hourrank-18/challenges/super-six-substrings 能被6整除的数有一个特点,就是能同时被3 ...

  3. git与GitHub(二)

    昨天在安装完git之后,出了一个问题,虽然暂时有解决的办法,但是由于电脑中了病毒并且配置低下等原因,这个问题的解决办法目前还有待考证.遇到的问题是这样的: 前提是想试一下git在命令行里的命令:于是: ...

  4. react注意点

    event 对象 和普通浏览器一样,事件监听函数会被自动传入一个 event 对象,这个对象和普通的浏览器 event 对象所包含的方法和属性都基本一致.不同的是 React.js 中的 event  ...

  5. 浅析document和window的区别

    1.执行时间 window.onload必须等到页面内包括图片的所有元素加载完毕后才能执行.         $(document).ready()是DOM结构绘制完毕后就执行,不必等到加载完毕. 2 ...

  6. shell中使用ssh

    ssh服务是不能用非交互的方式传递密码,想不输入密码,直接ssh连接到服务器有两种方法,sshpass和expect sshpass # wget http://downloads.sourcefor ...

  7. 华硕笔记本刷BIOS

    笔记本硬件升级后想使用微软的Windows xp mode,之后发现笔记本BIOS中没有虚拟化选项,想通过升级BIOS的方法来解决,结果失败. 升级后出现关机后无法关闭电源指示灯以及风扇的问题,之后只 ...

  8. SQL中的动态语句执行--exec(@sqlstr)

    begin drop table #tmptable declare @money ut_money set @money=1.2345 create table #tmptable ( je ut_ ...

  9. bat 批处理测试局域网速度 两端电脑

    C:\Users\Administrator>iperf3 iperf3: parameter error - must either be a client (-c) or server (- ...

  10. 2012-2013 ACM-ICPC, NEERC, Central Subregional Contest C Sequence (打表)

    打个表找找规律,到24445的时候乘2以后产生了0出现循环. 一般地,判断循环节是否存在可以用Floyd判圈算法. #include<bits/stdc++.h> using namesp ...