Counting Divisors (2017 多校4)“素 数 筛”
来源:互联网 发布:商家平台源码 编辑:程序博客网 时间:2024/06/15 15:55
- Counting Divisors
In mathematics, the function
For example,
In this problem, given
In each test case, there are
31 5 11 10 21 100 3
10482302
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#define maxn 1000100using namespace std;typedef long long ll;ll l,r,k;bool vis[maxn];int prime[maxn];ll a[maxn],b[maxn];int len;const ll MOD=998244353;void init(){ len=0; for(int i=2; i<maxn; i++) { if(!vis[i]) prime[len++]=i; for(int j=0; j<len&&i*prime[j]<maxn; j++) { vis[i*prime[j]]=1; if(i%prime[j]==0) break; } }}int main(){ int T; scanf("%d",&T); init(); while(T--) { ll ans=0; scanf("%lld%lld%lld",&l,&r,&k); for(ll i=0;i<r-l+1;i++) { a[i]=i+l; //记录每个数字的最后状态 b[i]=1; //存每个数字的贡献值 } for(ll i=0;i<len&&prime[i]<=r;i++) { ll tem,t; ll cnt=(l-1+prime[i])/prime[i]*prime[i]; while(cnt<=r) { t=cnt; tem=0; while(t%prime[i]==0) { tem++; t/=prime[i]; a[cnt-l]/=prime[i]; } b[cnt-l]=((b[cnt-l]%MOD)*((k*tem+1)%MOD))%MOD; cnt+=prime[i]; } } for(ll i=0;i<r-l+1;i++) { if(a[i]==1) ans=(ans+b[i])%MOD; else ans=(ans+((b[i]%MOD)*((k+1)%MOD)))%MOD; } printf("%lld\n",ans); }}
阅读全文
0 0
- Counting Divisors (2017 多校4)“素 数 筛”
- 2017 多校4 1003 Counting Divisors
- Hdu6069 Counting Divisors(2017多校第4场)
- HDU 6069 Counting Divisors 2017 多校
- HDU 6069 Counting Divisors(多校4)
- HDU6069 Counting Divisors(区间素数筛)
- Counting Divisors(hdu6069)
- HDU 2017 多校联合训练赛4 4003 6069 Counting Divisors 素数筛和素因数分解
- HDU6070 Counting Divisors(数论)
- hdu6069 Counting Divisors(数学)
- 2017 Multi-University Training Contest 4 && HDOJ 6069 Counting Divisors 【区间筛法】
- HDU 6069 Counting Divisors (2017 Multi-Univ Training Contest 4)
- HDU-2017 多校训练赛4-1003-Counting Divisors
- HDU 6069 Counting Divisors 【2017多校联赛4】
- HDU6069---Counting Divisors(2017多校联赛:数学)
- hdu 6069 Counting Divisors(2017多校第四场)
- Counting Divisors
- Counting Divisors
- JS实现继承的几种方式
- GNU C中嵌入汇编添加一个自定义uboot命令
- opencv常见函数
- Java8 Lambda语法 示例
- serializer嵌套序列化
- Counting Divisors (2017 多校4)“素 数 筛”
- 数据结构之二叉树
- uva1600-Patrol Robot(bfs)
- LeetCode 474. Ones and Zeroes 动态规划解法+拓展
- Socket抽象类的工程应用
- 【LeetCode】189. Rotate Array
- Set up CodeBlocks for OpenCV
- gcd公式
- Java 、 Android 面试题