Easy Summation

                                                            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072
K (Java/Others)

                                                                                             Total Submission(s): 27    Accepted Submission(s): 16

Problem Description
You are encountered with a traditional problem concerning the sums of powers.

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.
 
Input
The first line of the input contains an integer T(1≤T≤20),
denoting the number of test cases.

Each of the following T lines
contains two integers n(1≤n≤10000) and k(0≤k≤5).
 
Output
For each test case, print a single line containing an integer modulo 109+7.
 
Sample Input
3
2 5
4 2
4 1
 
Sample Output
33
30
10
 
Source




——————————————————————————————————

题意:给出一个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) 收藏的更多相关文章

  1. Python获取当前时间 分类: python 2014-11-08 19:02 132人阅读 评论(0) 收藏

    Python有专门的time模块可以供调用. <span style="font-size:14px;">import time print time.time()&l ...

  2. HDU6029 Happy Necklace 2017-05-07 19:11 45人阅读 评论(0) 收藏

    Happy Necklace                                                                           Time Limit: ...

  3. 滑雪 分类: POJ 2015-07-23 19:48 9人阅读 评论(0) 收藏

    滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 83276 Accepted: 31159 Description Mich ...

  4. 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 ...

  5. HDU6026 Deleting Edges 2017-05-07 19:30 38人阅读 评论(0) 收藏

    Deleting Edges                                                                                  Time ...

  6. HDU6029 Graph Theory 2017-05-07 19:04 40人阅读 评论(0) 收藏

    Graph Theory                                                                 Time Limit: 2000/1000 M ...

  7. POJ1269 Intersecting Lines 2017-04-16 19:43 50人阅读 评论(0) 收藏

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 15478   Accepted: 67 ...

  8. Avro基础 分类: C_OHTERS 2015-02-14 19:56 310人阅读 评论(0) 收藏

    一.Avro的基本功能 1.定义了数据模式文件的语法,一般使用json文件.以及一些数据基本类型与复杂类型. 2.定义了数据序列化到文件后的数据格式,此格式可供各种语言进行读取. 3.为部分语言定义了 ...

  9. 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 ...

随机推荐

  1. 手动安装yii2.0-redis扩展

    1.点击下载:yii2.0-redis扩展 2.把下载的扩展文件放到vendor/yiisoft/下,命名为yii2-redis 3.修改vender/yiisoft/下的extensions.php ...

  2. IntelliJ IDEA project module

    在IDEA 创建一个project,目录结构是这样的:在project下创建一个module之后目录结构是这样的: 简单的概括如下: IntelliJ系中的 Project  相当于Eclipse系中 ...

  3. eclipise快捷键,留给以后备用

    快捷键无效解决办法: 1.考虑是否被其他应用占用,如QQ,QQ音乐,千千动听等 2.在eclispe查看是否被修改:Window->Preferences->General->Key ...

  4. ROI

    1.ROI简介 ROI(region of interest),感兴趣区域.机器视觉.图像处理中,从被处理的图像以方框.圆.椭圆. 不规则多边形等方式勾勒出需要处理的区域,称为感兴趣区域,ROI.在H ...

  5. iOS - push 或 pop或点击导航栏返回pop指定导航控制器

    以前一直有个很疑惑的问题没有搞清楚 关于ios中 viewcontroller的跳转问题,其中有一种方式是采用navigationController pushViewController 的方法,比 ...

  6. [leetcode]163. Missing Ranges缺失范围

    Given a sorted integer array nums, where the range of elements are in the inclusive range [lower, up ...

  7. curl: (60) SSL certificate problem: unable to get local issuer certificate 错误

    今天同事做微信管理的项目,请求接口返回如下错误SSL certificate problem: unable to get local issuer certificate. 此问题的出现是由于没有配 ...

  8. Vim基础教程

    一.简介 世界上只有三种编辑器,EMACS.VIM和其它. 我们所处的时代是非常幸运的,有越来越多的编辑器,相对于古老的VIM和EMACS,它们被称为现代编辑器.我们来看看这两个古董有多大年纪了: * ...

  9. bluez蓝牙测试工具

    http://blog.csdn.net/talkxin/article/details/50610984

  10. 设计模式之java源码-工厂方法模式

    工厂方法模式 8.1 女娲造人的故事 东汉<风俗通>记录了一则神话故事:“开天辟辟,未有人民,女娲搏,黄土作人……”,讲述的内容就是大家非常熟悉的女娲造人的故事.开天辟地之初,大地上并没有 ...