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. springboot集成restdocs输出接口文档

    1.pom文件新增restdocs <dependency>    <groupId>org.springframework.restdocs</groupId> ...

  2. 关于爬虫的日常复习(13)—— 爬虫requests的初级高级的基本用法

  3. OAuth2.0的那点荒唐小秘密 -几个简单概念和原理

    OAuth2.0这个名词你是否在项目中时常听到呢?是否觉得好像懂,又好像不太懂呢? 最近一直想写篇关于OAuth2.0的东西,记录下我的学习与感悟,然各种理由的拖延,直到今日才静下心来写下这篇博客.当 ...

  4. Spring加载早期获取BasePackage

    public class GetBasePackage { private Class<? extends Annotation> annotation; public GetBasePa ...

  5. typescript 为什么使用 let呢

    为什么是使用let呢 因为已经厌烦了 int var 呵呵

  6. GP工作室—Alpha版本发布1

    目录 GP工作室-Alpha版本发布1 一.简介 1.1作业要求 1.2团队成员 二.软件下载安装说明 五.项目总结 @(Gold Point团队の项目计划) GP工作室-Alpha版本发布1 一.简 ...

  7. DOM中的位置和大小(总结)

    [window]window对象 一.position位置 screenLeft/screenTop (适用于火狐和谷歌) screenX/screenY (适用于IE) 二.size大小 inner ...

  8. PlayCanvas PBR材质shader代码分析(vertex shader)

    顶点shader主要对顶点坐标变换,将顶点坐标从local->world->view->clip 空间变换 local空间:模型物体坐标系 world空间:世界空间坐标系 view空 ...

  9. 1.Vue初始及相关Vue核心组件

    1.Vue官方文档 官网文档:https://cn.vuejs.org/v2/guide/ 2.Vue-cli官方文档(脚手架) 官网文档:https://cli.vuejs.org/zh/guide ...

  10. zabbix3.4源码安装步骤

    zabbix3.4源码安装步骤1.安装环境: 安装机器:22.224.9.227 以下简称监控机: 操作系统信息:内核版本: Linux version 2.6.18-194.1.AXS3 (pack ...