判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town
/*
题意: 求(n-1)! mod n
数论:没啥意思,打个表能发现规律,但坑点是4时要特判!
*/
/************************************************
* Author :Running_Time
* Created Time :2015-8-15 19:06:12
* File Name :A.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e5 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ; bool is_prime(int x) {
if (x == || x == ) return true;
if (x % != && x % != ) return false;
for (int i=; i*i<=x; i+=) {
if (x % i == || x % (i + ) == ) return false;
}
return true;
} int main(void) { //BestCoder Round #51 (div.2) 1001 Zball in Tina Town
int T; scanf ("%d", &T);
while (T--) {
int n; scanf ("%d", &n);
if (n == ) {
puts (""); continue;
}
if (is_prime (n)) {
printf ("%d\n", n - );
}
else puts ("");
} return ;
}
判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town的更多相关文章
- BestCoder Round #51 (div.2)
明显是无良心的数学round= = 1000 Zball in Tina Town #include<iostream> #include<cstdio> #include&l ...
- 找规律 Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks
题目传送门 /* 找规律,水 */ #include <cstdio> #include <iostream> #include <algorithm> #incl ...
- 找规律 Codeforces Round #290 (Div. 2) A. Fox And Snake
题目传送门 /* 水题 找规律输出 */ #include <cstdio> #include <iostream> #include <cstring> #inc ...
- BestCoder Round #50 (div.1) 1001 Distribution money (HDU OJ 5364)
题目:Click here 题意:bestcoder上面有中文题目 #include <iostream> #include <cstdio> #include <cst ...
- BestCoder Round 69 Div 2 1001&& 1002 || HDU 5610 && 5611
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5610 如果杠铃总质量是奇数直接impossible 接着就考验耐心和仔细周全的考虑了.在WA了三次后终于发 ...
- BestCoder Round #81 (div.2)1001
Machine Accepts: 580 Submissions: 1890 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65 ...
- ACM学习历程—HDU5585 Numbers(数论 || 大数)(BestCoder Round #64 (div.2) 1001)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5585 题目大意就是求大数是否能被2,3,5整除. 我直接上了Java大数,不过可以对末尾来判断2和5, ...
- 构造 BestCoder Round #52 (div.2) 1001 Victor and Machine
题目传送门 题意:有中文版的 分析:首先要知道机器关闭后,w是清零的.所以一次(x + y)的循环弹出的小球个数是固定的,为x / w + 1,那么在边界时讨论一下就行了 收获:这种题目不难,理解清楚 ...
- hdu 5636 搜索 BestCoder Round #74 (div.2)
Shortest Path Accepts: 40 Submissions: 610 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: ...
随机推荐
- 利用WiFi Pineapple Nano渗透客户端获取SHELL
前言: 前两篇文章介绍了The WiFi Pineapple Nano设备的一些主要功能模块,例如PineAP.SSLsplit和Ettercap等.今天给大家实际场景演示下如何利用Pineapple ...
- 关于对FLASH开发,starling、starling feathers、starling MVC框架的理解
说在前头:楼主之前没有不论什么flash开发经验,仅仅是从一次尝试中总结自己的理解和经验而已.假设有写的不正确的地方,欢迎大家指正. 前一段时间尝试想用flash(as3)又一次制作一下之前做的一个游 ...
- MYSQL 增加字段不报错,插入数据不报错处理
') ON DUPLICATE KEY UPDATE sort_name = "vipset"; 重点在 ON DUPLICATE KEY UPDATE sort_name = & ...
- Java 实现桥接(Bridge)模式
类图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamp3d21scDQ1Ng==/font/5a6L5L2T/fontsize/400/fill/I0 ...
- hdu 2059 龟兔赛跑 (dp)
/* 把起点和终点比作加油站,那总共同拥有n+2个加油站了, 每次都求出从第0个到第j个加油站(j<i)分别在加满油的情况下到第i个加油站的最短时间dp[i], 终于的dp[n+1]就是最优解了 ...
- Codeforces 755 F. PolandBall and Gifts 多重背包+贪心
F. PolandBall and Gifts It's Christmas time! PolandBall and his friends will be giving themselves ...
- Linq:int类型使用Contains方法
获取的是前台传过来的String类型的值,例如:1,123,44,59 具体代码如下 if (!string.IsNullOrEmpty(str)) { string[] strArr = str.S ...
- File to byte[] in Java
File to byte[] in Java - Stack Overflow https://stackoverflow.com/questions/858980/file-to-byte-in-j ...
- casperjs userAgent的一些问题
casperjs 的options内的userAgent若设置为非正常浏览器的字符串,可能导致form无法正确提交. 表现为,this.click()失效,或evaluate(function(){$ ...
- mac多线程下载神器
本文参考:https://blog.csdn.net/orangleliu/article/details/46834429 神器:axel 安装(已经安装homebrew前提下,没有请参考:http ...