/*
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. 解决 EF where<T>(func) 查询的一个性能问题

    前两年帮朋友 做了个网吧管理软件,采用动软的三层架构 sql语句生成的.最近因功能变更 要改动,而我这段正在做asp.net mvc +ef+autofac的一个电商网站.索性 就把原来的底层全重新了 ...

  2. POJ3070Fibonacci

    矩阵乘法裸题 求快速幂 #include<iostream> #include<cstdio> #define ll long long #define Mod 10000 u ...

  3. [App Store Connect帮助]二、 添加、编辑和删除用户(1)用户帐户和职能概述

    您可以在 App Store Connect 的“用户和访问”部分管理用户.添加沙盒测试员以及管理 API 密钥. 用户职能决定了用户对 App Store Connect 和 Apple Devel ...

  4. 2019 年了,为什么我还在用 jQuery?

    译者按: 看来 jQuery 还是有一些用武之地的. 原文: Why I'm Still Using jQuery in 2019 译者: Fundebug 为了保证可读性,本文采用意译而非直译.翻译 ...

  5. 【POJ3255/洛谷2865】[Usaco2006 Nov]路障Roadblocks(次短路)

    题目: POJ3255 洛谷2865 分析: 这道题第一眼看上去有点懵-- 不过既然要求次短路,那估计跟最短路有点关系,所以就拿着优先队列优化的Dijkstra乱搞,搞着搞着就通了. 开两个数组:\( ...

  6. Java系列学习(五)-流程控制语句

    1.顺序结构 1.if语句 (1)图例 (2)三种格式 A:格式1 B:格式2 C:格式3 2.swich语句 图例: 格式: [注]input可以是byte,short,int,char:JDK5以 ...

  7. fcc jQuery 练习

    在页面顶端增加一行script元素,然后写上结束符, 浏览器会运行script 里所有的Javascript,包括jQuery <script>$(document).ready(func ...

  8. 易语言 打开exe可执行文件、打开网页

    打开文件--------按钮被单击事件 直接复制以下代码即可 .版本 2 .子程序 _按钮58_被单击 运行 (“exe文件路径”, 假, ) 打开网站--------按钮被单击事件 直接复制以下代码 ...

  9. 重绘DataGridView标头

    最近突然想在DataGridView标头放置一个CheckBox,我就想着重写下DataGridViewColumnHeaderCell抱着试试的心态结果真的是可以的下面是源码:(如果有看不懂的可以加 ...

  10. RTL Compiler之synthesis flow

    1 generic RTL Compiler work flow 2 invoking RTL compiler RTL Compiler is invoked from the operating ...