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 ...
随机推荐
- spring 中c3p0的优化配置
jdbc.properties driverClass=com.mysql.jdbc.Driver jdbcUrl=jdbc:mysql://localhost:3306/testdb user=ro ...
- linux 常用find
磁盘查找文件内容: find .|xargs grep x find . -exec grep x{} \; 磁盘查找文件名称: find / -name "httpd.conf" ...
- Element div is not closed
报错内容:Element div is not closed 解决方法: 将代码复制到NotePad++.SubLime Text等文本编辑器中,另存为.jsp或者.html文件. 这样可以利用语法高 ...
- Windows下Fortran编译Lapack库及使用的方法(转自新浪)
Lapack 是一套被非常广泛使用的线性代数计算工具库,现在的主要编写语言时 Fortran90 .Lapack 基本上可以说是速度最快的线性代数计算库,我们看看官方给出的其被应用的几个地方就可以看出 ...
- Marriage Match II(二分+并查集+最大流,好题)
Marriage Match II http://acm.hdu.edu.cn/showproblem.php?pid=3081 Time Limit: 2000/1000 MS (Java/Othe ...
- 【校招面试 之 C/C++】第2题 函数模板、类模板、特化、偏特化
1.C++模板 说到C++模板特化与偏特化,就不得不简要的先说说C++中的模板.我们都知道,强类型的程序设计迫使我们为逻辑结构相同而具体数据类型不同的对象编写模式一致的代码,而无法抽取其中的共性,这样 ...
- Halcon的一维条码解码步骤和解码技巧
一.图像预处理和条码增强 对比度太低:scale_image(或使用外部程序scale_image_range),增强图像的对比度. 图像模糊:emphasize锐化图像,使条码看起来更清晰. 深色背 ...
- PAT 1083 是否存在相等的差(20)(代码+思路)
1083 是否存在相等的差(20 分) 给定 N 张卡片,正面分别写上 1.2.--.N,然后全部翻面,洗牌,在背面分别写上 1.2.--.N.将每张牌的正反两面数字相减(大减小),得到 N 个非负差 ...
- 第三章 RNA测序
第三章 RNA测序 RNA测序(RNA Sequencing,简称RNA-Seq,也被称为全转录物组鸟枪法测序Whole Transcriptome Shotgun Sequencing,简称WT ...
- Codeforces 691C. Exponential notation 模拟题
C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: st ...