zoukankan      html  css  js  c++  java
  • LightOJ 1370 Bi-shoe and Phi-shoe(欧拉函数+打表)

    /*
    题意:
    对于每个数字a[i]找到一个数num[i],num[i]的欧拉函数值大于等于a[i],
    求找到的所有数的最小和。
    */
    #include <algorithm>
    #include <iostream>
    #include <cmath>
    #include <cstdio>
    #include <cstring>
    #include <map>
    using namespace std;
    typedef long long LL;
    const int N = 1e6 + 10;
    int ans[N];
    void init()
    {
        int i, j;
        for(i = 2; i < N; i++) {
            if(!ans[i])
                for(j = i; j < N; j += i) {
                    if(!ans[j])
                        ans[j] = j;
                    ans[j] = ans[j] / i * (i - 1);
                }
        }
    }
    int main()
    {
        int it = 1, t, m, n, i;
        init();
        scanf("%d", &t);
        while(t--) {
            scanf("%d", &n);
            LL sum = 0;
            while(n--) {
                scanf("%d", &m);
                for(i = m + 1; ans[i] < m; i++)
                    ;
                sum += i;
            }
            printf("Case %d: %lld Xukha
    ", it++, sum);
        }
        return 0;
    }
  • 相关阅读:
    3.10上午学习内容
    计算机网络基础
    2017.3.30-morning
    2017.3.29-afternoon
    2017.3.29-morning
    2017.3.28-afternoon
    2017.3.28-morning
    2017.3.27-afternoon
    2017.3.27-morning
    2017.3.24-morning
  • 原文地址:https://www.cnblogs.com/yu0111/p/6759077.html
Copyright © 2011-2022 走看看