E - 5

Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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 \leq {10}^{5},2 \leq n \leq {10}^{9} 

Output

For each test case, output an integer representing the answer.

Sample Input

2
3
10

Sample Output

2
0

思路:用 long long 直接暴力打个表可以看到21以内的结果, 5以前的没什么规律, 5以后的只要是素数答案是n-1, 不是素数答案都是0。n的取值范围十的九次方, 一般这种题都是水题。

代码:

#include<stdio.h>
#include<string.h>
#include<math.h>

#define N 110

void judge(int n)//判断是否是素数。
{
int i, k, f = 0;
k = (int)sqrt(n);

for(i = 2; i <= k; i++)
{
if(n % i == 0)
{
printf("%d\n", 0);
f = 1;
break;
}
}
if(f ==0)
printf("%d\n", n-1);

}

int main()
{
int t, n;

scanf("%d", &t);

while(t--)
{
scanf("%d", &n);

if(n == 2)
printf("1\n");
else if(n == 3 || n == 4)
printf("2\n");
else if( n == 5)
printf("4\n");
else
{
judge(n);
}
}

return 0;
}

HDU 5391 水题。的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  3. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  4. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  5. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  6. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  7. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  8. hdu 5038 水题 可是题意坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心  If not all ...

  9. hdu 5138(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5138 反着来. #include<iostream> #include<cstdi ...

随机推荐

  1. Tarjin + 缩点

    链接:https://www.nowcoder.com/acm/contest/81/C来源:牛客网 题目描述 给出一个 0 ≤ N ≤ 105 点数.0 ≤ M ≤ 105 边数的有向图, 输出一个 ...

  2. [洛谷P4012] [网络流24题] 深海机器人问题

    Description 深海资源考察探险队的潜艇将到达深海的海底进行科学考察. 潜艇内有多个深海机器人.潜艇到达深海海底后,深海机器人将离开潜艇向预定目标移动. 深海机器人在移动中还必须沿途采集海底生 ...

  3. python3小脚本-监控服务器性能并插入mysql数据库

    操作系统: centos版本 7.4 防火墙 关闭 selinux 关闭 python版本 3.6 mysql版本 5.7 #操作系统性能脚本 [root@localhost sql]# cat cp ...

  4. Add Scaffold

  5. 团队项目——Alpha发布1

    这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/GeographicInformationScience/homework 这个作业要求在哪里 https ...

  6. 数据结构 二维数组-->稀疏数组-->二维数组

    稀疏数组基本概念: 稀疏数组应用场景: 当一个数组大部分的元素为"0",或者为同一个值的数组时,可以使用稀疏数组来保存该数组 处理方法: 1>记录数组一共有几行几列,有多少不 ...

  7. Quartz.Net和队列应用demo

    using System; using System.Collections.Generic; using System.Threading; namespace ConsoleApplication ...

  8. [HNOI2008]GT考试(kmp,dp,矩阵乘法)

    [HNOI2008]GT考试(luogu) Description 求有多少个n位的数字串不包含m位的字符串(范围 n <= 1e9 n<=1e9, m <= 20m<=20) ...

  9. shiro盐值加密并验证

    在数据表中存的密码不应该是123456,而应该是123456加密之后的字符串,而且还要求这个加密算法是不可逆的,即由加密后的字符串不能反推回来原来的密码,如果能反推回来那这个加密是没有意义的.著名的加 ...

  10. (转)Gamma分布,Beta分布,Multinomial多项式分布,Dirichlet狄利克雷分布

    1. Gamma函数 首先我们可以看一下Gamma函数的定义: Gamma的重要性质包括下面几条: 1. 递推公式: 2. 对于正整数n, 有 因此可以说Gamma函数是阶乘的推广. 3.  4.  ...