2017杭电多校联赛team3 Kanade's sum hdu6058 快速幂
来源:互联网 发布:js播放器进度条 编辑:程序博客网 时间:2024/06/07 00:34
Kanade's sum
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2011 Accepted Submission(s): 810
Problem Description
Give you an array A[1..n] of length n .
Letf(l,r,k) be the k-th largest element of A[l..r] .
Specially ,f(l,r,k)=0 if r−l+1<k .
Give youk , you need to calculate ∑nl=1∑nr=lf(l,r,k)
There are T test cases.
1≤T≤10
k≤min(n,80)
A[1..n] is a permutation of [1..n]
∑n≤5∗105
Let
Specially ,
Give you
There are T test cases.
Input
There is only one integer T on first line.
For each test case,there are only two integersn ,k on first line,and the second line consists of n integers which means the array A[1..n]
For each test case,there are only two integers
Output
For each test case,output an integer, which means the answer.
Sample Input
15 21 2 3 4 5
Sample Output
30
Source
2017 Multi-University Training Contest - Team 3
Recommend
liuyiding | We have carefully selected several similar problems for you: 6066 6065 6064 6063 6062
思路:
由样例发现,n^k%mod=ans。
官方题解
ac代码:
#include<stdio.h>#define LL long long#define Mod 1e9+7LL N,K,ans;LL power2(LL a, LL b, LL c) {LL res = 1;a %= c;while (b) {if (b & 1)res = (res * a) % c;a = (a * a) % c;b >>= 1;}return res;}int main() {int cnt=0;while(~scanf("%lld%lld",&N,&K)) {printf("Case #%d: %lld\n",++cnt,power2(N,K,Mod));}return 0;}
总结:有想法多试一试,数据大的题目打表看看(上一场多校貌似也有一道找规律的)。
阅读全文
0 0
- 2017杭电多校联赛team3 Kanade's sum hdu6058 快速幂
- HDU6058 2017杭电多校联赛第三场-Kanade's sum
- HDU6058-Kanade's sum
- hdu6058-Kanade's sum
- hdu6058 Kanade's sum
- HDU6058-Kanade's sum
- HDU6058 Kanade's sum
- HDU6058-Kanade's sum
- HDU6058 Kanade's sum
- hdu6058 Kanade's sum
- 2017杭电多校联赛第三场-Kanade's sum (hdu6058) 求第k大的数的和
- 【2017多校】HDU6058 Kanade's sum 【链表】
- HDU6058 Kanade's sum【模拟】
- Hdu6058 Kanade's sum(2017多校第3场)
- 2017多校训练Contest3: 1003 Kanade's sum hdu6058
- 2017杭电多校第三场 1003 Kanade's sum(hdu6058 区间内第k大)
- 【HDU6058】Kanade's sum(暴力 or 链表)
- HDU6058-Kanade's sum 链表+思维
- 关于/*+ DRIVING_SITE(tableName)*/的优化(SQL效率)
- 每日一题(5) —— 逗号表达式
- HDU 1728 逃离迷宫 + HDU 1072 Nightmare(bfs+dfs)
- element ui 表格的checkbox初始化不可勾选
- 拼多多2017校招前端笔试题
- 2017杭电多校联赛team3 Kanade's sum hdu6058 快速幂
- 人脸集数据库
- springMVC中在过滤器中使用spring bean
- 如何部署android开发环境
- Javascript整理
- 计算机网络中的一些计算题
- 2017 Multi-University Training Contest
- java用ServerSocket类结合io流实现一对一聊天(java实现简单的TCP聊天程序只能用telnet连接后方可使用)
- (部分转载)POJ2191Mersenne Composite Numbers梅森素数