HDU 5430:Reflect 欧拉函数
来源:互联网 发布:威斯敏斯特大学 知乎 编辑:程序博客网 时间:2024/06/05 01:47
Reflect
Accepts: 72
Submissions: 302
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
问题描述
从镜面材质的圆上一点发出一道光线反射N次后首次回到起点。问本质不同的发射的方案数。
输入描述
第一行一个整数T,表示数据组数。T≤10对于每一个组,共一行,包含一个整数,表示正整数N(1≤N≤106)。
输出描述
对于每一个组,输出共一行,包含一个整数,表示答案。
输入样例
14
输出样例
4
如果k/(N+1)不是既约分数的话,即可以约分,说明该方案之前出现过,这次只不过所有的线跑了两遍,不符合题目中“首次”回到起点的含义。所以就是求有多少个k符合条件。
代码:
#include <iostream>#include <algorithm>#include <cmath>#include <vector>#include <string>#include <cstring>#pragma warning(disable:4996)using namespace std;int euler(int n){int res = n, a = n;for (int i = 2; i*i <= a; i++){if (a%i == 0){res = res / i*(i - 1);while (a%i == 0)a /= i;}}if (a > 1)res = res / a*(a - 1);return res;}int main(){int test;cin >> test;int n;while (test--){cin >> n;cout << euler(n+1) << endl;}return 0;}
0 0
- hdu 5430 reflect (欧拉函数)
- hdu 5430 Reflect(欧拉函数)
- hdu 5430 Reflect(欧拉函数)
- HDU 5430:Reflect 欧拉函数
- HDU 5430 Reflect 欧拉函数
- HDU 5430-Reflect(欧拉函数求圆内反射方法数)
- HDU 5430 Reflect (欧拉函数) (类似UVA 12493 Stars)
- hdu 5430 Reflect 求圆镜内反射N次回到出口的方法数 欧拉函数
- BC - Reflect(欧拉函数)
- HDU 5430 Reflect
- HDU 5430 Reflect
- hdu 5430 Reflect(数论)
- hdu-1286欧拉函数
- hdu 2588 欧拉函数
- hdu 2824 欧拉函数
- hdu 1787 欧拉函数
- 欧拉函数 hdu 2824
- hdu~3501~欧拉函数
- Android Studio删除module
- After 500: 写了第500篇博客,然后呢?
- 关于Spring中的<idref/>
- UIPickerView 学习
- tcp/ip 连接三次握手,断开四次握手
- HDU 5430:Reflect 欧拉函数
- 电脑上使环境变量立即生效的方法
- JSP九大内置对象
- 百度2015 在线笔试题(3)
- 英语常用口语
- HDU_3416_Marriage Match IV(最短路+最大流)
- Mac下获取AppStore安装包文件路径
- WordPress主题基础
- angularJS中批量提交请求的batch.js(1)