LightOJ 1007 Mathematically Hard
来源:互联网 发布:重置sql密码用户名 编辑:程序博客网 时间:2024/05/16 10:11
题意:求a~b的欧拉函数值的平方和
先预处理出1~5e6的欧拉函数值,再预处理出前缀平方和就OK
要注意空间限制,一不小心就炸空间
要注意数据范围,会爆long long
#include <bits/stdc++.h>const int MAXN = 5e6 + 5;unsigned long long phi[MAXN];bool get_phi(){ phi[0] = phi[1] = 0; for(int i = 2; i < MAXN; i++) phi[i] = i; for(int i = 2; i < MAXN; i++) if(phi[i] == i) for(int j = i; j < MAXN; j += i) phi[j] = phi[j] / i * (i - 1);}int main(){ get_phi(); for(int i = 2; i < MAXN; i++) phi[i] = phi[i - 1] + phi[i] * phi[i]; int T; scanf("%d", &T); for(int ca = 1; ca <= T; ca++) { int a, b; scanf("%d%d", &a, &b); printf("Case %d: %llu\n", ca, phi[b] - phi[a - 1]); } return 0;}
0 0
- LightOJ 1007 Mathematically Hard
- LightOJ 1007 Mathematically Hard
- lightoj 1007 - Mathematically Hard 欧拉函数
- lightoj 1007 - Mathematically Hard 欧拉函数
- LightOJ 1007 Mathematically Hard 欧拉函数
- LightOJ-1007-Mathematically Hard [欧拉函数]
- Mathematically Hard LightOJ
- LIGHTOJ 1007 – MATHEMATICALLY HARD【欧拉函数】
- LightOJ 1007 - Mathematically Hard (欧拉筛+预处理前缀和)
- lightoj 1007Mathematically Hard (欧拉函数水题)
- Light OJ 1007 - Mathematically Hard
- Light oj 1007 - Mathematically Hard
- LightOJ1007 - Mathematically Hard
- LightOJ1007 Mathematically Hard
- light oj 1007 Mathematically Hard (欧拉函数)
- light oj 1007 Mathematically Hard (欧拉函数)
- Light OJ 1007 Mathematically Hard [欧拉函数+前缀和]【数论】
- Mathematically Hard (欧拉定理)
- spring数据源配置
- (原创)一般矩阵 Matrix类
- 《leetCode》:N-Queens(奇葩的测试平台,居然不能AC)
- Objective-C运行时定义的几种重要的类型
- Objective-c:内存管理
- LightOJ 1007 Mathematically Hard
- 欢迎使用CSDN-markdown编辑器
- 【python】xml Elementtree 学习一
- [js学习笔记]城市选择控件(双下拉框选择不同城市列表)
- LayoutInflater
- 将maven项目自动部署至私有nexus maven仓库
- 【南大软院大神养成计划:第一天】种下21天,收获不一样的自己——前端养成启程!
- lightoj1210Efficient Traffic System
- iOS宏定义