HDU 5430 Reflect
题意:问在一个圆形的镜面里,从任意一点发出一个光源,经n次反射回到起点的情况数是多少。
解法:直接贴题解吧……

求1至N+1中与N+1互质的个数,即欧拉函数。
代码:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long using namespace std; int eular(int n)
{
int ret = 1;
for(int i = 2; i * i <= n; i++)
{
if(n % i == 0)
{
n /= i;
ret *= i - 1;
while(n % i == 0)
{
n /= i;
ret *= i;
}
}
}
if(n > 1)
ret *= n - 1;
return ret;
}
int main()
{
int T;
while(~scanf("%d", &T))
{
while(T--)
{
int n;
scanf("%d", &n);
printf("%d\n", eular(n + 1));
}
}
return 0;
}
HDU 5430 Reflect的更多相关文章
- HDU 5430 Reflect(欧拉函数)
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5430 从镜面材质的圆上一点发出一道光线反射NNN次后首次回到起点. 问本质不同的发射的方案数. 输入描述 ...
- hdu 5430 Reflect (数学推导题)
Problem Description We send a light from one point on a mirror material circle,it reflects N times a ...
- HDU 5430:Reflect 欧拉函数
Reflect Accepts: 72 Submissions: 302 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/ ...
- hdu 5279 Reflect phi 欧拉函数
Reflect Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/contest_chi ...
- hdu 5430(几何)
题意:求光在圆内反射n次后第一次返回原点的方案数 如果k和n-1可约分,则表明是循环多次反射方案才返回原点. #include <iostream> #include <cstrin ...
- HDU 5835 Danganronpa(弹丸论破)
Danganronpa(弹丸论破) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU 5835 Danganronpa (贪心)
Danganronpa 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5835 Description Chisa Yukizome works as ...
- 2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】
Dying Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tot ...
- HDU 3586.Information Disturbing 树形dp 叶子和根不联通的最小代价
Information Disturbing Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/ ...
随机推荐
- WAF安恒
http://wenku.baidu.com/view/c242927f581b6bd97e19ea1a.html?from=search
- 李洪强漫谈iOS开发[C语言-007]-语言标准简介
C语言是介于低级语言和高级语言之间的 一个应用程序 C语言在嵌入式上使用,的确是具有低级语言的特征 直接操作硬件,扫描内存 访问到的都是虚拟内存,一个应用程序占多大内存? 表示最多 可以放多少条指令 ...
- eclipse的设置和优化
转载:http://my.oschina.net/zhaoqian/blog/66545 1.eclipse下的编码设置: eclipse 中使用模板新建 JSP,xhtml等 文件时,默认的编码为: ...
- spring autoWire注解和@resource注解区别
1.autoWire注解主要是按类型匹配.因为autowire的扫描机制,是按照接口类型来扫描bean的. 而JSR250 @resource注解是通过名称扫描注入的. @autowire注解的扫描方 ...
- 利用python 获取 windows 组策略
工作中有时候会有这种需求: 1. 自动配置组策略的安全基线,这个东西不用你自己写了,微软有这个工具,Microsoft Security Compliance Manager,你可以在下面的地址去下载 ...
- 2014-9-17二班----6 web project
部署 加载 到 Tomcat 6.0 服务器上 web.xml <welcome>index.jsp </welcome> <welcome&g ...
- ASP.NET MVC 4 (一)路径映射
原文:ASP.NET MVC 4 (一)路径映射 正如ASP.NET MVC名字所揭示的一样,是以模型-视图-控制设计模式构建在ASP.NET基础之上的WEB应用程序,我们需要创建相应的程序类来协调处 ...
- 68. Text Justification
题目: Given an array of words and a length L, format the text such that each line has exactly L charac ...
- Linux下安装、配置、启动Apache
http://www.cnblogs.com/zhuque/archive/2012/11/03/2763352.html#
- 如何禁用 radio ,设置为只读,不能选定
如何禁用 radio ,设置为只读,不能选定 禁用 radio ,设置为只读,不能选定: <input name="gender" type="radio" ...