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 ...
随机推荐
- delphi 保存网页
保存网页. htmluses ActiveX;procedure TForm1.Button1Click(Sender: TObject);var persist :IPersistfile;beg ...
- ListView上移 和下移
有问题 //ListBox选中的项目移动到第1位 Listbox1.Items.Move(ListBox1.ItemIndex,0); //ListView选中的项目移动到第1 ...
- 保存form配置信息INI
(* 功能:IniFormState1 保存和读取 窗体的大小2 保存和读取 窗体在屏幕上的位置//让程序第1次出现在屏幕的中心点获取屏幕的中心点POSITION:poScreenCenter //不 ...
- Swift学习笔记(一)搭配环境以及代码执行成功
1.Swift是啥? 百度去!度娘告诉你它是苹果最新推出的编程语言,比c,c++,objc要高效简单.可以开发ios,mac相关的app哦!是苹果以后大力推广的语言哦! 2.Swift给你带来什么机会 ...
- iOS开发——图形与动画篇OC篇&图层基本上动画
图层的一些基本动画效果 #define kRadianToDegrees (radian) (radian * 180.0) / (M_PI) //闪烁 [self.testView.layer ad ...
- RPC框架Thrift例子-PHP调用C++后端程序
更新 2016-02-22: Response对象不用主动创建. 前言 前段时间用了一下Facebook的开源RPC框架Thrift,做PHP客户端调用C++后端程序,真心觉得Thrift不错! 本文 ...
- MDI/MDIX接口
转载:http://blog.chinaunix.net/uid-24148050-id-137067.html MDI/MDIX is a type of Ethernet port connect ...
- Eclipse对printf()不能输出到控制台的解决方法
方案1: 在main 语句中加一条 setbuf(stdout,NULL); 这个即可. 在ecplise下使用cdt开发c程序,发现运行后终端没有输出,停止后会输出,通过在main中添加 setbu ...
- 小白日记30:kali渗透测试之Web渗透-扫描工具-Skipfish
WEB渗透-skipfish Skipfish是一个命令行模式,以C语言编写的积极的Web应用程序的安全性侦察工具,没有代理模式. 它准备了一个互动为目标的网站的站点地图进行一个递归爬网和基于字典的探 ...
- [Android]自定义dialog
吃过饭,有没有太写代码的愿望,就开始想今天工作中遇到的问题了. 有一个很有意思的东西就是Dialog,这个是基础的组件: 我们会在一些地方需要自定义弹出窗,可是用popUpWindow太小题大作,用弹 ...