【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 ...
随机推荐
- 批处理禁止指定的IE的加载项
步骤: 1.查找插件对应的 CLSID 获取 HKCU\Software\Microsoft\Windows\CurrentVersion\Ext\Stats 下的 CLSID, 然后在 HKCR\C ...
- 带头结点的双向循环链表----------C语言
/***************************************************** Author:Simon_Kly Version:0.1 Date: 20170520 D ...
- 关闭windows的DEP
1.与开启dep时一样,按组合键win+r打开运行窗口,输入cmd并按回车,如图所示: 2.调出命令提示符窗口后,输入bcdedit.exe/set {current} nx AlwaysOff ...
- ()centos7 安装mysql8.0
一.下载mysql 1 .下载 https://dev.mysql.com/downloads/repo/yum/ wget http://repo.mysql.com/mysql80-communi ...
- 浅谈HP-Socket在物联网的应用
原文链接:https://my.oschina.net/chrisforbt/blog/1669746 一.应用背景 去年公司成立了个项目——<智慧用电安全隐患监管服务平台>,计划是开发一 ...
- arttemplate 后台返回的数据格式问题
1. 2.JSON.parse() 方法用于将一个 JSON 字符串转换为对象. $("body").on("click","#analyze&quo ...
- 内存Zone中的pageset成员分析
1: struct per_cpu_pageset __percpu *pageset; 首先,分析一个函数,__free_pages,这个函数是Buddy System提供的API接口函数,用于翻译 ...
- ICPC Asia Nanning 2017 F. The Chosen One (高精度运算)
题目链接:The Chosen One 比赛链接:ICPC Asia Nanning 2017 题意 \(t\) 组样例,每组给出一个整数 \(n(2\le n\le 10^{50})\),求不大于 ...
- 微信小程序开发之https服务器搭建三步曲
本篇文章主要讲述3个方面的内容,如下: 1.SSL证书的获取 2.服务器 Nginx SSL 证书的配置. 3.如何兼容80端口和443端口以及为什么要同时兼容这两个端口. 1.SSL证书的获取 ht ...
- 使用Postman模拟HTTP请求
使用Postman模拟HTTP请求 Postman是一款强大的前端调试工具,不管是开发人员还是测试人员都会需要调试接口程序,如RestAPI,此时可以通过向服务器发送不同的HTTP请求来判断接口返回结 ...