UVALIVE 7362(欧拉函数)
来源:互联网 发布:网络维修工具包 编辑:程序博客网 时间:2024/05/17 04:19
题目链接:
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5384
题解:
欧拉函数记录所有数据范围内的值,然后加一起就可以了。
AC代码:
#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>using namespace std;int t, number, n;long long int ans;int euler(int x){ int i, res=x; for (i = 2; i < (int)sqrt(x * 1.0) + 1; i++) if(x%i==0) { res = res / i * (i - 1); while (x % i == 0) x /= i; // 保证i一定是素数 } if (x > 1) res = res / x * (x - 1); return res;}int hasaki[10001];int main(){ cin >> t; for(int i = 1; i <= 10000; i++) { hasaki[i] = euler(i); } while(t--) { scanf("%d%d", &number, &n); ans = 0; for(int i = 1; i <= n; i++) ans += hasaki[i]; cout << number << " " <<ans + 1<<endl; } return 0;}
0 0
- UVALIVE 7362(欧拉函数)
- UVALive 7362 Farey (欧拉函数)
- (模板题)UVALive 7362 Farey(欧拉函数)
- UVALive 5964 LCM Extreme(数论 欧拉函数)
- uvalive 10692 欧拉定理
- 51nod - 1136 欧拉函数(欧拉函数)
- 51nod 1136 欧拉函数(欧拉函数)
- 欧拉函数(模板)
- 欧拉函数(转)
- 欧拉函数(一)
- 欧拉函数(二)
- 欧拉函数(数学)
- hdu4556(欧拉函数)
- 欧拉函数(模板)
- 欧拉函数(模板)
- LghtOJ1370(欧拉函数)
- poj2407Relatives(欧拉函数)
- sdoi2008(欧拉函数)
- codeforces 689E
- Android 插入日程到系统日历要注意的3点
- LintCode_206 Interval Sum
- 二级下拉菜单
- LeetCode 143. Reorder List
- UVALIVE 7362(欧拉函数)
- 如何更有效地学习开源项目的代码?
- poj 1001 Exponentiation
- FusionCharts的使用方法
- Jquery 枚举展示
- java集合类深入分析之TreeMap/TreeSet篇
- Log4.properties配置详解
- [线段树] Chef and Array
- ActionResult 返回类型