【2018ACM/ICPC网络赛】沈阳赛区
这次网络赛没有打。生病了去医院了。。尴尬。晚上回来才看了题补简单题。
K Supreme Number
题目链接:https://nanti.jisuanke.com/t/31452
题意:输入一个整数n(其实可以当成字符串,因为很长啊。),求满足不超过n的supreme number。这个supreme number的定义是,这个字符串的子串都是质数。比如。137就是,但是19就不是。
题解:找规律。我先开始题没看懂,没懂子串也要为素数。后面才看到。然后在纸上枚举了一下可能出现的情况。发现大于4位数之后的只有317可以满足。所以打表列举即可。
代码:
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const int N =1e8+;
const int mod = 1e9+;
int T;
int sp[] = {,,,,,
,,,,,,,,,
,,,,
,,}; int change(string s){
int num = ;
for( int i = ;i < s.size(); i++){
num = num * + s[i] - '';
}
return num;
} int main(){
cin>>T;
int t = ;
while(T--){
string s;
cin>>s;
int len = s.size();
if(len >= ){
printf("Case #%d: 317\n",t++);
}
else{
int num = change(s); for(int i = ; i <= ;i++){
if(num == sp[i]){
printf("Case #%d: %d\n",t++,sp[i]);
break;
}
else if(num < sp[i]){
printf("Case #%d: %d\n",t++,sp[i-]);
break;
}
}
}
}
return ;
}
【2018ACM/ICPC网络赛】沈阳赛区的更多相关文章
- 【2018ACM/ICPC网络赛】焦作赛区
A Magic Mirror 题目链接:https://nanti.jisuanke.com/t/31710 题意:输入字符串,如果是“Jessy”就输出“Good Guy!",否则输出“D ...
- 【2018ACM/ICPC网络赛】徐州赛区
呃.自闭了自闭了.我才不会说我写D写到昏天黑地呢. I Characters with Hash 题目链接:https://nanti.jisuanke.com/t/31461 题意:给你一个字符串 ...
- 【icpc网络赛大连赛区】Sparse Graph
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submissi ...
- Supreme Number 2018沈阳icpc网络赛 找规律
A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying ...
- Ryuji doesn't want to study 2018徐州icpc网络赛 树状数组
Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, ea ...
- 2019沈阳icpc网络赛H德州扑克
题面:https://nanti.jisuanke.com/t/41408 题意:A,2,3,4,5,6,7,8,9,10,J,Q,K,13张牌,无花色之分,val为1~13. 给n个人名+n个牌,输 ...
- Trace 2018徐州icpc网络赛 (二分)(树状数组)
Trace There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx ...
- Trace 2018徐州icpc网络赛 思维+二分
There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy) ...
- Features Track 2018徐州icpc网络赛 思维
Morgana is learning computer vision, and he likes cats, too. One day he wants to find the cat moveme ...
随机推荐
- 11、jQueryEasyUI的基本组件
1.拖动的div <!--jquery 的主文件...--> <script type="text/javascript" src="../../js/ ...
- Ethenet: MAC PHY MII RMII
https://www.cnblogs.com/liangxiaofeng/p/3874866.html 1. general 下图是网口结构简图.网口由CPU.MAC和PHY三部分组成.DMA控制器 ...
- qemu通过命令行直接引导linux内核启动
qemu -kernel vmlinuz-3.14.0 -hda img_custom -append root=/dev/sda1
- css过滤镜实现颜色渐变
语法:filter : progid:DXImageTransform.Microsoft.Gradient ( enabled=bEnabled , startColorStr=iWidth , e ...
- ubuntu 无pthread
由于学习多线程编程,所以用到pthread,但是man的时候却发现没有pthread函数库的手册页,然后安装 $sudo apt-get install glibc-doc 安装以后,发现还是有很多函 ...
- mysql(自动添加系统时间)timestamp类型字段的CURRENT_TIMESTAMP与ON UPDATE CURRENT_TIMESTAMP属性
timestamp有两个属性,分别是CURRENT_TIMESTAMP 和ON UPDATE CURRENT_TIMESTAMP两种,使用情况分别如下: 1.CURRENT_TIMESTAMP 当要向 ...
- ABP 3.7版本迁移数据库报错未能加载文件或程序集“Castle.Core, Version=4.0.0.0”
ABP 3.7 3.8版本升级后迁移数据库,报错未能加载文件或程序集“Castle.Core, Version=4.0.0.0”,System.ComponentModel.Annotations也可 ...
- opencv 图像细化
图像细化多用于机器人视觉,OCR字符识别等领域,细化后的图像经过去毛刺就成为了我们常说的图像的骨架. 该图像细化代码依据论文: T. Y. ZHANG and C. Y. SUEN A Fast P ...
- 记录一次工作中jvm被linux杀死的调查
首先,以后碰到任何jvm的错误,先看日志!!!!!!!! web项目在tomcat目录下的log里,或者自己设定的errorfile目录下.总之,找到一切可以运用的日志,比如crash日志,cored ...
- fedora28 安装automake
yum install automake yum install hg //版本管理