【2018ACM/ICPC网络赛】沈阳赛区
2024-09-06 06:31:59
这次网络赛没有打。生病了去医院了。。尴尬。晚上回来才看了题补简单题。
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 ;
}
最新文章
- pt-table-checksum
- vuejs,router
- C# 數據事務操作
- AngularJS的学习--TodoMVC的分析
- 简单认识UISwitch
- OSGi 学习(一)
- Solr4.8.0源码分析(15) 之 SolrCloud索引深入(2)
- table边框设置
- 第36篇 Asp.Net源码解析(一)
- 算法基础_递归_给定m个A,n个B,一共有多少种排列
- 面试回顾——kafka
- Android Studio: Application Installation Failed
- altera FIFO知识点
- Codeforces731C(SummerTrainingDay06-M 并查集)
- Android 面试知识集1
- php中session的简单使用
- Beta Scrum Day 2 — 听说
- 【bzoj 2716】[Violet 3]天使玩偶 (CDQ+树状数组)
- 补知识:EntityFramework Core映射关系详解
- bzoj 3709: [PA2014]Bohater 贪心
热门文章
- Core Dump总结
- C++的ofstream与ifstream使用
- rbd_rados命令拷屏
- Spellchecker inspection helps locate typos and misspelling in your code, comments and literals, and fix them in one click
- 1044 Shopping in Mars (25 分)
- 2.执行计划(explain)分析
- C# 反射入门
- 新建pc端页面的模板
- AForge.Video.FFMPEG库几个注意事项
- C语言之文件包含