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
查看全文
相关阅读:
17-canvas绘制扇形
16-canvas绘制圆弧
15-canvas渐变色
14-canvas绘制柱状图
13-绘制矩形的简写方式
12-es6类的方式封装折线图
11-canvas绘制折线图
10-canva绘制数据点
jenkins 环境部署 (yum安装方式)
BerkeleyDB安装
原文地址:https://www.cnblogs.com/orangee/p/9094357.html
最新文章
正则表达式
预处理方法
Gensim相关
去停用词
python写入文件
vue项目配置及代理解决跨域
小程序云开发请求第三方http或https接口
[login] 调用失败 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID , cloud function service error code -501000, error message Environment not found;
scrollTop、scrollHeight与clientHeight
springboot完整项目,基于人人开源框架
热门文章
在自己win系统里面给idea配置Git
springboot中关于Long类型返回前端精度丢失问题处理
快速搭建springboot文件管理系统
Mybatis快速逆向生成代码
后台Spring、MyBatis、Shiro框架
Springboot+Vue实现仿百度搜索自动提示框匹配查询功能
mall项目电商系统
java面试题2-自己整合的
19-canvas绘制文字
18-canvas绘制饼状图
Copyright © 2011-2022 走看看