UESTC 1272 Final Pan's prime numbers(乱搞)
Description
Final Pan likes prime numbers very much.
One day, he want to find the super prime numbers.A prime numbers $n$($n$>4) is a super prime number only if $n$-4 and $n$+4 are both prime numbers,too.
Your task is really easy:Give $N$,find the maximum super prime number $n$ that $n$<=$N$.
Input
Only one integer $N.( 4<N<10^{12} )$
Output
If there is no such interger $n$,print'$-1$',otherwise print $n$.
Sample Input
8
Sample Output
7
题解:暴力超时,遂乱搞,这种题可以自己跑个1000组下来,最后发现满足这个条件的数只有一个7...
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
#define PI 3.1415926
#define ms(a) memset(a,0,sizeof(a))
#define msp memset(mp,0,sizeof(mp))
#define msv memset(vis,0,sizeof(vis))
using namespace std;
//#define LOCAL
bool prime(int n)
{
if(n==)return true;
for(int i=;i<=sqrt(n);i++)
{
if(n%i==)return false;
}
return true;
}
int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
//Start
long long n;
while(cin>>n)
{
if(n>=)printf("7\n");
else printf("-1\n");
}
return ;
}
UESTC 1272 Final Pan's prime numbers(乱搞)的更多相关文章
- CDOJ 1272 Final Pan's prime numbers
有些问题,不做实践与猜测,可能一辈子也想不出答案,例如这题. #include<stdio.h> #include<math.h> long long x; int main( ...
- UESTC--1272--Final Pan's prime numbers(水题)
Final Pan's prime numbers Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & % ...
- cdoj Dividing Numbers 乱搞记忆化搜索
//真tm是乱搞 但是(乱搞的)思想很重要 解:大概就是记忆化搜索,但是原数据范围太大,不可能记下所有的情况的答案,于是我们就在记下小范围内的答案,当dfs落入这个记忆范围后,就不进一步搜索,直接返回 ...
- hdu-5676 ztr loves lucky numbers(乱搞题)
题目链接: ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- algorithm@ Sieve of Eratosthenes (素数筛选算法) & Related Problem (Return two prime numbers )
Sieve of Eratosthenes (素数筛选算法) Given a number n, print all primes smaller than or equal to n. It is ...
- Sum of Consecutive Prime Numbers(poj2739)
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22019 Ac ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2739 Sum of Consecutive Prime Numbers(尺取法)
题目链接: 传送门 Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Description S ...
- HDOJ(HDU) 2138 How many prime numbers(素数-快速筛选没用上、)
Problem Description Give you a lot of positive integers, just to find out how many prime numbers the ...
随机推荐
- udp接收
char receive_buffer[500] = {0}; std::vector<std::string> mysplit(std::string str,std::string p ...
- 自定义Dialog,从下面弹出
Window window= getWindow(); 只要 打开一个Activity 就有一个窗口存放这个Activity ,手机又很多个窗口,不只是一个窗口 import android.app. ...
- [ An Ac a Day ^_^ ] [kuangbin带你飞]专题八 生成树 UVA 10600 ACM Contest and Blackout 最小生成树+次小生成树
题意就是求最小生成树和次小生成树 #include<cstdio> #include<iostream> #include<algorithm> #include& ...
- java基础第二天
学习了关键字,标识符,数据类型.变量和常量,运算符和表达式,开始编写一些简单的输入输出运算的程序了.
- 在vmware workstation10上安装ubuntu14.04,出现以下问题
VMware提示:已将该虚拟机配置为使用 64 位客户机操作系统.但是,无法执行 64 位操作. (1)设置bois 对于HP电脑来说,刚开机时,按住F10,会出现以下界面: 然后回车进行设置: 重启 ...
- NGUI中的Tween的委托使用
public TweenPosition tweenIn; public TweenScale tweenOut; EventDelegate In = new EventDelegate(this, ...
- SQLite模糊查找(like)
select UserId,UserName,Name,Sex,Birthday,Height,Weight,Role from xqhit_Users where UserName like &qu ...
- 在MVC里使用 HttpContext.Response输出内容
public ActionResult About() { byte[] ss = System.Text.Encoding.UTF8.GetBytes("111122"); Ht ...
- 关于IT实例教程
W3c:http://www.w3school.com.cn/ 易百:http://www.yiibai.com/ 菜鸟教程:http://www.runoob.com/
- Design Pattern——单一职责原理
在类的职责分离上多考虑,做到单一职责,这样的代码才能做到易于维护,易扩展,灵活多样.