• luogu1829 [国家集训队]Crash的数字表格


    被 bs 了姿势水平……好好学习数学QAQQAQQAQ
    ref

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    using namespace std;
    typedef long long ll;
    int n, m, pri[10000005], cnt, mu[10000005], qia[10000005];
    bool isp[10000005];
    const int mod=20101009;
    void shai(){
    	memset(isp, true, sizeof(isp));
    	isp[0] = isp[1] = false;
    	mu[1] = 1;
    	for(int i=2; i<=10000000; i++){
    		if(isp[i])	pri[++cnt] = i, mu[i] = -1;
    		for(int j=1; j<=cnt && i*pri[j]<=10000000; j++){
    			isp[i*pri[j]] = false;
    			if(i%pri[j]==0){
    				mu[i*pri[j]] = 0;
    				break;
    			}
    			mu[i*pri[j]] = mu[i] * -1;
    		}
    	}
    	for(int i=1; i<=10000000; i++)
    		qia[i] = ((ll)i*i*mu[i]%mod+mod)%mod;
    	for(int i=2; i<=10000000; i++)
    		qia[i] = (qia[i-1] + qia[i]) % mod;
    }
    int solve1(int x, int y){
    	int i=1, re=0;
    	while(i<=min(x, y)){
    		int j=min(x/(x/i), y/(y/i));
    		int tmp=(qia[j]-qia[i-1]+mod)%mod;
    		tmp = (ll)tmp * ((ll)(1+x/i)*(x/i)/2 % mod) % mod;
    		tmp = (ll)tmp * ((ll)(1+y/i)*(y/i)/2 % mod) % mod;
    		re = (re + tmp) % mod;
    		i = j + 1;
    	}
    	return re;
    }
    int main(){
    	cin>>n>>m;
    	shai();
    	int i=1, ans=0;
    	while(i<=min(n, m)){
    		int j=min(n/(n/i), m/(m/i));
    		int tmp=((ll)(i+j)*(j-i+1)/2)%mod;
    		tmp = (ll)tmp * solve1(n/i, m/i) % mod;
    		ans = (ans + tmp) % mod;
    		i = j + 1;
    	}
    	cout<<ans<<endl;
    	return 0;
    }
    
  • 相关阅读:
    CSS关键词的值-currentColor关键字提示文字(当前颜色)
    DOM 对象方法
    CSS三种样式表
    html页面不使用缓存的代码
    DOM-----style属性对照表
    UISwitch属性
    UIImageView属性
    UIView属性
    UIScrollView
    UILabel属性
  • 原文地址:https://www.cnblogs.com/poorpool/p/8921796.html
Copyright © 2020-2023  润新知