判素数+找规律 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: ...
随机推荐
- Meteor部
一个关于 Meteor 主要事项就是如何轻松部署应用程序.当程序完成后,有一个简单的方法来和世界分享你的应用程序.所有需要做的就是在运行命令提示符窗口下面的代码. C:\Users\Administr ...
- leetcode ----Trie/stack专题
一:Implement Trie (Prefix Tree) 题目: Implement a trie with insert, search, and startsWith methods. Not ...
- 微信小程序之 Swiper(轮播图)
1.逻辑层 mine.js // pages/mine/mine.js Page({ /** * 页面的初始数据 */ data: { /*轮播图 配置*/ imgUrls: [ 'http://im ...
- Echarts 的样例
jsp页面: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8 ...
- map集合排序
默认情况下,HashMap.HashTable.TreeMap.LinkedHashMap的排列顺序比较: package com.per.sdg.demo; import java.util.Has ...
- hive计算网页停留时长
hive表结构例如以下: create table pv_user_info( session_id string, user_id string, url string, starttime big ...
- CSS中:overflow:hidden的作用
功能1.隐藏溢出 在IE6下,当子容器的宽高超出父容器时,父容器就会被撑开来. 要想解决这个问题,在父容器中除定义宽和高的值以外,还必须写overflow:hidden,这样就能把子容器的其它内容隐 ...
- asp.net编码解码的两篇文章
http://www.cnblogs.com/freshman0216/p/4165949.html http://www.cnblogs.com/freshman0216/p/4172655.htm ...
- Adding Security to an Existing Website
The procedure earlier in this article relies on using the Starter Site template as the basis for web ...
- website项目的reference问题
right click on website project--> property pages dll dependency Check the type column,if you have ...