HDU6027 Easy Summation 2017-05-07 19:02 23人阅读 评论(0) 收藏
Easy Summation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072
K (Java/Others)
Total Submission(s): 27 Accepted Submission(s): 16
Given two integers n and k.
Let f(i)=ik,
please evaluate the sum f(1)+f(2)+...+f(n).
The problem is simple as it looks, apart from the value of n in
this question is quite large.
Can you figure the answer out? Since the answer may be too large, please output the answer modulo 109+7.
denoting the number of test cases.
Each of the following T lines
contains two integers n(1≤n≤10000) and k(0≤k≤5).
3 2 5 4 2 4 1
33 30 10
题意:给出一个n和k,求从1^k到n^k的和
解题思路:暴力,注意取模即可
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <map>
- #include <cmath>
- #include <set>
- #include <stack>
- #include <queue>
- #include <vector>
- #include <bitset>
- #include <functional>
- using namespace std;
- #define LL long long
- const int INF=0x3f3f3f3f;
- const int mod=1e9+7;
- int n,m;
- int main()
- {
- int T;
- scanf("%d",&T);
- while(T--)
- {
- scanf("%d%d",&m,&n);
- LL ans=0;
- for(int i=1; i<=m; i++)
- {
- LL x=1;
- for(int j=1; j<=n; j++)
- {
- x*=i;
- x%=mod;
- }
- ans+=x;
- ans%=mod;
- }
- printf("%lld\n",ans);
- }
- return 0;
- }
HDU6027 Easy Summation 2017-05-07 19:02 23人阅读 评论(0) 收藏的更多相关文章
- Python获取当前时间 分类: python 2014-11-08 19:02 132人阅读 评论(0) 收藏
Python有专门的time模块可以供调用. <span style="font-size:14px;">import time print time.time()&l ...
- HDU6029 Happy Necklace 2017-05-07 19:11 45人阅读 评论(0) 收藏
Happy Necklace Time Limit: ...
- 滑雪 分类: POJ 2015-07-23 19:48 9人阅读 评论(0) 收藏
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 83276 Accepted: 31159 Description Mich ...
- POJ3320 Jessica's Reading Problem 2017-05-25 19:55 38人阅读 评论(0) 收藏
Jessica's Reading Problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12346 Accep ...
- HDU6026 Deleting Edges 2017-05-07 19:30 38人阅读 评论(0) 收藏
Deleting Edges Time ...
- HDU6029 Graph Theory 2017-05-07 19:04 40人阅读 评论(0) 收藏
Graph Theory Time Limit: 2000/1000 M ...
- POJ1269 Intersecting Lines 2017-04-16 19:43 50人阅读 评论(0) 收藏
Intersecting Lines Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 15478 Accepted: 67 ...
- Avro基础 分类: C_OHTERS 2015-02-14 19:56 310人阅读 评论(0) 收藏
一.Avro的基本功能 1.定义了数据模式文件的语法,一般使用json文件.以及一些数据基本类型与复杂类型. 2.定义了数据序列化到文件后的数据格式,此格式可供各种语言进行读取. 3.为部分语言定义了 ...
- Hadoop常见异常及其解决方案 分类: A1_HADOOP 2014-07-09 15:02 4187人阅读 评论(0) 收藏
1.Shell$ExitCodeException 现象:运行hadoop job时出现如下异常: 14/07/09 14:42:50 INFO mapreduce.Job: Task Id : at ...
随机推荐
- 关于Git的礼节
(这里的内容本来是<怎样尊重一个程序员>的一小节,但由于Git的使用引起了很普遍的不尊重程序员的现象,现在特别将这一节提出来单独成文.) Git是现在最流行的代码版本控制工具.用外行话说, ...
- javascript获取事件源对象和产生事件的对象
事件源对象是指event对象,其封装了与事件相关的详细信息,比如按键状态. 获取事件源对象的方法 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1. ...
- Ansible develop module
def cnf(action,configs,path): message = "Modify %s\n" %path changed = False if action == & ...
- The Hard Thing About Hard Things
1.大多数的管理书籍都是告诉你如何做正确的事,不把事情搞砸.而好书是告诉你,当事情已经搞砸时,你该怎么办. 2.这是个个真实的世界,他们偷走了你的梦想,可你却不知道是谁偷的.
- GridView中如何实现自定义时间货币等字符串格式?
方法一: <asp :GridView ID="GridView1" runat="server"> <columns> <asp ...
- 条款2:尽量以const, enum, inline替换#define
原因: 1. 追踪困难,由于在编译期已经替换,在记号表中没有. 2. 由于编译期多处替换,可能导致目标代码体积稍大. 3. define没有作用域,如在类中定义一个常量不行. 做法: 可以用const ...
- python内置函数之attr【反射】
#Auther Bob#--*--conding:utf-8 --*-- #我们来循序渐进的学习反射 import s1 #阶段1# def run():# url = input("请输入 ...
- jquery源码学习-初始(1)
最近几天一直在研究jquery源码,由于水平太低看得昏头转向.本来理解的也不是很深刻,下面就用自己的想法来说下jquery是如何定义构造函数初始化的.如果有什么不对的地方,希望个位高手指出. 首先要了 ...
- 把Linq查询返回的var类型的数据 转换为DataTable EF连接查询
问题:我要获得一个角色下对应的所有用户,需要两表连接查询,虽然返回的只有用户数据,但是我想到若是返回的不只是用户数据,而还要加上角色信息,那么我返回什么类型呢,返回var吗,这样不行. 于是我网上找找 ...
- 绘制3D的js库
有哪些值得推荐的绘制3D的js库? 4 个回答 默认排序 草皮子 HTML5/GAME 4 人赞同了该回答 只用过three.js,所以推荐这个.不清楚你打算用来做什么,总的来说,得看你的运 ...