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. 数字任意组合 - gcd

    链接:https://www.nowcoder.com/acm/contest/160/A来源:牛客网 题目描述有一个计数器,计数器的初始值为0,每次操作你可以把计数器的值加上a1,a2,...,an ...

  2. cf - 01串的问题

    One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got ...

  3. 线段相交的异或值 (线段树 or 优先队列)

    VVQ 最近迷上了线段这种东西 现在他手上有 n 条线段,他希望在其中找到两条有公共点的线段,使得他们的异或值最大. 定义线段的异或值为它们并的长度减他们交的长度 输入描述: 第一行包括一个正整数 n ...

  4. vue学习笔记1:el 与 data

    一.vue介绍 vue是目前三大主流框架之一(React.Angular.Vue) vue特点: 易用 灵活 高效 vue官网:官网链接 二,知识点 vue实例选项: el 注:不能 让el直接管理h ...

  5. c语言-输出圆形

    #include<stdio.h> #define high 100//定义界面大小 #define wide 100 void Circle(int ridus) //确定坐标 {int ...

  6. Dubbo如何支持本地调用?injvm方式解析

    Dubbo是一个远程调用的框架,对于一个服务提供者,暴露了一个接口供外部消费者调用,那么对于提供者自己是否可以调用这个接口,需要什么特殊处理吗? 这篇文章就分享下Dubbo关于本地调用的实现机制,以及 ...

  7. kali linux下的部分命令

    查看发行版本 cat    /etc/issue cat   /etc/*-release 查看内核版本 uname  -a 显示机器的处理器架构 arch uname -m 清屏 clear 命令行 ...

  8. REST 风格架构

       ------------------------------ 时间不多了, 抓紧做一些有意义的事情 REST 风格架构   1. 他是面向资源进行开发的   2. 他是基于HTTP 协议进行开发 ...

  9. Docker的save和export命令的区别

    我最近在玩Docker,一种应用程序容器和Linux的虚拟技术.它太酷了,创建Docker镜像和容器只需要几分钟.所有的工作都是开箱即用的. 在结束我一天的工作之前,我希望能保存下我的工作.但我在Do ...

  10. OS课程 ucore_lab2实验报告

    练习零:填写已有实验    本实验依赖实验1.请把你做的实验1的代码填入本实验中代码中有"LAB1"的注释相应部分.提示:可采用diff和patch工具进行半自动的合并(merge ...