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 ...
随机推荐
- 初次用SqlServer查看本地的Excel文件时需要注意的地方
日常用到通过SqlServer 读取Excel文件的案例 ,记录下来 文件路径 :C:\Users\Administrator\Desktop\icd10.xls 1.查询语句: SELECT *F ...
- MAVEN学习总结1
一.安装Maven插件 下载下来的maven插件如下图所示:,插件存放的路径是:E:/MavenProject/Maven2EclipsePlugin
- SpringMVC Controller 介绍(详细深刻)
一.简介 在SpringMVC 中,控制器Controller 负责处理由DispatcherServlet 分发的请求,它把用户请求的数据经过业务处理层处理之后封装成一个Model ,然后再把该Mo ...
- 【转】LVS负载均衡之session解决方案 持久连接
原文地址:http://minux.blog.51cto.com/8994862/1744761 1. 持久连接是什么? 1.1 在LVS中,持久连接是为了用来保证当来自同一个用户的请求时能够定位到同 ...
- 为Vmware里安装的CentOS7.5设置静态IP
[引言]为测试搭建大数据集群环境,采用在Vmware里安装了几台CentOS7.5的虚拟机,在测试过程中,出现启动虚拟机后,虚拟机的IP地址会变,不方便测试集群,所以需要设置静态IP,在此,记录我的设 ...
- Python 网络爬虫 009 (编程) 通过正则表达式来获取一个网页中的所有的URL链接,并下载这些URL链接的源代码
通过 正则表达式 来获取一个网页中的所有的 URL链接,并下载这些 URL链接 的源代码 使用的系统:Windows 10 64位 Python 语言版本:Python 2.7.10 V 使用的编程 ...
- laravel中的attach and detach toggle method
创建模型 post and user 以及 users , posts ,user_post(favorities)测试数据 在此可以看上一篇中的数据,本次测试数据利用的上一篇的数据.detach ...
- Mbatis——动态SQL
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "- ...
- .NET读取服务器或本地文件
//把本地文件信息读入数据流中 FileStream stream = new FileStream(path, FileMode.Open, FileAcces ...
- Python基础入门-数据类型
一.变量 1)变量定义 在python中,我们可以把变量理解为一个值,变量是一个标签名,变量是有对应的一个值. name = 100(name是变量名 = 号是赋值号100是变量的值) 2)变量赋值 ...