zoukankan      html  css  js  c++  java
  • LIGHT OJ 1370 欧拉函数(在小于自身的正整数中有n个与自身互素的数,这样的数最小的为n后第一个素数)

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<cstring>
     4 #include<string>
     5 #include<algorithm>
     6 #include <cmath>
     7 using namespace std;
     8 typedef long long ll;
     9 const ll INF = -100000000000ll;
    10 const double eps = 1e-8;
    11 const int maxn = 1e6 + 10;
    12 const double PI = acos(-1);
    13 int pre[maxn];
    14 void init(){
    15     pre[1] = 1;
    16     for(int i = 2;i <= 1000005;i++)
    17         if(!pre[i]){
    18             for(int j = i*2;j <= 1000005;j += i)
    19                 pre[j] = 1;
    20         }
    21 
    22 }
    23 int main()
    24 {
    25   //  freopen("in.txt","r",stdin);
    26     init();
    27     int T,cas = 0;
    28     cin>>T;
    29     while(T--){
    30         int n,a;
    31         cas++;
    32         scanf("%d",&n);
    33         ll ans = 0;
    34         for(int i = 1;i <= n;i++){
    35             scanf("%d",&a);
    36             a++;
    37             while(pre[a]) a++;
    38            // cout<<i<<" "<<a<<endl;
    39             ans += a;
    40         }
    41 
    42         printf("Case %d: %lld Xukha
    ",cas,ans);
    43     }
    44 
    45     return 0;
    46 }
  • 相关阅读:
    C#
    C#
    C#
    python——socket网络编程
    Python——面向对象
    Python——函数
    Python——列表深浅拷贝
    Python——文件操作
    多级菜单(增强版)
    Python 编码机制
  • 原文地址:https://www.cnblogs.com/shimu/p/5927457.html
Copyright © 2011-2022 走看看