Codeforces 755A:PolandBall and Hypothesis(暴力)
http://codeforces.com/problemset/problem/755/A
题意:给出一个n,让你找一个m使得n*m+1不是素数。
思路:暴力枚举m判断即可。
- #include <cstdio>
- #include <cstring>
- #include <cmath>
- #include <cstdlib>
- #include <algorithm>
- #include <string>
- #include <iostream>
- #include <stack>
- #include <map>
- #include <queue>
- #include <set>
- using namespace std;
- typedef long long LL;
- #define N 100010
- #define INF 0x3f3f3f3f
- int main()
- {
- int n;
- cin >> n;
- for(int i = ; i <= ; i++) {
- int num = i * n + ;
- int tmp = sqrt(num);
- bool flag = ;
- for(int i = ; i <= tmp; i++) {
- if(num % i == ) {
- flag = ; break;
- }
- }
- if(flag) {
- printf("%d\n", i);
- break;
- }
- }
- return ;
- }
Codeforces 755A:PolandBall and Hypothesis(暴力)的更多相关文章
- 【codeforces 755A】PolandBall and Hypothesis
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces Gym 100015H Hidden Code 暴力
Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hac ...
- Codeforces gym 100685 A. Ariel 暴力
A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...
- Codeforces Gym 100637G G. #TheDress 暴力
G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G ...
- [ An Ac a Day ^_^ ] CodeForces 691F Couple Cover 花式暴力
Couple Cover Time Limit: 3000MS Memory Limit: 524288KB 64bit IO Format: %I64d & %I64u Descri ...
- Codeforces 626D Jerry's Protest(暴力枚举+概率)
D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- codeforces 650D D. Image Preview (暴力+二分+dp)
题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memo ...
- Codeforces Gym 100203G Good elements 暴力乱搞
原题链接:http://codeforces.com/gym/100203/attachments/download/1702/statements.pdf 题解 考虑暴力的复杂度是O(n^3),所以 ...
- Codeforces 839D Winter is here - 暴力 - 容斥原理
Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n s ...
随机推荐
- XF 列表视图事件
<?xml version="1.0" encoding="utf-8" ?><ContentPage xmlns="http:// ...
- C# IDisposable接口的使用
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- ASP UserInfoList 方法1
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserInfoList.a ...
- golang并发编程的两种限速方法
引子 golang提供了goroutine快速实现并发编程,在实际环境中,如果goroutine中的代码要消耗大量资源时(CPU.内存.带宽等),我们就需要对程序限速,以防止goroutine将资源耗 ...
- C#可扩展编程之MEF学习笔记(五):MEF高级进阶(转)
好久没有写博客了,今天抽空继续写MEF系列的文章.有园友提出这种系列的文章要做个目录,看起来方便,所以就抽空做了一个,放到每篇文章的最后. 前面四篇讲了MEF的基础知识,学完了前四篇,MEF中比较常用 ...
- WPF中的资源(一) - 静态资源和动态资源
原文:WPF中的资源(一) - 静态资源和动态资源 WPF中,每个界面元素都含有一个名为Resources的属性,其存储的是以"键-值"对形式存在的资源,而其子级元素在使用这些资源 ...
- Android零基础入门第86节:探究Fragment生命周期
一个Activity可以同时组合多个Fragment,一个Fragment也可被多个Activity 复用.Fragment可以响应自己的输入事件,并拥有自己的生命周期,但它们的生命周期直接被其所属的 ...
- DBShop 电子商务网店系统
DBShop 电子商务网店系统,采用业界知名框架 ZendFramework 2 开发而成. 下面为功能简介 1.在线更新:在线系统更新和在线模板安装与更新,简单.方便.快捷,省却了手动更新的繁琐步骤 ...
- Windows Azure之Mobile Service
我建个android app和Windows Azure的Mobile Service配合,以实现会员注册的功能,实际十分简单,微软家的东西真心好用 首先新建个Mobile Service New-& ...
- Delphi中动态调用TXMLDocument的经历
var vXMLDocument: TXMLDocument;begin vXMLDocument := TXMLDocument.Create('c:/temp/temp.xml'); Cap ...