LightOJ 1213 Fantasy of a Summation
来源:互联网 发布:台达plc编程教学视频 编辑:程序博客网 时间:2024/06/05 15:03
思路:观察后可以发现,这段代码计算的就是((a[1]+a[2]+…+a[n])*k*n^(k-1))%mod
#include <iostream>#include <algorithm>using namespace std;typedef long long ll;ll pow(int a, int b, int m){ ll res = 1; while(b) { if(b&1) res = res*a%m; a = a*a%m; b >>= 1; } return res;}int main(){ int t,time = 0; ll n,k,mod; ll sum,num,n2; cin >> t; while(t--) { sum = 0; cin >> n >> k >> mod; for(int i = 0; i < n; ++i) { cin >> num; sum = (sum+num)%mod; } n2 = pow(n,k-1,mod); n2 = n2*k%mod; cout << "Case " << ++time << ": " << sum*n2%mod <<endl; } return 0;}
0 0
- lightOJ 1213 Fantasy of a Summation
- LightOJ 1213 Fantasy of a Summation
- LightOJ 1213 Fantasy of a Summation
- LightOJ 1213 - Fantasy of a Summation (排列组合+快速幂)
- lightoj 1213 - Fantasy of a Summation 【数学计数】
- LightOJ 1213 Fantasy of a Summation(快速幂)
- Fantasy of a Summation
- Fantasy of a Summation
- LightOj 1220 Fantasy of a Summation(快速幂)
- 【Light】[1213]Fantasy of a Summation
- lightoj1213 - Fantasy of a Summation
- LightOJ1213 Fantasy of a Summation
- light oj 1213 - Fantasy of a Summation (数学计数)
- light oj 1220 Fantasy of a Summation
- Light OJ 1213 Fantasy of a Summation (快速幂+规律)
- Fantasy of a Summation(找规律,水)
- ACM_1007_Numerical Summation of a Series
- Numerical Summation of a Series
- 警告: Could not find action or result There is no Action mapped for namespace / and action name
- Hadoop(一) 之 安装Hadoop
- iOS 常用三方库
- 互联网&IT技术一周大事件汇总
- 电路啸叫的原因????!!!!!
- LightOJ 1213 Fantasy of a Summation
- python获取指定路径下的所有文件
- sybase复制服务
- xml解析
- ViewPager 调用 notifyDataSetChanged()无刷新
- webpack~关于使用包详解(随时更新)
- entrySet() ,keySet()的区别
- BZOJ3307 雨天的尾巴 (树链剖分 线段树合并 dfs相关)
- Java length、length()、size()区别