hdu 5391 Zball in Tina Town 威尔逊定理 数学
Zball in Tina Town
Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
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.
The following T lines, each line contains an integer n, according to the description.
T≤105,2≤n≤109
3
10
0
#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define esp 0.00000000001
const int N=1e3+,M=1e6+,inf=1e9+,mod=;
int prime(int n)
{
if(n<=)
return ;
if(n==)
return ;
if(n%==)
return ;
int k, upperBound=n/;
for(k=; k<=upperBound; k+=)
{
upperBound=n/k;
if(n%k==)
return ;
}
return ;
}
int main()
{
int x,y,z,i,t;
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&x);
if(x==)
printf("2\n");
else if(prime(x))
printf("%d\n",x-);
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 ... 
- hdu5391 Zball in Tina Town(威尔逊定理)
		转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Zball in Tina Town Time Limit: 3000/1500 ... 
- 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 ... 
- HDU-5391 Zball in Tina Town
		(n-1)!/n 就是如果n为素数,就等于n-1else为0. 求素数表: Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others) Memo ... 
随机推荐
- nodemailer发送邮件各个服务器接口
			来自:https://github.com/nodemailer/nodemailer-wellknown/blob/master/services.json#L125 { "1und1 ... 
- Python菜鸟之路:Django 缓存
			Django中提供了6种缓存方式: 开发调试 内存 文件 数据库 Memcache缓存(python-memcached模块) Memcache缓存(pylibmc模块) 1. 开发调试 # 此为开始 ... 
- 流畅的python 对象引用 可变性和垃圾回收
			对象引用.可变性和垃圾回收 变量不是盒子 人们经常使用“变量是盒子”这样的比喻,但是这有碍于理解面向对象语言中的引用式变量.Python 变量类似于 Java 中的引用式变量,因此最好把它们理解为附加 ... 
- (数据库之pymysql)
			权限管理http://www.cnblogs.com/linhaifeng/articles/7267587.html#_label6一.pymysql模块(安装与查询) 1.安装pymysql(py ... 
- 48dp rhythm
- django 通过orm操作数据库
			Django Model 每一个Django Model都继承自django.db.models.Model 在Model当中每一个属性attribute都代表一个database field 通过D ... 
- Linux主从同步监测和利用sendMail来发邮件
			首先介绍下sendMail About SendEmailSendEmail is a lightweight, command line SMTP email client. If you have ... 
- NUnit TestFixtureSetup 和 TestFixtureTearDown
			TestFixtureSetup 和 TestFixtureTearDown 在所有测试开始前(TestFixtureSetup)或结束后(TestFixtureTearDown)运行一 次.记住他只 ... 
- nginx限制连接
			limit_conn_zone $binary_remote_addr zone=addr:10m; locaton /download { limit_rate_after 128k; #是对每个连 ... 
- beego——构造查询
			QueryBuilder提供了一个简单.流畅的SQL查询构造器.在不影响代码可读性的前提下用来快速的建立SQL语句. QueryBuilder在功能上与ORM重合,但是个由利弊,ORM更适合用于简单的 ... 
