#include<stdio.h>
#include<string.h>
#define N 50010
int phi[N],n,sum[N];
void phi_table()
{
int i,j;
memset(phi,,sizeof(phi));
phi[]=;
for(i=;i<=N;i++)
if(!phi[i])
for(j=i;j<=N;j+=i) /*筛法求欧拉函数值*/
{
if(!phi[j])
phi[j]=j;
phi[j]=phi[j]/i*(i-);
/*phi[j]保存不超过j且与j互质的正整数的个数*/
}
sum[]=;
for(i=;i<=;i++)
sum[i]=sum[i-]+phi[i];
} int main()
{
phi_table();
int i;
while(~scanf("%d",&n)&&n)
{
printf("%d\n",*sum[n]-);
}
return ;
}
/*转化为有多少对时,2与1互质,但是(2,1)和(1,2)算2对,
所以应该乘以2,但是(1,1)被算了两次,所以减去一次*/

交表(Send a Table)的更多相关文章

  1. UVA10820 交表 Send a Table

    \(\Large\textbf{Description:} \large{输入n,求有多少个二元组(x,y)满足:1\leqslant x,y\leqslant n,且x和y互素.}\) \(\Lar ...

  2. Berkeley DB的数据存储结构——哈希表(Hash Table)、B树(BTree)、队列(Queue)、记录号(Recno)

    Berkeley DB的数据存储结构 BDB支持四种数据存储结构及相应算法,官方称为访问方法(Access Method),分别是哈希表(Hash Table).B树(BTree).队列(Queue) ...

  3. UVa10820 Send a Table[欧拉函数]

    Send a TableInput: Standard Input Output: Standard Output When participating in programming contests ...

  4. 聚簇(Cluster)和聚簇表(Cluster Table)

    聚簇(Cluster)和聚簇表(Cluster Table) 时间:2010-03-13 23:12来源:OralanDBA.CN 作者:AlanSawyer 点击:157次 1.创建聚簇 icmad ...

  5. UVA 10820 - Send a Table 数论 (欧拉函数)

    Send a Table Input: Standard Input Output: Standard Output When participating in programming contest ...

  6. UVA 10820 Send a Table euler_phi功能

    除1,1其他外国x,y不等于 为 x<y 案件 一切y有phi(y)组合 F[x]= phi(i) 2<=i<=x 结果为 2*F[x]+1 Problem A Send a Tab ...

  7. MySQL 建表语句 create table 中的列定义

    MySQL 建表语句 create table 中的列定义: column_definition: data_type [NOT NULL | NULL] [DEFAULT default_value ...

  8. 哈希表(Hash Table)原理及其实现

    原理 介绍 哈希表(Hash table,也叫散列表), 是根据关键码值(Key value)而直接进行访问的数据结构.也就是说,它通过把关键码值映射到表中一个位置来访问记录,以加快查找的速度.这个映 ...

  9. 表优化 altering table OPTIMIZE TABLE `sta_addr_copy`

    表优化 altering table OPTIMIZE TABLE `sta_addr_copy` [总结] 1.实际测试的结果是,在state sqlaltering table OPTIMIZE ...

  10. Hash表(hash table ,又名散列表)

    直接进去主题好了. 什么是哈希表? 哈希表(Hash table,也叫散列表),是根据key而直接进行访问的数据结构.也就是说,它通过把key映射到表中一个位置来访问记录,以加快查找的速度.这个映射函 ...

随机推荐

  1. 龙书D3D11章节习题答案(第四章)

    下面答案仅供參考,有错欢迎留言. Chapter 4:Direct3D Initialzation    1. Modify the previous exercise solution by dis ...

  2. 浏览器开发者工具Chrome Developer Tool

    开发者工具Chrome Developer Tool https://developers.google.com/chrome-developer-tools/docs/profiles   一直被墙 ...

  3. Python - colour-science库

    http://nbviewer.jupyter.org/github/colour-science/colour-ipython/blob/master/notebooks/colour.ipynb# ...

  4. ElasticDownload

    https://github.com/eltld/ElasticDownload

  5. ShopMall

    https://github.com/KingsleyYau/ShopMall-Android https://github.com/KingsleyYau/ShopMall-iOS https:// ...

  6. TestNG demo

    下载TestNG的归档文件 下载最新版本的TestNG的jar文件,详细请点击访问 http://www.testng.org..在写这篇教程的时候,我下载TestNG中-6.8.jar,并将 tes ...

  7. [Selenium]通过Selenium实现在当前浏览器窗口点击一个图标之后,弹出另外一个窗口,关闭这个窗口,再回到原来的窗口进行操作

    public void clickReportIcon(){ String initialWindowHandle = driver.getWindowHandle(); //保存原始的浏览器窗口 p ...

  8. XHTML中button加入超链接以及使插入图片与屏幕一样大

    1.button加入超链接 (1)假设是在本页跳转到新页面.用 <span style="font-size:18px;"><input type="b ...

  9. 尝试使用UISearchDisplayController及对苹果对控件封装习惯的理解

    本文转载至 http://blog.sina.com.cn/s/blog_74e9d98d01019vji.html   在之前做过的应用中,很多都有“搜索”这个功能,大部分情况下我都是只采用UISe ...

  10. JavaScript重点记忆

    String的常用方法 indexOf() 返回字符串中检索指定字符第一次出现的位置 lastIndexOf() 返回字符串中检索指定字符最后一次出现的位置 match() 找到一个或多个正则表达式的 ...