HDU-5391 Zball in Tina Town
(n-1)!/n 就是如果n为素数,就等于n-1else为0。
求素数表:
Zball in Tina Town
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 833 Accepted Submission(s):
477
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.
, representing the number of cases.
The following T
lines, each line contains an integer n
, according to the description.
T≤105
,2≤n≤10
9
answer.
3
10
0
#include<iostream>
#include <cstdio>
#include<cstring>
using namespace std;
bool is_prime(int n)
{
for(int i=;i*i<=n;i++){
if(n%i==) return false;
}
return n!=;
}
int main (void)
{
int n,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(n==)
{
printf("2\n");
continue;
}
if(is_prime(n))
printf("%d\n",n-);
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 ...
- 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 ...
- 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 ...
- hdu5391 Zball in Tina Town(威尔逊定理)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Zball in Tina Town Time Limit: 3000/1500 ...
随机推荐
- 排序算法FIVE:插入排序InsertSort
/** *插入排序思路:O(n^2) * 最外层一个循环,从第二个数到最后一个,变量为i * 每个数存储在key变量中 * 变量j,是左边已经排好序的数组的上限 * 判断key与前面每一个数比较 1, ...
- php 导出excel表格
方式一:使用PHPExcel类库 //引入PHPExcel库文件(路径根据自己情况)include './phpexcel/Classes/PHPExcel.php'; $excel = new PH ...
- js电话号码正则校验--座机和手机号
1.最新的电话号码段: 移动:134(1349除外)135 136 137 138 139 147 150 151 152 157 158 159 182 183 184 187 188 联通: 13 ...
- Django初体验
为什么使用Django 快速开发 使用python 数据库ORM系统 大量内置应用 后台管理系统 admin 用户认证系统 auth 会话系统 sessions 安全性高 表单验证 SQL注入 跨站点 ...
- Python 列表实现字典的get功能
字典有一个很好用的方法,就是get,既可以预防KeyError异常,也可以为不存在的key设置一个默认的value 例如: v=d.get('k','default') 而列表没有一个类似的方法,如果 ...
- 折腾了一早上的C# WPF ListView+Grid 实现图片+文字 自动换行排列 类似Windows资源管理器效果
<ListBox Name="lstFileManager" Background ="Transparent" ItemsSource="{B ...
- 创建Mysql
CREATE DATABASE IF NOT EXISTS yiya DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
- hive--UDF、UDAF
1.UDF package com.example.hive.udf; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.had ...
- CMOS (1)–PMOS与NMOS
1,名称来源 p,n指示的是生成的沟道类型 2,驱动逻辑0与逻辑1 一般用NMOS驱动逻辑0,用PMOS驱动逻辑1.
- struts2 查 找总结
0:38 2013/5/25 查 找 * * |-_-查找全部 Action层的home方法中的查找方法创建时不需要带个查找对象的参数 service层不用组织条件 dao层一条查询所有的hql语句S ...