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 ...
随机推荐
- bzoj 4300: 绝世好题 dp
4300: 绝世好题 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php ...
- C++ Caption
主题 1. 设置控件的标题文本 2. 获取控件的标题文本 Caption属性 取得一个窗体的标题(caption)文字,或者一个控件的内容 红色的部分就是 Caption 标题 Set ...
- linux 下网站压力测试工具webbench
一直在用webbench ,这个linux下的网站压力测试工具.整理下. 笔记本装的ubuntu,其他linux系统也差不多. webbench 需要先安装 ctags,一个vim的阅读插件,可以直接 ...
- [MODX] 1. Template *
After uploading javascript, css and images to the assets folder. We try to use Template to customize ...
- 如何在Ubuntu 13.04中升级到 GNOME 3.8
如何在Ubuntu 13.04中升级到 GNOME 3.8 添加 GNOME 3 PPA(Personal Package Archives) 在你进一步浏览之前,确认你正在运行的是Ubuntu 13 ...
- zookeeper-3.4.6安装
下载zookeeper包并解压 配置.在conf文件夹中将zoo_sample.cfg复制一份为zoo.cfg 修改zoo.cfg 在/home/admln/zookeeper中新建一个文件myid( ...
- html禁止清除input文本输入缓存
多数浏览器默认会缓存input的值,只有使用ctl+F5强制刷新的才可以清除缓存记录. 如果不想让浏览器缓存input的值,有2种方法: 方法一: 在不想使用缓存的input中添加 autocompl ...
- a code snip
import java.util.ArrayList; import java.util.HashMap; import java.util.regex.Matcher; import java.ut ...
- [django]自定义全局context
1. 创建一个context processor函数 新建一个文件命名为custom_processors.py,把它放到项目app文件夹(例如我的blog文件夹),添加一个返回字典的函数,其代码如下 ...
- CF Two Buttons (BFS)
Two Buttons time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...