题解 【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 并查集模板题. 我们将在当 ...
随机推荐
- matlab HW求法笔记
for i=1:9400 Sbox_out_11(i) = length(findstr(num2str(dec2bin(Sbox_out_1(i,:))),'1')); end
- python3练习100题——004
继续做题-经过python3的测试 原题链接:http://www.runoob.com/python/python-exercise-example4.html 题目:输入某年某月某日,判断这一天是 ...
- jQuery---音乐导航
音乐导航 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...
- harbor仓库部署时启用https时的常见错误KeyError: 'certificate'等
出现 KeyError: 'certificate' 错误 先确认你的配置是否正确,例如harbor.yml里的https证书位置是否正确,证书是否正常无误 如果上述无误确反复报错,请确认你的harb ...
- php 文件追加写入
//追加写入 file_put_contents('xml.text',json_encode($postObj,JSON_FORCE_OBJECT).PHP_EOL,FILE_APPEND);
- Hadoop的完全分布式搭建
一.准备虚拟机两台 1.将虚拟机进行克隆https://www.cnblogs.com/the-roc/p/12336745.html 2.1将克隆虚拟机的IP修改一下 vi /etc/sysconf ...
- [TJOI2015] 线性代数 - 最大权闭合子图
展开 \(D=(AB-C)A^T\\ =\sum_{i=1}^n(\sum_{j=1}^na_jb_{j,i}-c_i)a_i\\ =\sum_{i=1}^n\sum_{j=1}^na_ia_jb_{ ...
- PP: Sequence to sequence learning with neural networks
From google institution; 1. Before this, DNN cannot be used to map sequences to sequences. In this p ...
- PHP实现推送微信小程序模板消息
这边只会写如何实现,至于在公众号管理后台添加模板消息可以参考这篇文章: https://www.cnblogs.com/txw1958/p/wechat-template-message.html,当 ...
- BOM笔记
目录 BOM (浏览器对象模型) 简介 window对象 子对象 history 子对象 lacation 子对象 navigator 子对象 screen 子对象 frames BOM (浏览器对象 ...