UvaLive7362 Fare(欧拉函数)
题意:求1~n的素因子之和。
分析:欧拉函数
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#define fin freopen("in.txt", "r", stdin)
#define fout freopen("out.txt", "w", stdout)
#define pr(x) cout << #x << " : " << x << " "
#define prln(x) cout << #x << " : " << x << endl
typedef long long ll;
typedef unsigned long long llu;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const double pi = acos(-1.0);
const double EPS = 1e-;
const int dx[] = {, , -, };
const int dy[] = {-, , , };
const ll MOD = 1e9 + ;
const int MAXN = + ;
const int MAXT = + ;
using namespace std;
int pr[MAXN];
int ps[MAXN];
void init()
{
for(int i = ; i <= ; ++i)
{
int tmp1 = i;
int tmp2 = i;
for(int j = ; j <= i; ++j)
if(tmp2 % j == )
{
tmp1 = tmp1 / j * (j - );
tmp2 /= j;
while(!(tmp2 % j))
tmp2 /= j;
}
pr[i] = tmp1;
}
ps[] = ;
for(int i = ; i <= ; ++i)
ps[i] = ps[i - ] + pr[i];
}
int main()
{
int P;
scanf("%d", &P);
init();
while(P--)
{
int x, n;
scanf("%d%d", &x, &n);
printf("%d %d\n", x, ps[n]);
}
return ;
}
UvaLive7362 Fare(欧拉函数)的更多相关文章
- hdu2588 GCD (欧拉函数)
GCD 题意:输入N,M(2<=N<=1000000000, 1<=M<=N), 设1<=X<=N,求使gcd(X,N)>=M的X的个数. (文末有题) 知 ...
- BZOJ 2705: [SDOI2012]Longge的问题 [欧拉函数]
2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 2553 Solved: 1565[Submit][ ...
- BZOJ 2818: Gcd [欧拉函数 质数 线性筛]【学习笔记】
2818: Gcd Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 4436 Solved: 1957[Submit][Status][Discuss ...
- COGS2531. [HZOI 2016]函数的美 打表+欧拉函数
题目:http://cogs.pw/cogs/problem/problem.php?pid=2533 这道题考察打表观察规律. 发现对f的定义实际是递归式的 f(n,k) = f(0,f(n-1,k ...
- poj2478 Farey Sequence (欧拉函数)
Farey Sequence 题意:给定一个数n,求在[1,n]这个范围内两两互质的数的个数.(转化为给定一个数n,比n小且与n互质的数的个数) 知识点: 欧拉函数: 普通求法: int Euler( ...
- 51Nod-1136 欧拉函数
51Nod: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1136 1136 欧拉函数 基准时间限制:1 秒 空间限制: ...
- 欧拉函数 - HDU1286
欧拉函数的作用: 有[1,2.....n]这样一个集合,f(n)=这个集合中与n互质的元素的个数.欧拉函数描述了一些列与这个f(n)有关的一些性质,如下: 1.令p为一个素数,n = p ^ k,则 ...
- FZU 1759 欧拉函数 降幂公式
Description Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000 ...
- hdu 3307 Description has only two Sentences (欧拉函数+快速幂)
Description has only two SentencesTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- C#用天气预报的WebServices
后台代码: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WeatherWS ws = new W ...
- Spring 中JCA CCI分析--转载
转载地址:http://blog.csdn.net/a154832918/article/details/6790612 J2EE提供JCA(Java Connector Architecture)规 ...
- 网口扫盲三:以太网芯片MAC和PHY的关系
转载:http://www.cnblogs.com/jason-lu/articles/3195473.html 问:如何实现单片以太网微控制器? 答:诀窍是将微控制器.以太网媒体接入控制器(MA ...
- XGPush集成(信鸽集成)
#import "AppDelegate.h" #import "XGPush.h" #import "XGSetting.h" #defi ...
- linux:ifconfig命令
许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...
- python--json & pickle 模块
用于序列化的两个模块 json,用于字符串 和 python数据类型间进行转换 pickle,用于python特有的类型 和 python的数据类型间进行转换 Json模块提供了四个功能:dumps. ...
- css笔记08:id选择器之父子选择器
1.父子选择器 (1)01.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...
- MongoDB,HDFS, Spark to 电影推荐
http://www.infoq.com/cn/news/2014/12/mongdb-spark-movie-recommend MovieWeb是一个电影相关的网站,它提供的功能包括搜索电影信息. ...
- Umbraco入门(一)--在VS中安装Umbraco
在VS中安装Umbraco 由于Vs中自己集成的IIS,所以在安装Umbraco是不用再想以前那么麻烦,需要设置IIS等等…… 使用VS的NuGet程序包管理器 创建一个用空的ASP Web应用程 ...
- 使用 autoconf
在此之前先说一下autooconf在linux下安装的问题,因为不知道怎么安装,我就直接在终端上输入autoconf,结果它会提示是否安装它,下面还有指定安装的方法,我 就直接输入,是什么命令记不住了 ...