给出x,求最小的y使y的欧拉函数大于等于x
*解法:i).求出1e6之内的数的欧拉函数,遍历找
            ii).求比x大的第一个质数——因为每个质数n的欧拉函数都是n-1
wa一次是因为SZ写小了……
#include <iostream>
#include <cstdio>
using namespace std;
#define SZ 1000005
long long phi[SZ], a[SZ];
void getphi(int n)
{
for(int i = ; i <= n; i++) phi[i] = ;
phi[] = ;
for(long long i = ; i <= n; i++)
{
if(!phi[i])
for(long long j = i; j <= n; j += i)
{
if(!phi[j]) phi[j] = j;
phi[j] = phi[j] / i * (i - );
}
}
}
int main()
{
int T, cc = ;
scanf("%d", &T);
phitable(SZ);
while(T--)
{
int n;
scanf("%d", &n);
long long ans = ;
for(int i = ; i < n; i++)
scanf("%lld", &a[i]);
sort(a, a+n);
long long j = , i = ;
while(i < n)
{
if(a[i] > phi[j]) {j++; continue;}
ans += j;
i++;
}
printf("Case %d: %lld Xukha\n", ++cc, ans);
}
return ;
}

欧拉函数 || LightOJ 1370 Bi-shoe and Phi-shoe的更多相关文章

  1. 数论-欧拉函数-LightOJ - 1370

    我是知道φ(n)=n-1,n为质数  的,然后给的样例在纸上一算,嗯,好像是找往上最近的质数就行了,而且有些合数的欧拉函数值还会比比它小一点的质数的欧拉函数值要小,所以坚定了往上找最近的质数的决心—— ...

  2. zoj 2777 Visible Lattice Points(欧拉函数,基础)

    题目 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> #include<algo ...

  3. UVA 11424 GCD - Extreme (I) (欧拉函数+筛法)

    题目:给出n,求gcd(1,2)+gcd(1,3)+gcd(2,3)+gcd(1,4)+gcd(2,4)+gcd(3,4)+...+gcd(1,n)+gcd(2,n)+...+gcd(n-1,n) 此 ...

  4. P2158 [SDOI2008] 仪仗队(欧拉函数模板)

    题目描述 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是否整齐(如下图 ...

  5. GuGuFishtion HDU - 6390 (欧拉函数,容斥)

    GuGuFishtion \[ Time Limit: 1500 ms\quad Memory Limit: 65536 kB \] 题意 给出定义\(Gu(a, b) = \frac{\phi(ab ...

  6. lightoj 1370 欧拉函数

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

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

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

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

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

  9. LightOJ 1370 Bi-shoe and Phi-shoe(欧拉函数)

    题意:题目给出一个欧拉函数值F(X),让我们求>=这个函数值的最小数N,使得F(N) >= F(X); 分析:这个题目有两种做法.第一种,暴力打出欧拉函数表,然后将它调整成有序的,再建立一 ...

随机推荐

  1. C++ 多项目dll调用-隐式

    将DAA人脸检测做成动态库以便其他程序调用,采用隐式调用完成. 给出部分关于dll制作的关键代码: 1.DLL 多项目DLL编写注意将其他相关项目设置成静态库,以及各库涉及的版本一致性. DLL.h ...

  2. View Programming Guide for iOS ---- iOS 视图编程指南(三)---Windows

    Windows Every iOS application needs at least one window—an instance of the UIWindow class—and some m ...

  3. 算法练习--LeetCode--54. Spiral Matrix 100%

      Spiral MatrixMedium Given a matrix of m x n elements (m rows, n columns), return all elements of t ...

  4. 洛谷 - P1217 - 回文质数 - 枚举

    https://www.luogu.org/problemnew/show/P1217 考虑暴力生成所有的回文数然后再判断是不是质数.注意个位的选择实际上只有4种.所以是 $4*10^3*10^3=4 ...

  5. adb相关

    --------------------------------------------- adb logcat |find "nafio" >c:/logcat.txt 另 ...

  6. hdu 1028 Ignatius and the Princess III【生成函数】

    老是想着化简,实际上O(n^3)就行了-- 写成生成函数是\( \prod_{i=1}^{n}(1+x^i+2^{2i}+...+x^{ \left \lfloor \frac{n}{i} \righ ...

  7. IT兄弟连 JavaWeb教程 请求转发案例

    CheckServlet类与OutputServlet类之间为请求转发关系.在web.xml文件中,为CheckServlet映射的URL为"/check",为OutputServ ...

  8. GraphicsLab Project学习项目

    作者:i_dovelemon 日期:2016 / 05 / 30 主题:3D,Graphics 引言 进公司以来,主要在学习的就是如何保证代码的质量,以前热爱的图形学也放置了.但是,作为游戏程序员,特 ...

  9. SpringBoot 整合SpringMVC 原理探究

    https://blog.csdn.net/cml_blog/article/details/70196572 Spring Web MVC 的配置 Bean :WebMvcProperties

  10. 接口测试_RESTClient基本使用

    火狐浏览器插件RESTClient基本使用. 消息头: Content-Type : application/x-www-form-urlencoded