sum of power
来源:互联网 发布:导入mac的照片在哪里 编辑:程序博客网 时间:2024/05/20 04:26
Think:
PS : 题目出处“浪潮杯”山东省第八届ACM大学生程序设计竞赛
题目要求 就是 计算 从1到n的m次幂运算的和, 同时注意mod取余运算;
Problem Description
Calculate mod (1000000000+7) for given n,m.
Input
Input contains two integers n,m(1≤n≤1000,0≤m≤10).
Output
Output the answer in a single line.
Example Input
10 0
Example Output
10
Hint
Author
“浪潮杯”山东省第八届ACM大学生程序设计竞赛(感谢青岛科技大学)
#include<bits/stdc++.h>using namespace std;#define mod 1000000007;long long int ans;long long int sum;long long int p(int a, int n) { ans = 1; for (int i = 0;i < n;i ++) { ans = ans * a; ans = ans % mod; } return ans; }int main() { int n, m; scanf("%d %d", &n, &m); sum = 0; for (int i = 1;i <= n;i ++) { sum = sum + p(i, m); sum = sum % mod; } printf("%lld\n", sum); }
阅读全文
0 0
- sum of power
- sum of power
- uva 766 sum of power
- 省SD2017 G sum of power【water】
- sum of power——大数取模
- 第八届山东省赛题->sum of power
- acm省赛--D sum of power快速幂
- Hackerrank Coprime Power Sum
- 山东省第八届 ACM 省赛 sum of power (求和、水)
- 山东省第八届 ACM 省赛 G sum of power (简单快速幂)
- 山东省第八届ACM省赛 G 题(sum of power)
- 山东省第八届 ACM 省赛 sum of power(SDUT 3899)
- 山东省第八届ACM省赛 G 题 sum of power 解答
- Power of two,power of three,power of four
- [LeetCode] Power of Three | Power of Two
- The power of Reading
- The power of algorithm
- Power of Cryptography POJ2109
- Eclipse编译时函数报错:Undefined reference to 'pthread_create'
- 模式识别学习笔记
- SpringMVC之Controller常用注解功能全解析
- C# 读写XML文件
- windows+ubuntu双系统不用重装系统的磁盘分区
- sum of power
- HDU 2005 第几天?
- scrapy代理的设置
- 研发vin码识别的原因,闲谈介绍
- word技巧123
- java中error,Exception,Throwable的关系
- mysql基础-group by
- robocode时间、速度、能量、GunHeat,以及常用调试方法
- 1030. 完美数列(25) PAT