题目链接: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. 【Java基础】Java中的代码块

    什么是代码块 在Java中,用{}括起来的代码称之为代码块. 代码块分类 局部代码块:在局部变量位置且用{}括起来的代码,用于限制局部变量的生命周期. 构造代码块:在类中的成员变量位置并用{}括起来的 ...

  2. HW2.4

    import java.util.Scanner; public class Solution { public static void main(String[] args) { final dou ...

  3. Kinect for Windows SDK开发入门(一):开发环境配置

    [译]Kinect for Windows SDK开发入门(一):开发环境配置 前几天无意中看到微软发布了Kinect for windows sensor,进去看了一下Kinect应用的例子,发现K ...

  4. Ubuntu 12.04 分区方案(仅供参考)

    Ubuntu 12.04 分区方案(仅供参考)   总空间大小:50G 目录 建议大小 实际大小 格式 描述 / 10G~20G 10G ext4 根目录 swap <2048M 1G swap ...

  5. 杂谈:你选择coco 还是unity3d?

    当一个人喜欢的时候,那么这样的兴趣是非常难改变的.你是否会改变自己想法?眼下而言,如今adobe 对flash开发处于维护的状态.为什么?是由于前期错误政策流失非常多人才,这一点也非常难避免.当今年湖 ...

  6. 【转】C++中多重继承的二义性及解决办法

    转自:http://www.cnblogs.com/lintong/archive/2012/07/28/2613002.html 1. 什么是多重继承的二义性 class A{ public: vo ...

  7. (step6.3.4)hdu 1151(Air Raid——最小路径覆盖)

    题意:     一个镇里所有的路都是单向路且不会组成回路. 派一些伞兵去那个镇里,要到达所有的路口,有一些或者没有伞兵可以不去那些路口,只要其他人能完成这个任务.每个在一个路口着陆了的伞兵可以沿着街去 ...

  8. Web挖掘技术

      一.数据挖掘 数据挖掘是运用计算机及信息技术,从大量的.不全然的数据集中获取隐含在当中的实用知识的高级过程.Web 数据挖掘是从数据挖掘发展而来,是数据挖掘技术在Web 技术中的应用.Web 数据 ...

  9. 什么是Cocos2d-x

    以下是官方对Cocos2d-x的说明."       Cocos2d-x is an open-source mobile 2D game framework, released under ...

  10. 【转】Cocos2d-x 2.x CCSprite 灰白图的生成(利用shader设置)——2013-08-27 21

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=325 游戏中人物死掉后要把人物头 ...