Codeforces 923 A. Primal Sport
http://codeforces.com/contest/923/problem/A
题意:
初始有一个x0,可以选择任意一个<x0的质数p,之后得到x1为≥x0最小的p的倍数
然后再通过x1按照一样的算法得出一个x2
已知x2,问x0最小可能是多少
设f[x] 表示<x 的最大的x的质因数
那么x1 ∈ [x2-f[x2]+1,x2]
同理,可以得到x0
#include<cstdio> using namespace std; int f[]; #define min(x,y) ( (x)<(y) ? (x) : (y) ) int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;++i)
{
if(!f[i])
for(int j=i<<;j<=n;j+=i) f[j]=i;
f[i]=i-f[i]+;
}
int ans=1e6;
for(int i=f[n];i<=n;++i) ans=min(ans,f[i]);
printf("%d",ans);
}
Codeforces 923 A. Primal Sport的更多相关文章
- 【Codeforces 947A】 Primal Sport
[题目链接] 点击打开链接 [算法] 不难看出,x1的范围是[x2-P(x2)+1,x2],x0的范围是[x1-P(x1)+1,x1] 我们可以先做一遍线性筛,然后暴力就可以了 [代码] #inclu ...
- 【Codeforces 923A】Primal Sport
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 考虑怎么得到数字x2=N,假设是质数p的倍数 那么x1肯定在x2-p+1~x2这个范围内才行 因为p的倍数要刚好大于等于x1, 所以x1肯定是 ...
- CodeForces 948B Primal Sport
Primal Sport 题意:2个人玩游戏, 每次轮到一个人选择一个比当前值小的素数, 然后在找到比素数的倍数中最小的并且不小于当前数的一个数. 现在这个游戏玩了2轮, 现在想找到最小的那个起点X0 ...
- VK Cup 2018 - Round 1 A. Primal Sport
A. Primal Sport time limit per test 1.5 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)B. Primal Sport
Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try ...
- Codeforces 923 D. Picking Strings
http://codeforces.com/contest/923/problem/D 题意: A-->BC , B-->AC , C-->AB , AAA-->empty 问 ...
- Codeforces 923 C. Perfect Security
http://codeforces.com/contest/923/problem/C Trie树 #include<cstdio> #include<iostream> us ...
- Codeforces 923 B. Producing Snow
http://codeforces.com/contest/923/problem/B 题意: 有n天,每天产生一堆体积为Vi的雪,每天所有雪堆体积减少Ti 当某一堆剩余体积vi<=Ti时,体积 ...
- CF948B Primal Sport
题目链接:http://codeforces.com/contest/948/problem/B 知识点: 素数 解题思路: \(f(x)\) 表示 \(x\) 的最大素因子.不难想到:\(X_1 \ ...
随机推荐
- 3、Docker容器管理
一.容器创建 1.创建命令 docker container [root@localhost harbor]# docker container Usage: docker container CO ...
- Appium+Python3+ Android入门
前言: Appium 是一个自动化测试开源工具,支持 iOS 平台和 Android 平台上的原生应用,web 应用和混合应用. 一.环境配置 1.安装Node.js https://nodejs.o ...
- Varnish 4.0 实战
简介 Varnish 是一款高性能且开源的反向代理服务器和 HTTP 加速器,其采用全新的软件体系机构,和现在的硬件体系紧密配合,与传统的 squid 相比,varnish 具有性能更高.速度更快.管 ...
- ElasticSearch 2 (4) - API Convention
ElasticSearch 2.1.1 (4) - API Convention The elasticsearch REST APIs are exposed using JSON over HTT ...
- ElasticSearch 2 (2) - Setup
ElasticSearch 2.1.1 (2) - Setup Installation Elasticsearch can be started using: $ bin/elasticsearc ...
- alpha冲刺随笔(一)
项目Alpha冲刺(团队) Alpha冲刺第一天 姓名 学号 博客链接 何守成 031602408 http://www.cnblogs.com/heshoucheng/ 黄锦峰 031602411 ...
- SpringBoot 5.SpringBoot小知识讲解
1.修改 server 端口: 在 application.properties 中添加 server.port=9090,我们的端口号就会变成9090了. 2.自定义配置Web: 2.1 创建 Cu ...
- webgl 模板缓冲
先思考个问题, 想实现遮罩怎么办? <!doctype html> <html> <head> <meta charset="utf-8" ...
- 深入理解Java反射+动态代理
答: 反射机制的定义: 是在运行状态中,对于任意的一个类,都能够知道这个类的所有属性和方法,对任意一个对象都能够通过反射机制调用一个类的任意方法,这种动态获取类信息及动态调用类对象方法的功能称为j ...
- python自动化之鼠标移动
################################用GUI自动化控制键盘和鼠标############################### ''' http://pyautogui.r ...