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;
    }
  • 相关阅读:
    SSH免密登陆
    Linux服务器绑定多网卡IP
    搭建简易网站
    Linux中raid磁盘阵列
    Linux中防火墙命令
    Linux中LVM逻辑卷管理
    Linux中fdisk分区
    Linux计划任务
    Linux基础命令(三)
    Linux基础命令(二)
  • 原文地址:https://www.cnblogs.com/albert-biu/p/10585829.html
Copyright © 2011-2022 走看看