/*
LightOJ 1370 Bi-shoe and Phi-shoe
http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1370
数论 欧拉函数
坑点是答案会爆int!!!!
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <map>
#include <set>
//#define test
using namespace std;
const int Nmax=1e6+5e5;//Nmax一定要大于1e6否则会找不到答案
int phi[Nmax];
int prime[Nmax];
int is_prime[Nmax];
int prime_cnt;
void get()
{
phi[]=;
for(int i=;i<Nmax;i++)
is_prime[i]=;
for(long long i=;i<Nmax;i++)
{
if(is_prime[i])
{
prime[++prime_cnt]=i;
phi[i]=i-;
}
for(int j=;j<=prime_cnt;j++)
{
if(i*prime[j]>=Nmax)
break;
is_prime[i*prime[j]]=;
if(i%prime[j]==)
{
phi[i*prime[j]]=phi[i]*prime[j];
break;
}
else
phi[i*prime[j]]=phi[i]*(prime[j]-);
}
}
}
int main()
{
#ifdef test
#endif
get();
phi[]=;//此题要求phi[1]=0;
//for(int i=1;i<Nmax;i++)
//{
//num[i].id=i;
//num[i].val=phi[i];
//}
//sort(num+1,num+Nmax);
//for(int i=1;i<=40;i++)
//{
//printf("phi[%d]:%d\n",i,phi[i]);
//}
int t,n;
scanf("%d",&t);
for(int ttt=;ttt<=t;ttt++)
{
scanf("%d",&n);
long long ans=0LL;//此题一大坑点,ans会爆int
int a;
for(int i=;i<=n;i++)
{
scanf("%d",&a);
for(int j=a+;j<Nmax;j++)//强力减枝!
{
if(phi[j]>=a)
{
ans+=1LL*j;
break;
}
}
}
printf("Case %d: %lld Xukha\n",ttt,ans);
}
return ;
}

LightOJ 1370 Bi-shoe and Phi-shoe的更多相关文章

  1. lightoj 1370 欧拉函数

    A - Bi-shoe and Phi-shoe Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & % ...

  2. LightOJ 1370 - Bi-shoe and Phi-shoe (欧拉函数思想)

    http://lightoj.com/volume_showproblem.php?problem=1370 Bi-shoe and Phi-shoe Time Limit:2000MS     Me ...

  3. Lightoj 1370 素数打表 +二分

    1370 - Bi-shoe and Phi-shoe   PDF (English) Statistics   Time Limit: 2 second(s) Memory Limit: 32 MB ...

  4. LightOJ 1370 Bi-shoe and Phi-shoe【欧拉函数 && 质数】

    题目链接: http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1370 题意: 给定值,求满足欧拉值大于等于这个 ...

  5. LightOJ 1370 Bi-shoe and Phi-shoe 欧拉函数+线段树

    分析:对于每个数,找到欧拉函数值大于它的,且标号最小的,预处理欧拉函数,然后按值建线段树就可以了 #include <iostream> #include <stdio.h> ...

  6. LightOJ - 1370

    Bi-shoe and Phi-shoe Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu S ...

  7. LightOJ - 1370 Bi-shoe and Phi-shoe (欧拉函数打表)

    题意:给N个数,求对每个数ai都满足最小的phi[x]>=ai的x之和. 分析:先预处理出每个数的欧拉函数值phi[x].对于每个数ai对应的最小x值,既可以二分逼近求出,也可以预处理打表求. ...

  8. 欧拉函数 || LightOJ 1370 Bi-shoe and Phi-shoe

    给出x,求最小的y使y的欧拉函数大于等于x *解法:i).求出1e6之内的数的欧拉函数,遍历找             ii).求比x大的第一个质数——因为每个质数n的欧拉函数都是n-1 wa一次是因 ...

  9. 【LightOJ - 1370】Bi-shoe and Phi-shoe

    Bi-shoe and Phi-shoe Descriptions: 给出一些数字,对于每个数字找到一个欧拉函数值大于等于这个数的数,求找到的所有数的最小和. Input 输入以整数T(≤100)开始 ...

随机推荐

  1. bzoj3940

    AC自动机 复习一下... 可惜又写错了 我们发现就是把单词建成ac自动机,然后把串在ac自动机上跑一遍,每到一个单词结束点就删除,删除是利用栈,每次弹出单词长度个字符就可以了 发现两个小问题,str ...

  2. Scala 是一门怎样的语言,具有哪些优缺点?

    保罗·格雷厄姆在<黑客与画家>中写道,Java属于B&D(捆绑与束缚)类型的语言.为何束缚手脚?因为要让新手和明星程序员写出类似质量的代 码,尽可能的抹消人的才华对程序的影响.不同 ...

  3. java网络编程UDP

    图片来自网络 [发送端] import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSoc ...

  4. Graphics.DrawMeshInstanced

    Draw the same mesh multiple times using GPU instancing. 可以免去创建和管理gameObj的开销 并不是立即绘制,如需:Graphics.Draw ...

  5. 增加删除div

    <!doctype html><html><head><meta charset="utf-8"><title>无标题文 ...

  6. iOS CoreData 开发之数据模型关系

    接着上一篇,上一篇中,我们简单的实现了一个用户实体,本次添加一个用户信息实体,与用户实体相关联,关系为1:1. 新建一个实体UserInfo:

  7. python编辑csv

    import csv import time def timestamp_to_timestr(timeStamp): timeArray = time.localtime(int(timeStamp ...

  8. MaskRCNN路标:TensorFlow版本用于抠图

    MaskRCNN用于检测路标,作为更详细的目标检测,用以得到更精准的额路标位置,路标的几何中心点,用于构建更为精准的拓扑地图,减少构图误差. 抠图工具已经完成,把框抠出来,用0值表示背景. pytho ...

  9. docker安装后出现Cannot connect to the Docker daemon

    启动docker service docker start docker安装后出现Cannot connect to the Docker daemon You need to add user in ...

  10. centOS安装python3 以及解决 导入ssl包出错的问题

    参考: https://www.cnblogs.com/mqxs/p/9103031.html https://www.cnblogs.com/cerutodog/p/9908574.html 确认环 ...