2501. 算算式
来源:互联网 发布:分类算法应用场景 编辑:程序博客网 时间:2024/04/25 23:06
2501. 算算式
Constraints
Time Limit: 1 secs, Memory Limit: 256 MB
Description
_gXX遇到一个麻烦的式子:
S = n1 + n2 + n3 + ...... + nk,已知n、k,求S的值。
因为_gXX数学很差,希望你能告诉他答案。但是由于他的数学实在太差了,所以你只需要告诉他S除以9901的余数即可。
Input
两个整数,n和k(n ≤ 1000 , k ≤ 109)。
Output
一个数,表示S除以9901的余数。
Sample Input
2 3
Sample Output
14
Problem Source
黄金周赛——省赛最后的冲刺
费马小定理,算法参考
http://blog.csdn.net/luojiayu14/article/details/7089499
http://www.doc88.com/p-381740859897.html
// Problem#: 2501
// Submission#: 1986692
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n,k,i,sum=0;
cin>>n>>k;
k%=9900;
for(i=1;i<=k;i++){
sum=(sum+1)*n;
sum%=9901;
}
cout<<sum<<endl;
return 0;
}
- 2501. 算算式
- 2501. 算算式
- Sicily 2501. 算算式
- Sicily 2501.算算式
- Sicily 2501. 算算式
- sicily 2501. 算算式
- Sicily 2501 算算式
- Sicily2501 算算式(费马小定理)
- 算算时间
- 算算退休后能拿多少钱?
- 算算你的IQ
- 算算收入排名
- 算算男女生比例
- 算算你的时间差
- [vijos1052] 贾老二算算术
- 咱也来算算英文单词的“分数”
- 算算你能活多久?
- 算算你啥时死掉
- Async 编程简介
- fopen函数
- 两个div滚动条同步简单实现
- 软工导论 12-13-2 第一次作业
- 常用算法帖(C#): 并发集合
- 2501. 算算式
- 交通灯管理系统分析
- 控制程序运行不超过指定个数实例的一种方法
- perror函数,strerror函数,errno
- nginx location的管理以及查找
- Extjs使用技巧总结
- testlink1.9.5与bugzilla的整合
- android webview 实现放大缩小 隐藏控件问题
- 导出含有缩略图的零件列表