hdu 5430 Reflect (数学推导题)

时间:2022-04-22 19:09:24

Problem Description

We send a light from one point on a mirror material circle,it reflects N times and return the original point firstly.Your task is calcuate the number of schemes.

![](../../data/images/C628--.jpg)
 
Input
First line contains a single integer T(T≤) which denotes the number of test cases. 

For each test case, there is an positive integer N(N≤).
 
Output
For each case, output the answer.
 
Sample Input

 
Sample Output

 
Source
 
 
对应中文题目
问题描述
从镜面材质的圆上一点发出一道光线反射NNN次后首次回到起点。
问本质不同的发射的方案数。
hdu 5430 Reflect (数学推导题)
输入描述
第一行一个整数T,表示数据组数。T≤10T \leq 10T≤10
对于每一个组,共一行,包含一个整数,表示正整数N(1≤N≤106)N(1 \leq N \leq 10^{6})N(1≤N≤10​6​​)。
输出描述
对于每一个组,输出共一行,包含一个整数,表示答案。
输入样例
1
4
输出样例
4

来自官方题解

hdu 5430 Reflect (数学推导题)


 
 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
#define ll long long
ll n;
ll eular(ll n)
{
ll res=;
for(ll i=;i*i<=n;i++)
{
if(n%i==)
{
n/=i,res*=i-;
while(n%i==)
{
n/=i;
res*=i;
}
}
}
if(n>) res*=n-;
return res;
}
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%I64d",&n);
ll ans=eular(n+);
printf("%I64d\n",ans);
}
return ;
}