HDU-5391 Zball in Tina Town
(n-1)!/n 就是如果n为素数,就等于n-1else为0。
求素数表:
Zball in Tina Town
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 833 Accepted Submission(s):
477
each other.
Tina has a ball called zball. Zball is magic. It grows larger
every day. On the first day, it becomes 1
time as large as its original size. On the second day,it will become 2
times as large as the size on the first day. On the n-th day,it will become
n
times as large as the size on the (n-1)-th day. Tina want to know its size on
the (n-1)-th day modulo n.
, representing the number of cases.
The following T
lines, each line contains an integer n
, according to the description.
T≤105
,2≤n≤10
9
answer.
3
10
0
#include<iostream>
#include <cstdio>
#include<cstring>
using namespace std;
bool is_prime(int n)
{
for(int i=;i*i<=n;i++){
if(n%i==) return false;
}
return n!=;
}
int main (void)
{
int n,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(n==)
{
printf("2\n");
continue;
}
if(is_prime(n))
printf("%d\n",n-);
else
printf("0\n"); }
return ;
}
HDU-5391 Zball in Tina Town的更多相关文章
- HDU 5391 Zball in Tina Town【威尔逊定理】
<题目链接> Zball in Tina Town Problem Description Tina Town is a friendly place. People there care ...
- hdu 5391 Zball in Tina Town 威尔逊定理 数学
Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Oth ...
- hdu 5391 Zball in Tina Town(打表找规律)
问题描述 Tina Town 是一个善良友好的地方,这里的每一个人都互相关心. Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大11倍.在第二天的时候, ...
- HDU 5391 Zball in Tina Town (打表,水)
题意: Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大1倍.在第二天的时候,它会变大2倍.在第n天的时候,它会变大n倍.zball原来的体积是1.Ti ...
- C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...
- (hdu)5391 Zball in Tina Town
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5391 Problem Description Tina Town is a friendl ...
- hdoj 5391 Zball in Tina Town
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5391 相关数论结论: 威尔逊定理——当且仅当p为素数时:( p -1 )! ≡ p-1 ( mod p ...
- HDU 5391Z ball in Tina Town 数论
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5391 bc: http://bestcoder.hdu.edu.cn/contests/c ...
- hdu5391 Zball in Tina Town(威尔逊定理)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Zball in Tina Town Time Limit: 3000/1500 ...
随机推荐
- Linux中的时间和时间管理
Coordinated Universal Time(UTC):协调世界时,又称为世界标准时间,也就是大家所熟知的格林威治标准时间(Greenwich Mean Time,GMT).比如,中国内地的时 ...
- width() innerwidth() outerwidth() css('width')
不多说,用一图足以说明 首先先解释下普通元素和非普通元素, 非普通元素是指window,document这些 元素对象, 普通元素是指除window,document之外的元素,如:div 对于普通的 ...
- Struts2 Annotation 默认返回Tiles2布局
Struts2的annotation方式很简约,特别实在遵从默认约定的时候就根本不需要配什么struts.xml.网上关于Annotation约定大于配置的教程也很多,其中也不乏将xml版struts ...
- svg学习笔记(一)
SVG——可扩展适量图形,基于XML PC端:IE9+ wap端:表现良好,适合使用 基础图形: line(线段) <line x1="25" y1="150 ...
- 不相交集合ADT
不相交集合数据结构保持一组不相交的动态集合S={S1,S2,...,SK},每个集合通过一个代表来识别,代表即集合中的某个成员. 如果x表示一个对象,不相交集合支持以下操作: MAKE-SET(x): ...
- Python prettytable的使用方法
Python prettytable的使用方法 prettytable可以整齐地输出一个表格信息: +-----------+------+------------+----------------- ...
- Java学习--final与static
final是java的关键字,它所表示的是“这部分是无法修改的”. 编译期常量,它在类加载的过程就已经完成了初始化,所以当类加载完成后是不可更改的,编译期可以将它代入到任何用到它的计算式中,也就是说可 ...
- 【gitlab】版本管理工具
- keil 51警告编译优化
KeilC51中将工程中没有调用的函数不进行编译的方法 把Target Options中的Device页中选上"Use Extended Linker(LX51)instead of BL5 ...
- Burp Suite Walkthrough(中文版)
Burp Suite是Web应用程序测试的最佳工具之一,其多种功能可以帮我们执行各种任务.请求的拦截和修改,扫描web应用程序漏洞,以暴力破解登陆表单,执行会话令牌等多种的随机性检查.本文将做一个Bu ...