这次网络赛没有打。生病了去医院了。。尴尬。晚上回来才看了题补简单题。


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 ;
}

最新文章

  1. pt-table-checksum
  2. vuejs,router
  3. C# 數據事務操作
  4. AngularJS的学习--TodoMVC的分析
  5. 简单认识UISwitch
  6. OSGi 学习(一)
  7. Solr4.8.0源码分析(15) 之 SolrCloud索引深入(2)
  8. table边框设置
  9. 第36篇 Asp.Net源码解析(一)
  10. 算法基础_递归_给定m个A,n个B,一共有多少种排列
  11. 面试回顾——kafka
  12. Android Studio: Application Installation Failed
  13. altera FIFO知识点
  14. Codeforces731C(SummerTrainingDay06-M 并查集)
  15. Android 面试知识集1
  16. php中session的简单使用
  17. Beta Scrum Day 2 — 听说
  18. 【bzoj 2716】[Violet 3]天使玩偶 (CDQ+树状数组)
  19. 补知识:EntityFramework Core映射关系详解
  20. bzoj 3709: [PA2014]Bohater 贪心

热门文章

  1. Core Dump总结
  2. C++的ofstream与ifstream使用
  3. rbd_rados命令拷屏
  4. Spellchecker inspection helps locate typos and misspelling in your code, comments and literals, and fix them in one click
  5. 1044 Shopping in Mars (25 分)
  6. 2.执行计划(explain)分析
  7. C# 反射入门
  8. 新建pc端页面的模板
  9. AForge.Video.FFMPEG库几个注意事项
  10. C语言之文件包含