题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5391

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 time as large as its original size. On the second day,it will become 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-)-th day. Tina want to know its size on the (n-)-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≤,≤n≤ Output
For each test case, output an integer representing the answer. Sample Input Sample Output

题意:求(n-1)!对n取模

方法:如果是素数就是n-1,如果不是素数(除了4)都是0,4的结果是2

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
#define N 10010
#define ll long long
#define met(a,b) memset(a,b,sizeof(a));
vector<vector<int> >Q;
int n;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int f=;
scanf("%d",&n); if(n==)///特例
{
printf("2\n");
continue;
}
int k=(int)sqrt(n);
for(int i=; i<=k; i++)
{
if(n%i==)
{
f=;
break;
} } if(f)
printf("0\n");
else
printf("%d\n",n-);
}
return ;
}

(hdu)5391 Zball in Tina Town的更多相关文章

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

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

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

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

  3. hdu 5391 Zball in Tina Town 威尔逊定理 数学

    Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Oth ...

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

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

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

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

  6. hdoj 5391 Zball in Tina Town

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

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

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

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

  9. 判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town

    题目传送门 /* 题意: 求(n-1)! mod n 数论:没啥意思,打个表能发现规律,但坑点是4时要特判! */ /***************************************** ...

随机推荐

  1. 100个常用的linux命令

    1,echo “aa” > test.txt 和 echo “bb” >> test.txt //>将原文件清空,并且内容写入到文件中,>>将内容放到文件的尾部 2 ...

  2. 单位内部DNS架设及域名解析服务

    越来越多的企业将企业内部局域网通过光缆.交换机等高速互连设备连接起来,形成较大规模的中型网络,网络上的主机和用户也随之日渐增多.作为 Internet的缩影,企业内部网上的各类服务器(如WWW服务器. ...

  3. cocos2d-x 2.0 拖尾效果分析

    转自:http://game.dapps.net/gamedev/game-engine/7281.html 在Cocos2d-x中,拖尾效果有一个专门的类CCMotionStreak来实现.下面我们 ...

  4. SQL Server数据库PIVOT函数的使用详解(一)

    http://database.51cto.com/art/201108/285250.htm SQL Server数据库中,PIVOT在帮助中这样描述滴:可以使用 PIVOT 和UNPIVOT 关系 ...

  5. jfinal获取当前访问路径和端口号

    public void generateSingleLicense() throws Exception { System.out.println(getRequest().getRequestURL ...

  6. int 0x13中断的參数传递

    int 0x13中断向量所指向的中断服务程序实质上就是磁盘服务程序. 用途:将指定扇区的代码载入到内存的指定位置. 因此,在使用int 0x13中断时要将參数传递给服务程序: 比如:将指定扇区和载入的 ...

  7. Android(java)学习笔记141:SQLiteDatabase的query方法参数分析

    public Cursor query (boolean distinct, String table, String[] columns, String selection, String[] se ...

  8. hysdk代码解析

    navigator 1. navigator.userAgent 浏览器的用户代理字符串 2. navigator.platform 浏览器所在的系统平台 window 1. window.devic ...

  9. css图片垂直居中

    css图片垂直居中一.style代码 .case-pic{ height: 125px; position: relative; text-align: center } .case-pic span ...

  10. 基于u盘安装centos6.0

    本人在dell笔记本上尝试安装centos6.0,与win7形成双系统,安装过程如下: 1.使用ultraliso制作u盘启动盘,启动盘以centos6.0的映像文件为源头制作: 2.制作完成后,删除 ...