题意:你懂得。

析:一看这个题应该是欧拉phi函数,也就说欧拉phi函数是指求从 1 到 n 中与 n 互素的数的个数,这个题很明显是这个意思嘛,不多说了。

代码如下:

#include <iostream>
#include <cstdio>
#include <cstring> using namespace std;
const int maxn = 32768 + 5;
int phi[maxn+5]; void phi_table(int n){
memset(phi, 0, sizeof(phi));
phi[1] = 1;
for(int i = 2; i <= n; ++i) if(!phi[i])
for(int j = i; j <= n; j += i){
if(!phi[j]) phi[j] = j;
phi[j] = phi[j] / i * (i-1);
}
} int main(){
phi_table(maxn);
int n, T; cin >> T;
while(T--){
scanf("%d", &n);
printf("%d\n", phi[n]);
}
return 0;
}

HDU 1286 找新朋友 (欧拉phi函数打表)的更多相关文章

  1. hdu 1286 找新朋友 欧拉函数模版题

    找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Des ...

  2. hdu 1286 找新朋友 (欧拉函数)

    找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  3. HDU 1286 找新朋友 (欧拉公式或者标记法(其实就是欧拉公式的思想))

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1286 找新朋友 Time Limit: 2000/1000 MS (Java/Others)    M ...

  4. hdu 1286:找新朋友(数论,欧拉函数)

    找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  5. HDU——1286找新朋友(欧拉函数+质数打表)

    找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  6. hdu-1286 找新朋友(欧拉函数,水题)

    题目链接: 找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  7. hdu 1286 找新朋友 (欧拉函数)

    Problem Description 新年快到了,"猪头帮协会"准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的 ...

  8. hdu 1286 找新朋友 (容斥原理 || 欧拉函数)

    Problem - 1286 用容斥原理做的代码: #include <cstdio> #include <iostream> #include <algorithm&g ...

  9. hdu 1286 找新朋友(欧拉函数)

    题意:欧拉函数 思路:欧拉函数 模板,代码略.

随机推荐

  1. 使用C#的两种方式OracleClient组件和OleDB组件连接ORACLE数据库

    一.使用OracleClient组件连接Oracle .Net框架的System.Data.OracleClient.dll组件(ADO.Net组件),为连接和使用Oracle数据库提供了很大的方便. ...

  2. 949. Largest Time for Given Digits

    Given an array of 4 digits, return the largest 24 hour time that can be made. The smallest 24 hour t ...

  3. Chrome 上传时打开对话框非常慢

    Chrome 上传时打开对话框非常慢 先说解决方法,将 Chrome 中这个选项关闭,打开会飞快. 如果只是图片之类是不会的,但是有 zip apk 之类的就会慢. 主要原因还是 Chrome 太安全 ...

  4. [CLPR] 卷积神经网络的结构

    本文翻译自: http://www.codeproject.com/Articles/16650/Neural-Network-for-Recognition-of-Handwritten-Digi ...

  5. asm335x系列adc和触摸屏驱动(转)

    An analog-to-digital converter (abbreviated ADC) is a device that uses sampling to convert a continu ...

  6. open_input_file函数调用结构图(转)

    open_input_file函数调用结构图(有些重复的函数调用就略掉了,大致是按流程往下的). 函数大致说明: AVFormatContext *avformat_alloc_context(voi ...

  7. sql server利用cte递归查询

    1.数据环境准备 参考Oracle递归查询文章. 2.查询某个节点下的所有子节点 with cte(id,name,parent_id) as ( select id,name,parent_id f ...

  8. java HttpClient 获取页面Cookie信息

    HttpClient client = new HttpClient(); GetMethod get=new GetMethod("http://www.baidu.com"); ...

  9. ubuntu 下出现E: Sub-process /usr/bin/dpkg returned an error code

    在用apt-get安装软件时出现了类似于 install-info: No dir file specified; try –help for more information.dpkg:处理 get ...

  10. id取模分表

    场景 1 假设按用户id分2个库 每个库分10张表. 分表策略 1.用户id%2 确定库  用户id%3确定表. 2.(用户id%(2*10))/ 10  取整确定库,(用户id%(2*10)%10确 ...