HDU 5391 水题。
Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
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 following T lines, each line contains an integer n, according to the description.
T \leq {10}^{5},2 \leq n \leq {10}^{9}
Output
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 水题。的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- hdu 5038 水题 可是题意坑
http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数 这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心 If not all ...
- hdu 5138(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5138 反着来. #include<iostream> #include<cstdi ...
随机推荐
- C# 根据年月日计算周次
//day:要判断的日期,WeekStart:1 周一为一周的开始, 2 周日为一周的开始 public static int WeekOfMonth(DateTime day, int WeekSt ...
- python 封装底层实现原理
事实上,python封装特性的实现纯属"投机取巧",之所以类对象无法直接调用私有方法和属性,是因为底层实现时,python偷偷改变了它们的名称. python在底层实现时,将它们的 ...
- kuangbin专题专题十一 网络流 POJ 3436 ACM Computer Factory
题目链接:https://vjudge.net/problem/POJ-3436 Sample input 1 3 4 15 0 0 0 0 1 0 10 0 0 0 0 1 1 30 0 1 2 1 ...
- (转) exp1-2://一次有趣的XSS漏洞挖掘分析(2)
第一次和一套程序做了这么多次的斗争.今天基友又给我来信说,没得玩了.了解了下情况,是他拿着0day到处插,被人家发现了.还出了个公告,说所有***必须安装补丁.呵呵,性福总是走的这么突然.这乐子一 ...
- windows下生成文件目录树
1.命令提示: tree /? 2.显示当前目录下的目录树(不显示文件) tree 3.递归显示目录结构(显示文件,常用于项目说明) tree /F 4.将显示的内容重定向到txt tree > ...
- 【WPF学习】第四章 加载和编译XAML
前面已经介绍过,尽管XAML和WPF这两种技术具有相互补充的作用,但他们也是相互独立的.因此,完全可以创建不使用XAML和WPF应用程序. 总之,可使用三种不同的编码方式来创建WPF应用程序: 只使用 ...
- geojson转esriJson
因为一些特殊需求,需要将geojson转为shp数据,网上有一些转换网站,但是存在一些问题,例如中文乱码.文件大小限制等等,折腾了一下,还是觉得用arcgis转比较好,因此先将geojson转为esr ...
- Leetcode 题目整理 climbing stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- 关于SpringMVC未找到类[No qualifying bean of type [...]is defined]问题
首先,不要慌,出现这个问题肯定是某一个配置注解没写上.. 无非就几个地方: 1.控制层是否添加@Controller or 需要pring管理的类是否添加@Component 2.DAO层是否添加@R ...
- 【C/C++】概念: VC虚函数布局引发的问题
在网上看到一个非常热的帖子,里面是这样的一个问题: 在打印的时候发现pFun的地址和 &(Base::f)的地址竟然不一样太奇怪了?经过一番深入研究,终于把这个问题弄明白了.下面就来一步步进行 ...