GCD - Extreme (II) UVA - 11426 数学
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 4000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii; inline int rd() {
int x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int phi[maxn];
void init() {
for (int i = 2; i <= maxn; i++)phi[i] = 0;
phi[1] = 1;
for (int i = 2; i <= maxn; i++) {
if (!phi[i]) {
for (int j = i; j <= maxn; j += i) {
if (!phi[j])phi[j] = j;
phi[j] = phi[j] / i * (i - 1);
}
}
}
} ll sum[maxn], f[maxn]; int main() {
// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
init();
for (int i = 1; i <= maxn; i++) {
for (int j = i * 2; j <= maxn; j += i)f[j] += i * phi[j / i];
}
sum[2] = f[2];
for (int j = 3; j <= maxn; j++)sum[j] = sum[j - 1] + f[j];
int n;
while (rdint(n) == 1&&n) {
printf("%lld\n", sum[n]);
}
return 0;
}
GCD - Extreme (II) UVA - 11426 数学的更多相关文章
- GCD - Extreme (II) UVA - 11426 欧拉函数_数学推导
Code: #include<cstdio> using namespace std; const int maxn=4000005; const int R=4000002; const ...
- GCD - Extreme (II) UVA - 11426(欧拉函数!!)
G(i) = (gcd(1, i) + gcd(2, i) + gcd(3, i) + .....+ gcd(i-1, i)) ret = G(1) + G(2) + G(3) +.....+ G(n ...
- GCD - Extreme (II) UVA - 11426 欧拉函数与gcd
题目大意: 累加从1到n,任意两个数的gcd(i,j)(1=<i<n&&i<j<=n). 题解:假设a<b,如果gcd(a,b)=c.则gcd(a/c,b ...
- F - GCD - Extreme (II) UVA - 11426
Given the value of N, you will have to find the value of G. The definition of G is given below:
- UVA 11426 - GCD - Extreme (II) (数论)
UVA 11426 - GCD - Extreme (II) 题目链接 题意:给定N.求∑i<=ni=1∑j<nj=1gcd(i,j)的值. 思路:lrj白书上的例题,设f(n) = gc ...
- UVA 11426 GCD - Extreme (II) (欧拉函数)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Problem JGCD Extreme (II)Input: Standard ...
- 【UVa11426】GCD - Extreme (II)(莫比乌斯反演)
[UVa11426]GCD - Extreme (II)(莫比乌斯反演) 题面 Vjudge 题解 这.. 直接套路的莫比乌斯反演 我连式子都不想写了 默认推到这里把.. 然后把\(ans\)写一下 ...
- UVA11426 GCD - Extreme (II) (欧拉函数/莫比乌斯反演)
UVA11426 GCD - Extreme (II) 题目描述 PDF 输入输出格式 输入格式: 输出格式: 输入输出样例 输入样例#1: 10 100 200000 0 输出样例#1: 67 13 ...
- GCD - Extreme (II) for(i=1;i<N;i++) for(j=i+1;j<=N;j++) { G+=gcd(i,j); } 推导分析+欧拉函数
/** 题目:GCD - Extreme (II) 链接:https://vjudge.net/contest/154246#problem/O 题意: for(i=1;i<N;i++) for ...
随机推荐
- Bootstrap 概览
目录1.移动设备2.响应式图片3.Normalize4.Containers 1.移动设备在Bootstrap 3中,我们重写了整个框架,使其一开始就是对移动设备友好的.这次不是简单的增加一些可选的针 ...
- 数论Keynote
[同余] 1.整数a,b对模m同余的充分与必要条件是m|(a-b),即a=b+mt,t是整数. 2.性质丁.若a1=b1(mod m),a2=b2(mod m),则(a1+a2)=(b1+b2)(mo ...
- 更新solrcloud+zookeeper的配置文件,要reload collection
1.用的lib下的solr-core-4.3.1jar中的ZkCLI工具,命令在solr(web发布的)同级目录下运行. (1)upconfig 更新配置文件命令 java -classpath ./ ...
- 认识WebRoot和WebContent目录
1.webRoot是不需要加的,因为它是默认的JSP目录,完整的路径应该是:项目名/xxx.jsp,如果在webroot下边建立了文件夹abc,又在abc中建立了xxx.jsp那么此时的路径应为htt ...
- [luogu3391] 【模板】文艺平衡树(fhq-treap反转区间)
解题关键:无旋treap模板. #include<iostream> #include<cstdio> #include<cstring> #include< ...
- springBoot集成 quartz动态定时任务
项目中需要用到定时任务,考虑了下java方面定时任务无非就三种: 用Java自带的timer类.稍微看了一下,可以实现大部分的指定频率的任务的调度(timer.schedule()),也可以实现关闭和 ...
- nginx+django+uwsgi
最近来了兴致,想搞一下django开发,so, 搭建一下环境 1.安装django,可能通过pip install 或者源码安装(因为环境是python2.6.6的环境,所以这里采用django 1 ...
- linux下方便的录屏命令
linux下方便的录屏命令 ffmpeg -f x11grab -s 1024*768 -r 20 -i :0.0 -sameq ~/recode.mpg -r后是刷新屏率, 推出直接Ctrl ...
- Jlabel实现内容自动换行
Jlabel实现内容自动换行 摘自:https://blog.csdn.net/zhhtao89/article/details/50179695 2015年12月04日 21:09:27 阅读数 ...
- javascript总结15:Break语句 与 continue语句
1 Break语句 解释:在循环体内,只要代码遇到break,程序立马结束当前循环. 当前循环指的是break语句所在的循环体. for (var i =1; i<10; i++){ if(i% ...