zoukankan      html  css  js  c++  java
  • cf 1139D

    题目链接:https://codeforces.com/contest/1139/problem/D

    目前还没整明白,留着以后看

    #include "bits/stdc++.h"
    
    using namespace std;
    typedef long long ll;
    const int mod = 1e9 + 7;
    const int maxn = 1e5 + 100;
    ll mu[maxn];
    int vis[maxn];
    ll mua[maxn];
    
    ll pow_mod(ll a, ll b) {
        ll ret = 1;
        while (b) {
            if (b & 1) ret = ret * a % mod;
            a = a * a % mod;
            b >>= 1;
        }
        return ret;
    }
    
    ll inv(ll x) {
        return pow_mod(x, mod - 2);
    }
    
    int main() {
        ll m;
        cin >> m;
        mu[1] = 1;
        for (int i = 1; i <= m; i++) mu[i] = 1;
        for (int i = 2; i <= m; i++) {
            if (!vis[i]) {
                mu[i] = -1;
                for (int j = i + i; j <= m; j += i) {
                    vis[j] = 1;
                    if ((j / i) % i == 0) mu[j] = 0;
                    else mu[j] *= -1;
                }
            }
        }
        ll ans = 1;
        for (int i = 2; i <= m; i++) {
            if (mu[i] != 0) {
                ans = ans - mu[i] * (m / i) * inv(m - m / i);
            }
        }
        cout << (ans % mod + mod) % mod << endl;
        return 0;
    }
  • 相关阅读:
    Element节点
    Document节点
    ParentNode接口,ChildNode接口
    NodeList接口,HTMLCollection接口
    Node接口
    DOM概述
    Promise对象
    定时器
    IT常用日语
    配置JavaWeb开发环境
  • 原文地址:https://www.cnblogs.com/albert-biu/p/10585829.html
Copyright © 2011-2022 走看看