zoukankan      html  css  js  c++  java
  • Codeforces 755A:PolandBall and Hypothesis(暴力)

    http://codeforces.com/problemset/problem/755/A

    题意:给出一个n,让你找一个m使得n*m+1不是素数。

    思路:暴力枚举m判断即可。

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <cmath>
     4 #include <cstdlib>
     5 #include <algorithm>
     6 #include <string>
     7 #include <iostream>
     8 #include <stack>
     9 #include <map>
    10 #include <queue>
    11 #include <set>
    12 using namespace std;
    13 typedef long long LL;
    14 #define N 100010
    15 #define INF 0x3f3f3f3f
    16 
    17 int main()
    18 {
    19     int n;
    20     cin >> n;
    21     for(int i = 1; i <= 1000; i++) {
    22         int num = i * n + 1;
    23         int tmp = sqrt(num);
    24         bool flag = 0;
    25         for(int i = 2; i <= tmp; i++) {
    26             if(num % i == 0) {
    27                 flag = 1; break;
    28             }
    29         }
    30         if(flag) {
    31             printf("%d
    ", i);
    32             break;
    33         }
    34     }
    35     return 0;
    36 }
  • 相关阅读:
    python之类的详解
    flask中cookie和session介绍
    Flask数据库的基本操作
    CSRF原理
    Ajax.2
    浅谈Ajax
    Django中的缓存机制
    Django简介
    HTTP协议
    web应用
  • 原文地址:https://www.cnblogs.com/fightfordream/p/6291491.html
Copyright © 2011-2022 走看看