zoukankan
html css js c++ java
Codeforces 963 A. Alternating Sum(快速幂,逆元)
[Codeforces 963 A. Alternating Sum](http://codeforces.com/problemset/problem/963/A) 题目大意:给出一组长度为n+1且元素为1或者-1的数组S(0~n),数组每k个元素为一周期,保证n+1可以被k整除。给a和b,求对1e9+9取模的结果 思路:容易想到,每个周期的∑组成的数列成等比,公比q=(b/a)^k,因此可以用等比数列公式求和。为了保证时间复杂度,需要用到快速幂运算;为了防止中间过程值溢出,需要多处取模,其中用费马小定理求逆元; 代码: ```C++ #include
#include
#include
using namespace std; typedef long long ll; const int mod=1e9+9; ll qpow(ll x,ll n,ll m) { ll res=1; while (n>0) { if (n&1) res=res*x%m; n>>=1; x=x*x%m; } return res; } ll inv(ll x,ll m) { return qpow(x,m-2,m); } int main() { int n,a,b,k,i; cin>>n>>a>>b>>k; cin.get(); ll ft=0,q,ans; for (i=0;i
查看全文
相关阅读:
appscan的初步使用
解决selenium自动化上传图片或文件出现windows窗口问题
写入excel数据报错:ValueError: Cannot convert {'code': 0, 'msg': 'login success!', 'username': 'test',} to Excel
接口自动化使用session会话解决数据依赖问题
使用django开发一个简单的post接口
windows10,解决jmeter5.2.1版本界面字体过小问题
django配置使用mysql数据库运行报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
python装饰器
python闭包
工作总结
原文地址:https://www.cnblogs.com/orangee/p/9094357.html
最新文章
HDU -- 4496
POJ -- 2823
HDU --- 4006
codeforce ---A. Milking cows
POJ -- 1273 Drainage Ditches
HDU --3549
最大流算法---Edmond-Karp
HDU --2665
POJ --2104
leetcode367- Valid Perfect Square- easy
热门文章
leetcode366- Find Leaves of Binary Tree- medium
leetcode311- Sparse Matrix Multiplication- medium
leetcode297- Serialize and Deserialize Binary Tree- hard
leetcode277- Find the Celebrity- medium
lintcode102- Linked List Cycle- medium
lintcode105- Copy List with Random Pointer- medium
leetcode450- Reverse Nodes in k-Group- hard
leetcode254- Factor Combinations- medium
leetcode245- Shortest Word Distance III- medium
解决selenium自动化,消息弹窗3秒消失,无法定位元素问题。
Copyright © 2011-2022 走看看