Zball in Tina Town

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)

Problem Description
Tina Town is a friendly place. People there care about 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.

 
Input
The first line of input contains an integer T, representing the number of cases.

The following T lines, each line contains an integer n, according to the description.
T≤105,2≤n≤109

 
Output
For each test case, output an integer representing the answer.
 
Sample Input
2
3
10
 
Sample Output
2
0
 
Source
 思路:当数为素数时,威尔逊;
    当数为非素数,4输出2;
          别的输出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 威尔逊定理 数学的更多相关文章

  1. HDU 5391 Zball in Tina Town【威尔逊定理】

    <题目链接> Zball in Tina Town Problem Description Tina Town is a friendly place. People there care ...

  2. hdu5391 Zball in Tina Town(威尔逊定理)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Zball in Tina Town Time Limit: 3000/1500 ...

  3. hdu 5391 Zball in Tina Town(打表找规律)

    问题描述 Tina Town 是一个善良友好的地方,这里的每一个人都互相关心. Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大11倍.在第二天的时候, ...

  4. HDU 5391 Zball in Tina Town (打表,水)

    题意: Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大1倍.在第二天的时候,它会变大2倍.在第n天的时候,它会变大n倍.zball原来的体积是1.Ti ...

  5. C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...

  6. (hdu)5391 Zball in Tina Town

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5391 Problem Description Tina Town is a friendl ...

  7. hdoj 5391 Zball in Tina Town

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5391 相关数论结论: 威尔逊定理——当且仅当p为素数时:( p -1 )! ≡ p-1 ( mod p ...

  8. HDU 5391Z ball in Tina Town 数论

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5391 bc:  http://bestcoder.hdu.edu.cn/contests/c ...

  9. 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 ...

随机推荐

  1. org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x160fd6f04410017 after 0ms

    dubbo报错: org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x160fd6f04410017 after ...

  2. vertical-align 使用参考

    在实现文字与图片垂直对齐的时候,发现了vertical-align的值也是很纷繁复杂,博客讲解各种不懂,最终还是找了CSS权威指南-中文第三版,看了前6章,终于弄明白了,如果你也有不懂的地方,请去看书 ...

  3. Less-Mixins分离规则集

    //Mixins --立即执行函数 .test{/* */} #test{/* */} --指定执行函数 .test(){/* */} #test(){/* */} --调用: .test; or . ...

  4. Oracle中sql相关的命令

    1.创建用户 SQL> -- 例如创建一个用户名为xiaoming,密码为a123的用户 SQL> create user xiaomingidentified by a123; 用户已创 ...

  5. SEO优化 给a标签添加rel="nofollow"

    为什么要使用nofollow标签? 我们使用nofollow标签的目的是很明确的,就是减少蜘蛛对页面上垃圾链接的爬行和传递权重,或者减少蜘蛛对页面上“无用”链接的爬行和传递链接权重. 这里所说的无用是 ...

  6. django博客项目2.建立 Django 博客应用

    建立博客应用 我们已经建立了 Django 博客的项目工程,并且成功地运行了它.不过到目前为止这一切都还只是 Django 为我们创建的项目初始内容,Django 不可能为我们初始化生成博客代码,这些 ...

  7. django的序列化问题

    Django中的序列化主要应用在将数据库中检索的数据返回给客户端用户,特别的Ajax请求一般返回的为Json格式 1.serializers from django.core import seria ...

  8. Pimpl Idiom /handle body idiom

    在读<Effective C++>和项目源代码时,看到pImpl Idiom.它可以用来降低文件间的编译依赖关系,通过把一个Class分成两个Class,一个只提供接口,另一个负责实现该接 ...

  9. laravel相关插件

    1. Laravel-4-Generators Rapidly speed up your Laravel workflow with generators  https://packagist.or ...

  10. HackerRank - common-child【DP】

    HackerRank - common-child[DP] 题意 给出两串长度相等的字符串,找出他们的最长公共子序列e 思路 字符串版的LCS AC代码 #include <iostream&g ...