zoukankan      html  css  js  c++  java
  • 能量采集

    有点像SDOI仪仗队
    注解见代码

    # include <stdio.h>
    # include <stdlib.h>
    # include <iostream>
    # include <algorithm>
    # include <string.h>
    # define IL inline
    # define RG register
    # define Fill(a, b) memset(a, b, sizeof(a))
    using namespace std;
    typedef long long ll;
    
    IL ll Read(){
        RG char c = getchar(); RG ll x = 0, z = 1;
        for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
        for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + c - '0';
        return x * z;
    }
    
    //sigma [2 * Gcd(i, j) + 1]
    int n, m;
    ll f[100010], ans;
    //f[x]表示gcd为x的(i, j)的对数
    //g[x]表示gcd为x的倍数的(i, j)的对数
    //g[x] = (n / x) * (m / x)
    //f[x] = g[x] - f[2 * x] - f[3 * x] - ... - f[i * x]
    
    int main(RG int argc, RG char* argv[]){
        n = Read(); m = Read();
        for(RG int i = min(n, m); i; i--){
            f[i] = 1LL * (n / i) * (m / i);
            for(RG int j = 2; i * j <= min(n, m); j++) f[i] -= f[i * j];
            ans += f[i] * (2 * i - 1);
        }
        printf("%lld
    ", ans);
        return 0;
    }
    
  • 相关阅读:
    [BZOJ2969] 矩形粉刷
    数字 (number)
    字符串(String)
    小HY的四元组
    最大公约数(Max Gcd)
    [洛谷P2102] 地砖铺设
    Python OS模块(内置模块)
    json解析神器--jsonpath
    kafka 优势+应用场景
    Python之异常处理
  • 原文地址:https://www.cnblogs.com/cjoieryl/p/8206391.html
Copyright © 2011-2022 走看看