/* 交表 _________________________________________________________________________________

                                                                               #include <iostream>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
#define fir first
#define sec second
#define pb(x) push_back(x)
#define mem(A, X) memset(A, X, sizeof A)
#define REP(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define rep(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))
#define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
typedef long long LL;
typedef unsigned long long ull;
typedef pair<long,long> pll; LL T,n;
const int mod=1e9+7;
const int maxn=1e5+10; const int size=50000;//1-10000的表
int phi[size+1];
void phi_table() // 1 到 n 的欧拉phi函数值表 ( O( nlg(lgn) ) )
{
for(int i=2;i<=size;i++)
{
phi[i]=0;
}
phi[1]=1;
for(int i=2;i<=size;i++)
{
if(!phi[i])
{
for(int j=i;j<=size;j+=i)
{
if(!phi[j]) phi[j]=j;
phi[j] = phi[j]/i*(i-1);
}
}
}
} int main()
{
freopen("in.txt","r",stdin);
phi_table();
while(cin>>n&&n)
//while(cin>>T)
{
//REP(kase,1,T) { }
LL ans=1;
REP(i,2,n)
ans+=2*phi[i];
cout<<ans<<endl; }
return 0;
} /*
note :
debug :
optimize:
*/

uva 10820的更多相关文章

  1. Uva 10820 交表

    题目链接:https://uva.onlinejudge.org/external/108/10820.pdf 题意: 对于两个整数 x,y,输出一个函数f(x,y),有个选手想交表,但是,表太大,需 ...

  2. UVa 10820 - Send a Table(欧拉函数)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  3. UVa 10820 (打表、欧拉函数) Send a Table

    题意: 题目背景略去,将这道题很容易转化为,给出n求,n以内的有序数对(x, y)互素的对数. 分析: 问题还可以继续转化. 根据对称性,我们可以假设x<y,当x=y时,满足条件的只有(1, 1 ...

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

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

  5. uva 10820 (筛法构造欧拉函数)

    send a table When participating in programming contests, you sometimes face the following problem: Y ...

  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. UVA 10820 欧拉函数模板题

    这道题就是一道简单的欧拉函数模板题,需要注意的是,当(1,1)时只有一个,其他的都有一对.应该对欧拉函数做预处理,显然不会超时. #include<iostream> #include&l ...

  8. UVa 10820 - Send a Table

    题目:找到整数区间[1.n]中全部的互质数对. 分析:数论,筛法,欧拉函数.在筛素数的的同一时候.直接更新每一个数字的欧拉函数. 每一个数字一定会被他前面的每一个素数筛到.而欧拉函数的计算是n*π(1 ...

  9. Uva 10820 Send a Table(欧拉函数)

    对每个n,答案就是(phi[2]+phi[3]+...+phi[n])*2+1,简单的欧拉函数应用. #include<iostream> #include<cstdio> # ...

随机推荐

  1. windows7 64位系统pl/sql 客户端的安装

    解压将下载到的将其解压,如我解压到了 E:\app\instantclient_11_2 3.设置PLSQL Developer在tools-prefrences,conncetion,OCI lib ...

  2. Y+的查看及FLUENT壁面函数的选择

    y+的查看 其实,我们关心的应该是壁面y+值.那么我们看云图的话,是可以直接看到的,但是个人感觉,如果case大的话,也不是很方便.此外,你要是看云图的话,要用filled的方式,而且把node va ...

  3. spark-sql性能测试

    一,测试环境       1) 硬件环境完全相同:              包括:cpu/内存/网络/磁盘Io/机器数量等       2)软件环境:              相同数据       ...

  4. ubuntu的一些操作

    1.修改ubuntu的grub启动选择菜单 需要修改到文件为 /boot/grub/grub.cfg 命令: sudo gedit /boot/grub/grub.cfg 修改默认启动项:set de ...

  5. redis缓存技术学习

    1 什么是redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串). list(链表).set(集合)和zset ...

  6. boost和C++11中的sleep

    boost boost线程中表示睡眠的函数有sleep和sleep_for sleep 例如: boost::this_thread::sleep(boost::posix_time::seconds ...

  7. Python的平凡之路(19)

    一.Django请求生命周期   对于所有的web框架来说本质就是一个socket服务端,浏览器是socket客户端                                          ...

  8. Mac下使用firefoxdriver

    Mac使用Firefox浏览器只需要设置WebDriver driver = new FirefoxDriver(),不需要安装firefoxdriver,前提是你的Firefox被安装在默认的位置. ...

  9. std::vector<bool>中的坑

    http://www.cplusplus.com/reference/vector/vector/?kw=vector C++中,vector<bool>为了达到节省内存的目的,专门做了特 ...

  10. 如何注册OCX控件

    32位系统: 将文件放到c:\windows\system目录 注册 运行:Regsvr32 c:\windows\system\xxx.ocx 取消注册运行:Regsvr32.exe /u c:\w ...