兰伯特-切比雪夫定理【数论】

首先引用一下百度百科上面贴的定理
图片说明

然后这里给出一道模板题 小道消息
题目讲解:视频讲解
代码

#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll maxn = 1e6+10;
double eps = 1e-8;

ll N,K;

bool is_prime(ll x){
    for(ll i = 2;i*i <= x;i++) if(x%i ==0) return false;
    return true;
}
int main(){
    cin>>N>>K;
    N++,K++;
    if(is_prime(K) && 2LL*K>N) puts("1");
    else puts("2");

    return 0;
}
Ryuichi的算法分享 文章被收录于专栏

分享我的一些算法题解,致力于把题解做好,部分题解可能会采用视频的形式来讲解。

全部评论

相关推荐

玉无心❤️:发照片干啥 发简历啊
点赞 评论 收藏
分享
完美的潜伏者许愿简历通过:我上表jd,请求封我做后端大将军的事,北京有消息了:竟然不许!!! 他们一定是看我没有实习,这才故意驳回我的请求!
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务