Send a Table UVA

编程入门 行业动态 更新时间:2024-10-28 00:24:22
//欧拉函数打表
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<assert.h>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<sstream>
#include<stack>
#include<queue>
#include<string>
#include<bitset>
#include<algorithm>
#pragma warning(disable:4996)
#define me(s)  memset(s,0,sizeof(s))
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int dr[] = { 0, -1, 0, 1, -1, -1, 1, 1 };
const int dc[] = { -1, 0, 1, 0, -1, 1, -1, 1 };
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-15;
const int maxn = 50000;
int phi[maxn + 1], phi_psum[maxn + 1];void phi_table(int n) {phi[1] = 0;for (int i = 2; i <= n; i++) if (phi[i] == 0)for (int j = i; j <= n; j += i) {if (phi[j] == 0) phi[j] = j;phi[j] = phi[j] / i * (i - 1);}
}int main() {int n;phi_table(maxn);phi_psum[0] = 0;for (int i = 1; i <= maxn; i++)phi_psum[i] = phi_psum[i - 1] + phi[i];while (scanf("%d", &n) == 1 && n)printf("%d\n", 2 * phi_psum[n] + 1);return 0;
}

 

更多推荐

Send,Table,UVA

本文发布于:2023-05-29 21:32:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/353299.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Send   Table   UVA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!