CodeForce 923A PromalSport

S7-200 Smart 控制运动轴(脉冲电机/伺服)教程 S7-200 Smart 控制运动轴(脉冲电机/伺服) 结合本人刚接触触摸屏时候的踩坑经验,编写S7-200 Smart 控制运动轴(脉冲电机/伺服)的详细流程,给刚接触PLC的朋友提供一些经验指导。 本文详细介绍了S7-200 Smart 控制脉冲步进/伺服电机流程,包含接线方法及梯形图。希望对初学者有所帮助 阅读详情

B. Primal Sport
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below.

Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the current number, and announces the smallest multiple of this prime number that is not smaller than the current number.

Formally, he or she selects a prime p < Xi - 1 and then finds the minimum Xi ≥ Xi - 1 such that p divides Xi. Note that if the selected prime palready divides Xi - 1, then the number does not change.

Eve has witnessed the state of the game after two turns. Given X2, help her determine what is the smallest possible starting number X0. Note that the players don't necessarily play optimally. You should consider all possible game evolutions.

Input

The input contains a single integer X2 (4 ≤ X2 ≤ 106). It is guaranteed that the integer X2 is composite, that is, is not prime.

Output

Output a single integer — the minimum possible X0.

Examples
input
Copy
14
output
6
input
Copy
20
output
15
input
Copy
8192
output
8191
Note

In the first test, the smallest possible starting number is X0 = 6. One possible course of the game is as follows:

  • Alice picks prime 5 and announces X1 = 10
  • Bob picks prime 7 and announces X2 = 14.

In the second case, let X0 = 15.

  • Alice picks prime 2 and announces X1 = 16
  • Bob picks prime 5 and announces X2 = 20.

题意:

两人玩游戏,每人选一个比当前值小的素数a,要求写出一个比当前值大的最小的数,这个数是a的倍数。现在游戏已经进行了两轮,给出第二轮的值,求最小的开始值。

找到X2的最大质因数k,X1的范围就在X2-k+1到X2之间,在这些数用同样方法找X0,取最小值。

#include<bits/stdc++.h>
#define maxn 1000010
#define INF 0x3f3f3f3f
using namespace std;
bool p[maxn];
int ser[maxn];
void prime()
{
    memset(p,1,sizeof(p));
    p[1]=p[0]=0;
    //memset(ser,1,sizeof(ser));
    for(int i=2;i<maxn;i++)
    {
        if(p[i])
        {
            ser[i]=1;
            for(int j=i+i;j<maxn;j+=i)
            {
                p[j]=0;
                ser[j]=i;
            }
        }
    }
}
int main()
{
    int x2;
    prime();
    while(scanf("%d",&x2)!=EOF)
    {
        int ans=INF;
        for(int i=x2-ser[x2]+1;i<x2;i++)
        {
                ans=min(ans,i-ser[i]+1);
        }
        if(ans==INF)
            ans=x2-1;
        printf("%d\n",ans);
    }
    return 0;
}



Trae CN 使用入门指南 【代码】Trae CN 使用入门指南。 阅读详情

相关推荐

LED灯闪烁实验:实验介绍

每个章节都会单独进行验证工作,例如Simulink开发的应用层软件,会在Simulink-TestHarness中进行仿真,通过Scope示波器模块输出0-1交替的结果。CubeIDE集成双方的代码后,会烧写到开发板中验证是否按照定义的时间进行闪烁。ST-LINK V2是STM32开发生态系统中常用的硬件调试接口,能够连接微控制器与开发环境,实现程序的下载、调试和分析。STM32F103C8T6最小系统板是基于STM32F103C8T6微控制器的开发板,本实验会涉及使用板载的连接PC13引脚的LED灯。

u013288925的博客 435

D. Soldier and Number Game/牛牛的“质因数”(欧拉筛处理最小/最大质因数)

https://ac.nowcoder.com/acm/contest/9982/I https://codeforces.com/problemset/problem/546/D 思路:总的思路就是要o(n)拿出每个数的最大/最小质因数。然后就可以logn处理。 欧拉筛本身的处理就是可以把v[i]存成i的最小质因数来筛,详见F. 1.小W 的质数(prime)[欧拉筛再理解] 如果我要处理出每个数的最大质因数呢?类似一个dp的思路 Maxp[x]:表示x的最大质因子 枚举的i是x的最大因.

代码笔记本 329

增距镜或中继镜选型

增距镜光路图

camerall 5197

(codeforce547)C-Mike and Foam(质因子+容斥原理)

