题意:问在一个圆形的镜面里,从任意一点发出一个光源,经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的更多相关文章

  1. HDU 5430 Reflect(欧拉函数)

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=5430 从镜面材质的圆上一点发出一道光线反射NNN次后首次回到起点. 问本质不同的发射的方案数. 输入描述 ...

  2. hdu 5430 Reflect (数学推导题)

    Problem Description We send a light from one point on a mirror material circle,it reflects N times a ...

  3. HDU 5430:Reflect 欧拉函数

    Reflect  Accepts: 72  Submissions: 302  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/ ...

  4. hdu 5279 Reflect phi 欧拉函数

    Reflect Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/contest_chi ...

  5. hdu 5430(几何)

    题意:求光在圆内反射n次后第一次返回原点的方案数 如果k和n-1可约分,则表明是循环多次反射方案才返回原点. #include <iostream> #include <cstrin ...

  6. HDU 5835 Danganronpa(弹丸论破)

     Danganronpa(弹丸论破) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  7. HDU 5835 Danganronpa (贪心)

    Danganronpa 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5835 Description Chisa Yukizome works as ...

  8. 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 ...

  9. HDU 3586.Information Disturbing 树形dp 叶子和根不联通的最小代价

    Information Disturbing Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/ ...

随机推荐

  1. c++ 虚继承与继承的差异 (转)

    转自:CSDN dqjyong 原文链接:http://blog.csdn.net/dqjyong/article/details/8029527 前面一篇文章,说明了在C++ 虚继承对基类构造函数调 ...

  2. POJ2104 k-th number 划分树

    又是不带修改的区间第k大,这次用的是一个不同的方法,划分树,划分树感觉上是模拟了快速排序的过程,依照pivot不断地往下划分,然后每一层多存一个toleft[i]数组,就可以知道在这一层里从0到i里有 ...

  3. ibaits与spring整合的心得

    Ibatis2.3与spring3.0整合,其要明确一下,Ibatis与Hibernate一样都是dao层链接数据库用的框架.它是一个轻量级的orm框架,比Hibernate更加灵活. sqlMapC ...

  4. compiler 学习

    一款强大的编译器LLVM:http://llvm.org/docs/GettingStarted.html#layout http://llvm.org/docs/LangRef.html http: ...

  5. 80. Remove Duplicates from Sorted Array II

    题目: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For ex ...

  6. NSDate & NSDateFormatter

    #import <Foundation/Foundation.h>   int main(int argc, const char * argv[]) {    @autoreleasep ...

  7. Javaweb实现的优优图书商城(含源码)

    原文地址:http://www.cnblogs.com/liaoyu/p/uushop.html 源码地址:https://github.com/liaoyu/uushop 贴出一个大学时做的小项目, ...

  8. Android PullToRefreshExpandableListView的点击事件

    这几天做项目的时候用到了一个开源的下拉刷新的框架(需要的朋友可以加我Q:359222347).其中我使用PullToRefreshExpandableListView的时候发现这个东西没有setOnC ...

  9. mysql优化 mysql explain

    一篇文章: 使用use index优化sql查询   先看一下arena_match_index的表结构,大家注意表的索引结构CREATE TABLE `arena_match_index` (  ` ...

  10. Android Activity形象描述

    Activity就是形象的说就是一个容器,在里面放置各种控件(按钮,文本,复选框等),就形成了软件的界面~ Activity是可见的,如果不加任何控件的话,那么就像Windows中的空白窗体一样 通过 ...