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 ...
随机推荐
- 在Eclipes中查看源代码和大纲快速定位
1 在Eclipes中查看源代码,快捷键使用clrl+光标,选择你要查看的方法和属性查看源代码.例如你想看StringBuilder这个类源代码 StringBuilder allow = new S ...
- ArcGIS案例学习笔记4_1
ArcGIS案例学习笔记4_1 联系方式:谢老师,135-4855-4328, xiexiaokui(#)qq.com 时间:第四天上午 案例1:矢量校正案例 教程:Editing编辑教程 pdf 数 ...
- 【Java】JVM(二)、Java垃圾收集算法
一.标记-清除算法 算法主要分为两个步骤 1. 标记: 遍历所有的 GC Roots, 然后标记所有可达对象为存活对象 2. 清除: 遍历堆中所有对象,然后将没有标记的对象清除. 存在不足: 1. 效 ...
- jps command not found已解决
根据当前版本安装devel 包 eg: yum install java--openjdk-devel -y jdk小工具jps介绍 jps(Java Virtual Machine Process ...
- jsp页面添加时间
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <body& ...
- mysq 数据库基本管理
命令表: 1.设置mysql数据库密码 mysqladmin -u root password 'new-password' 'new-password'为数据库密码. 2.登陆mysql数据库 my ...
- Educational Codeforces Round 59
B. Digital root 题意: 题目定义了x的digital root是S(x).S(5)=5,S(38)=S(3+8=11)=S(1+1+2)=2. 有n个询问,每次询问给出ki和xi,要你 ...
- 神龟快跑,2016做的一款UWP游戏
神龟快跑,2016做的一款UWP游戏, 实际是H5页面, 用LAYA转AS3得到的 安装地址 https://www.microsoft.com/zh-cn/store/p/神龟快跑/9nblggh4 ...
- python的select服务端的代码和客户端的代码
服务端的代码 import socket import queue import select ip_bind = ("127.0.0.1",9000) message_queue ...
- linux 下 php 安装 Gearman
Gearman是一个分发任务的程序框架,它会对作业进行排队自动分配到一系列机器上.gearman跨语言跨平台,很方便的实现异步后台任务. 一个Gearman请求的处理过程涉及三个角色: Clien ...