(codeforce547)C-Mike and Foam(质因子+容斥原理)

AC__dream的博客 938

Codeforces 923A - Primal Sport

传送门:Primal SportA. Primal Sporttime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob begin their day with a quick game. They first choos...

勇敢前进的ACMer 1371

Codeforces 923A Primal Sport

A. Primal Sporttime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob begin their day with a quick game. They first choose a starting num...

Kizuna_AI的博客 797

codeforces 948B Primal Sport

B. Primal Sporttime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob begin their day with a quick game. They first choose a sta...

nankeyimeng的博客 1869

Codeforces 923A Primal Sport(贪心 欧拉筛)

题目链接:Primal Sport 题意 AliceAliceAlice 和 BobBobBob 两人在玩一个游戏,AliceAliceAlice 先开始,两人轮流进行,第 iii 次游戏中,对于一个整数 XiXiX_i,选择一个素数 p&lt;Xip&lt;XipYYY,使得 Y≥XY≥XY\geq X 且 YYY 能被 ppp 整除,将这个数字作为下一次游戏的新值 Xi+1Xi+1X...

Dmaxiya 427

Codeforces Round #470 (rated, Div. 2,(数字,质因子)

B. Primal Sport time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Alice and Bob begin their day with a quick game. They first cho...

城南的花 322

Codeforces Round #470ABC 题解

A - Protect Sheep CodeForces - 948A (暴力)水题不贴代码了,暴力判断羊的相邻的四个点有没有狼,如果没有的话暴力把所有空的点填上狗- -B - Primal Sport CodeForces - 948B (数学)Alice and Bob begin their day with a quick game. They first choose a startin...

neuq_zsmj的博客 482

Codeforces Round#470

CF948A Protect Sheep(模拟)没看到输出“Yes”卡了二十分钟【再见】 CF923A Primal Sport(线性素数筛,数学) CF923B Producing Snow(树状数组+二分/平衡树) CF923C Perfect Security(贪心+Trie) CF923D Picking Strings(手玩题)

Icefox的博客 482

Opus 5大模型性能分析:响应速度、输出质量与成本优化策略

大语言模型(LLM)作为人工智能领域的核心技术,通过Transformer架构实现文本生成与推理能力。其工作原理基于注意力机制,能够理解上下文语义并生成连贯内容。在工程实践中,LLM的技术价值体现在自动化文本处理、智能对话系统等场景,但模型复杂度提升可能带来响应延迟和成本增加等挑战。本文聚焦Opus 5模型的实际表现,针对用户反馈的响应速度和输出质量稳定性问题,结合API调用成本分析,探讨大模型在真实应用环境中的优化方案与部署策略。

434

hdu4371 Alice and Bob---博弈------多校联合8

Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 99    Accepted Submission(s): 62 Problem Description Alice and Bob are

Shirley 1720

Codeforces Round #470 div2 C

C. Producing Snowtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice likes snow a lot! Unfortunately, this year's winter is already over, and she...

ACM_e的博客 814

Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1) B. Primal Sport

B. Primal Sporttime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob begin their day with a quick game. They first choose a starting num...

风语之城的博客 413

Primal Sport

Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below. Alice goes first and then they take alternatin...

雪霜贸贸,荠麦之茂 347

质因数的思维题

Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below. Alice goes first and then they take alterna...

weixin_34245082的博客 165

ACdream群赛1112(Alice and Bob)

题意:http://acdream.info/problem?pid=1112 Problem Description Here  is Alice and Bob again ! Alice and Bob are playing a game. There are several numbers.First, Alice choose a number n.Then he c

xiefubao的专栏 1700

博弈——Alice and Bob

Alice and Bob are interested in playing games. One day, they invent a game which has rules below:  1. Firstly, Alice and Bob choose some random positive integers, and here we describe them as n, d 1,

LSC_333的博客 1031

A:Alice and Bob

A:Alice and Bob Alice and Bob are very smart guys and they like to play all kinds of games in their spare time. The most amazing thing is that they always find the best strategy, and that's why they

w750636248的专栏 1452

codeforces923b(前缀和 优先队列)

B. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alice likes snow a lot! Unfortunately, thi

yypurpose的博客 420

VK Cup 2018 Round 1: A. Primal Sport

A. Primal Sporttime limit per test 1.5 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputAlice and Bob begin their day with a quick game. They first choose a starting...

加载中... 618
上一篇: Codeforces 470Div 2 C. Producing Snow
下一篇: L3-001. 凑零钱
DlPF_C
博客等级 码龄10年 12粉丝 147原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值