题解 【Codeforces755A】 PolandBall and Hypothesis
我们可以发现,当n>2时,n·(n-2)+1=(n-1)·(n-1),因此,输出n-2即可。
如果n<=2,我们可以发现:
当n=2时,2·4+1=9不是质数,输出4即可;
当n=1时,1·3+1=4不是质数,输出3即可。
至此,此题就被我们解决了!
AC代码:
#include <bits/stdc++.h>//万能头文件
using namespace std;//使用标准名字空间
inline int read() { //快速读入
int f=,x=;
char c=getchar();
while(c<'' || c>'') {
if(c=='-')f=-;
c=getchar();
}
while(c>='' && c<='') {
x=x*+c-'';
c=getchar();
}
return f*x;
}
int n,m;
int main() {
n=read();//输入n
if(n>) { //如果n>2
printf("%d",n-);//就输出n-2
return ;
}
if(n==) { //如果n=2
printf("");//就输出4
return ;
}
if(n==) { //如果n=1
printf("");//就输出3
return ;
}
return ;//结束
}
题解 【Codeforces755A】 PolandBall and Hypothesis的更多相关文章
- 【codeforces 755A】PolandBall and Hypothesis
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 题解 CF755A 【PolandBall and Hypothesis】
直接从1开始枚举不就行了... 思路如下: 1.先定义一个判断是不是质数的函数 int pd(int n) { if(n==1)return true; if(n==2)return false; f ...
- 题解-CF755G PolandBall and Many Other Balls
题面 CF755G PolandBall and Many Other Balls 给定 \(n\) 和 \(m\).有一排 \(n\) 个球,求对于每个 \(1\le k\le m\),选出 \(k ...
- Codeforces 755A:PolandBall and Hypothesis(暴力)
http://codeforces.com/problemset/problem/755/A 题意:给出一个n,让你找一个m使得n*m+1不是素数. 思路:暴力枚举m判断即可. #include &l ...
- 解题报告8VC Venture Cup 2017 - Elimination Round
题目链接:http://codeforces.com/contest/755 本蒟蒻做了半天只会做前两道题.. A. PolandBall and Hypothesis 题意:给出n,让你找出一个m, ...
- 大素数判断(miller-Rabin测试)
题目:PolandBall and Hypothesis A. PolandBall and Hypothesis time limit per test 2 seconds memory limit ...
- 某5道CF水题
1.PolandBall and Hypothesis 题面在这里! 大意就是让你找一个m使得n*m+1是一个合数. 首先对于1和2可以特判,是1输出3,是2输出4. 然后对于其他所有的n,我们都可以 ...
- CF755G PolandBall and Many Other Balls 题解
从神 Karry 的题单过来的,然后自己瞎 yy 了一个方法,看题解区里没有,便来写一个题解 一个常数和复杂度都很大的题解 令 \(dp_{i,j}\) 为 在 \(i\) 个球中选 \(j\) 组的 ...
- CF755C PolandBall and Forest 题解
Content 给定无向图的 \(n\) 个点的父亲节点,求无向图的联通块个数. 数据范围:\(1\leqslant n\leqslant 10^4\). Solution 并查集模板题. 我们将在当 ...
随机推荐
- 1.Docker Compose
一.Docker Compose 简介 概述 Compose 项目是 Docker 官方的开源项目,负责实现对 Docker 容器集群的快速编排.从功能上看,跟 OpenStack 中的 Heat 十 ...
- Nginx出现403 forbidden
我装在linux上的nginx版本是1.16 当我在nginx/conf/nginx.conf文件里配置完代理 location /ds { root /home/nginx; index index ...
- H5_0012:js事件冒泡和捕获
捕获(capture)和冒泡(bubble)是事件传播过程中的两个概念, 比如用户单击某个元素, 但由于元素处于父元素内, 该父元素又处于document对象中, document对象又处于windo ...
- 375. 猜数字大小 II
题目: 链接:https://leetcode-cn.com/problems/guess-number-higher-or-lower-ii/ 我们正在玩一个猜数游戏,游戏规则如下: 我从 1 到 ...
- Git和TortoiseGit
1.简介 Git是一个开源的分布式版本控制系统,用于敏捷高效的处理任何或大或小的项目.它采用了分布式版本库的方式,不必服务器端软件支持. 2.Git和Svn的区别 1.Git 是分布式的,SVN 不是 ...
- 一个扩展搜索API的优化过程
概述 API 是一个服务的门面,就像衣装是人的形象一样. 优雅的 API 设计,能让业务方使用起来倍儿爽,提升开发效率,降低维护成本:糟糕的 API 设计,则让业务方遭心,陷入混沌. 本文将展示一个扩 ...
- CSS:display:none的使用注意事项
总结:display:none 属性会使元素完全隐藏,js无法获得元素,通过js设置style.display="inline-block" 后 js才可获得此元素的属性和内容 ...
- 文件包含漏洞(DVWA环境中复现)
LOW: 源代码: <?php // The page we wish to display $file = $_GET[ 'page' ]; ?> 可以看到,low级别的代码对包含的文件 ...
- sap gui中打断点,进入不了断点
1: 当abap development tool 打开时,会影响sap gui中的断点进入. 2: 需要sap gui和abap development tool 都关闭,重新进入sap gui打 ...
- Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/Type
问题描述 将项目挂载到 Myeclipse 的 tomcat 上,启动 tomcat ,报错“Initialization of bean failed; nested exception is ja ...