hdu 5363Key Set
The first line contains an integer n (1≤n≤109), the number of integers in the set.
1
2
3
4
一看数据就是快速幂,一开始用int错了,索性全改为long long
#include <iostream>
#include <cmath>
using namespace std; long long f(long long a)
{
long long temp=;
long long ans=;
while (a)
{
if (a%!=)
ans*=temp; ans=ans%;
temp=temp*temp;
temp=temp%;
a/=;
}
return ans;
}
int main()
{
long long n,m;
cin>>n;
while (n--)
{
cin>>m;
cout <<f(m-)-<<endl;
}
return ;
}
hdu 5363Key Set的更多相关文章
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 3791二叉搜索树解题(解题报告)
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...
- hdu 4329
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟 a. p(r)= R'/i rel(r)=(1||0) R ...
随机推荐
- gcc-gdb
1.使用gdb ,习惯了cgdb ,加上了vim. 调试发现,使用了stl,不知如何查看使用的vector,stack等中的值,来吧.gdb-std-views.下载 1)下载好之后,mv stl-v ...
- 钢管下料问题(钢管用量最少)Lingo求解
大家好,我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang !钢管下料问题1(钢管用量最少) 题目: 钢管原料 每根19m 客户需求 4m 50根 ...
- 被误解的 MVC 和被神化的 MVVM
被误解的 MVC 和被神化的 MVVM 被误解的 MVC MVC 的历史 MVC,全称是 Model View Controller,是模型 (model)-视图 (view)-控制器 (contro ...
- Effective Java实作Comparator - 就是爱Java
如果集合或数组内的对象,有1个以上不同的排序逻辑时,那该如何处理呢?尤其是当已经实现了Comparable,又不能变动原本的逻辑时,Mix会采用Comparator来处理. 阅读全文>>
- 基本套接字总结(@function)
最近学习了下UNIX下的网络编程.为了以后查询方便,总结在这里. 首先套接字的地址定义: IPv4地址和IPv6地址定义见<netinet/in.h>头文件定义.为了能够顺利转换不同的套接 ...
- BZOJ 2527 Meteors
http://www.lydsy.com/JudgeOnline/problem.php?id=2527 思路:整体二分 #include<cstdio> #include<cmat ...
- Codeforces 509C Sums of Digits
http://codeforces.com/contest/509/problem/C 题目大意: 给出一个序列,代表原序列对应位置数的每一位的数字之和,原序列单调递增,问原序列的最后一个数最小的方 ...
- 利用php unpack读取c struct的二进制数据,struct内存对齐引起的一些问题
c语言代码 #include <stdio.h> struct test{ int a; unsigned char b; int c; }; int main(){ FILE *fp; ...
- 玩转指针(Playing with Pointers)
Question: What is a Pointer? What are its limitations? What are its benefits? How do we use it? What ...
- 代理delegate、NSNotification、KVO在开发中的抉择
在开发ios应用的时候,我们会经常遇到一个常见的问题:在不过分耦合的前提下,controllers间怎么进行通信.在IOS应用不断的出现三种模式来实现这种通信: 1.委托delegation: 2.通 ...