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


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网络赛】沈阳赛区的更多相关文章

  1. 【2018ACM/ICPC网络赛】焦作赛区

    A Magic Mirror 题目链接:https://nanti.jisuanke.com/t/31710 题意:输入字符串,如果是“Jessy”就输出“Good Guy!",否则输出“D ...

  2. 【2018ACM/ICPC网络赛】徐州赛区

    呃.自闭了自闭了.我才不会说我写D写到昏天黑地呢. I  Characters with Hash 题目链接:https://nanti.jisuanke.com/t/31461 题意:给你一个字符串 ...

  3. 【icpc网络赛大连赛区】Sparse Graph

    Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submissi ...

  4. Supreme Number 2018沈阳icpc网络赛 找规律

    A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying ...

  5. 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 ...

  6. 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个牌,输 ...

  7. Trace 2018徐州icpc网络赛 (二分)(树状数组)

    Trace There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx ...

  8. Trace 2018徐州icpc网络赛 思维+二分

    There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy) ...

  9. Features Track 2018徐州icpc网络赛 思维

    Morgana is learning computer vision, and he likes cats, too. One day he wants to find the cat moveme ...

随机推荐

  1. Linux 线程Demo

    #include <stdio.h> #include <pthread.h> struct char_print_params { char character; int c ...

  2. 2、Locust压力测试 实战

    创建测试脚本 创建Test()类继承TaskSet类 创建beigong() 方法表示一个行为,访问北弓官网首页.用@task() 装饰该方法为一个任务.1表示一个Locust实例被挑选执行的权重,数 ...

  3. 1.6 USB的插入检测机制

  4. JAR API

    JAR API包括使用 manifest 文件的类.Manifest类的一个对象表示一个manifest文件. 在代码中创建一个Manifest对象,如下所示: 1 Manifest manifest ...

  5. 深入浅出JS:Two

    JS中的Promise: MDN上面对promise的描述:Promise 对象用于表示一个异步操作的最终状态(完成或失败),以及其返回的值. 可以直接对字面上理解:Promise:承诺,一诺千金,只 ...

  6. USACO2012 overplanting /// 矩阵切割 递归 oj21547

    题目大意: 在农场的任何一个“轴向对齐”的长方形区域(即垂直和水平方向)种植草坪. 现种植了N(1≤ N ≤10)个不同的矩形区域,其中一些甚至可能重叠. Input Multiple test ca ...

  7. c# mvc 简洁大气官网

    后台管理 https://g.alicdn.com/idleFish-F2e/app-basic/item.html?itemid=580281597427&ut_sk=1.WCB2zfWM% ...

  8. mysql的索引方法btree和hash的区别

    原文链接: http://www.91w.net/database/330.html 1. Hash索引: Hash 索引结构的特殊性,其检索效率非常高,索引的检索可以一次定位,不像B-Tree 索引 ...

  9. [HDU3333]Turing Tree

    莫队模板题... 不过树状数组也可以做...跟HH的项链几乎一模一样,离线询问,然后记录前缀,更新的时候把前缀删掉就好了,然而这题开long long,卡空间 //hgs AK IOI,IMO,ICH ...

  10. Codeforces 1152D DP

    题意:有一颗由长度为2 * n的合法的括号序列构成的字典树,现在你需要在这颗字典树上选择一些不连接的边,问最多可以选择多少条边? 思路:不考虑题目条件的话,我们只考虑在随意的一棵树上选择边,这是一个贪 ...