【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 ...
随机推荐
- bigdecimal解决小数间的加减乘除
public class bigdecimal { public static BigDecimal div(double v1,double v2){ BigDecimal b1=new BigDe ...
- Vim用法AAAAA
.linux系统中如何进入退出vim编辑器,方法及区别 我们当然要保存并退出了,然后下一步了.这时,我们要按键盘左上角的"ESC",留意到了没有?左下角的插入状态不见了,如图. 然 ...
- POJ 3805 Separate Points (判断凸包相交)
题目链接:POJ 3805 Problem Description Numbers of black and white points are placed on a plane. Let's ima ...
- el-select 1.4.x版本实现2.x.x版本的reserve-keyword功能
今天在维护以前的项目时,发现了一个小bug,其实也不算是bug,只是客户对这个控件的体验不是很满意. 我们在element 2.x.x的版本的官方文档中可以发现el-select组件的属性中比1.x. ...
- 【构造共轭函数+矩阵快速幂】HDU 4565 So Easy! (2013 长沙赛区邀请赛)
[解题思路] 给一张神图,推理写的灰常明白了,关键是构造共轭函数,这一点实在是要有数学知识的理论基础,推出了递推式,接下来就是矩阵的快速幂了. 神图: 给个大神的链接:构造类斐波那契数列的矩阵快速幂 ...
- Pregel Aggregator
- mysql组合查询
使用UNION 多数SQL查询都只包含一个或多个表中返回数据的单条SELECT语句.MySQL也允许执行多个查询(多条SELECT语句),并将结果作为单个查询结果集返回.这些组合查询通常称为并(uni ...
- 微信小程序之自定义组件
在微信小程序项目中 肯定会存在很多功能和样式上相似的部分 面对这种情况 只是单单的ctrl+c ctrl+v 就显得很low了,而且也不便于后期维护那么这时候 使用微信小程序中的自定义组件功能就很合适 ...
- CSIC_716_20191127【组合,封装、类的私有属性方法、property装饰器】
组合 what? 组合是指一个对象中,包含另一个或多个对象. why? 减少代码的冗余. How? 在类中加入其他类的对象,实现跨类对象之间的联动. 耦合度 软件设计要 高内聚 ...
- wordpress添加视频弹窗插件Video PopUp
Video PopUp 给外部div 添加class类名:class="main-play" a链接添加 class="vp-a" 测试链接地址:https: ...