(hdu)5391 Zball in Tina Town
题目链接: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的更多相关文章
- C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...
- 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 ...
- hdoj 5391 Zball in Tina Town
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5391 相关数论结论: 威尔逊定理——当且仅当p为素数时:( p -1 )! ≡ p-1 ( mod p ...
- 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 ...
- hdu5391 Zball in Tina Town(威尔逊定理)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Zball in Tina Town Time Limit: 3000/1500 ...
- 判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town
题目传送门 /* 题意: 求(n-1)! mod n 数论:没啥意思,打个表能发现规律,但坑点是4时要特判! */ /***************************************** ...
随机推荐
- Storm系列(十五)架构分析之Executor-Spout
Spout实现mk-threads接口用于创建与Executor对应的消息循环主函数. defmulti mk-threads executor-selector Mk-threads函数的主消息循环 ...
- https://hub.docker.com/
- IOS 10适配https 包含对于一些http的一些兼容配置
iOS10 从2017年1月1日起苹果提出所有新提交的App默认不允许使用NSAllowsArbitraryLoads来绕过ATS的限制,也就是说强制我们用HTTPS,如果不这样的话提交App可能会被 ...
- 【开发工具 - Git】之Git使用案例
本帖主要介绍一下Git在实际项目开发中的使用流程,包括克隆.暂存.提交.推送.拉取.分支.冲突解决等,暂时还不包括回退. 1.首先需要安装Git,下一步下一步就行,这里就不说了.值得一提的是,如果Gi ...
- javascript中bind,apply,call的相同和不同之处
javasctipt中bind,apply,call的相同点是: 1,都是用来改变this的指向; 2,都可以通过后续参数进行传参; 3,第一个参数都是指定this要指向的对象; 不同点: 1,调用方 ...
- js 数组详解(javascript array)
Array Array 对象用于在单个的变量中存储多个值. 构造函数: 1) new Array(); 2) new Array(size); 3) new Array(element0, ...
- 验证(Verification)与确认(Validation)的差别
验证(Verification)与确认(Validation)的差别 说法一: (2)“验证(Verification)”的涵义 通过提供客观证据对规定要求已得到满足的认定. (2)“确认(Valid ...
- WPF WebBrowser
XAML <Window x:Class="WpfApplication5.Window1" xmlns="http://schemas.microso ...
- cocos2dx 3.1创建工 mac
1.下载cocos2dx 3.1版本号 2.打开终端,cd 进入 cocos2d-x-3.1.1/tools/cocos2d-console/bin 3.cocos new game -p com.t ...
- Ajax之旅(一)--什么是Ajax
本来在学习DRP,但是无意中发现所附资料中有一些參考书籍,当中就有一个关于Ajax的,看了看,挺好的,于是决定暂停一下DRP,再次学习一下Ajax.记得第一遍学习Ajax的时候认为真的是一团雾水,看了 ...