hdu 5279 Reflect phi 欧拉函数
Reflect
Time Limit: 1 Sec
Memory Limit: 256 MB
题目连接
http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=628&pid=1003
Description
从镜面材质的圆上一点发出一道光线反射NN次后首次回到起点。
问本质不同的发射的方案数。
Input
第一行一个整数T,表示数据组数。T \leq 20T≤20
对于每一个组,第一行一个整数n(1 \leq n \leq 100)n(1≤n≤100),接下来第二行nn个数允许前导零的非负整数A_iAi,表示数列。保证A_iAi位数\leq 100≤100。
Output
对于每一个组,输出共一行,包含一个整数,表示答案。
Sample Input
1 4
Sample Output
4
HINT
题意
题解:
暴力打表就好了
然后发现是欧拉函数phi
然后猜了一发结论交了一发
AC了
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long LL;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
const int inf=0x7fffffff; //无限大
/* */
//**************************************************************************************
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
LL phi[maxn],n;
void phi1()
{
memset(phi,,sizeof(phi));
phi[]=;
for(LL i=;i<=n;i++)
{
if(!phi[i])
{
for(LL j=i;j<=n;j+=i)
{
if(!phi[j]) phi[j]=j;
phi[j]=phi[j]/i*(i-);
}
}
}
}
int main()
{
int t=read();
n=;
phi1();
while(t--)
{
int x=read();
cout<<phi[x+]<<endl;
}
}
hdu 5279 Reflect phi 欧拉函数的更多相关文章
- HDU 5430 Reflect(欧拉函数)
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5430 从镜面材质的圆上一点发出一道光线反射NNN次后首次回到起点. 问本质不同的发射的方案数. 输入描述 ...
- HDU 1695 GCD(欧拉函数+容斥原理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1695 题意:x位于区间[a, b],y位于区间[c, d],求满足GCD(x, y) = k的(x, ...
- HDU 1695 GCD (欧拉函数+容斥原理)
GCD Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- hdu 3501 Calculation 2 (欧拉函数)
题目 题意:求小于n并且 和n不互质的数的总和. 思路:求小于n并且与n互质的数的和为:n*phi[n]/2 . 若a和n互质,n-a必定也和n互质(a<n).也就是说num必定为偶数.其中互质 ...
- hdu 2814 快速求欧拉函数
/** 大意: 求[a,b] 之间 phi(a) + phi(a+1)...+ phi(b): 思路: 快速求欧拉函数 **/ #include <iostream> #include & ...
- Master of Phi (欧拉函数 + 积性函数的性质 + 狄利克雷卷积)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6265 题目大意:首先T是测试组数,n代表当前这个数的因子的种类,然后接下来的p和q,代表当前这个数的因 ...
- hdu 3501 容斥原理或欧拉函数
Calculation 2 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- 题解报告:hdu 2588 GCD(欧拉函数)
Description The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written ...
- HDU 1787 GCD Again(欧拉函数,水题)
GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
随机推荐
- K2 blackpearl 流程开发(一)
转:http://blog.csdn.net/gxiangzi/article/details/8444060 郁闷,今天K2的license过期了,很多东西都没法用了,还得去找PM大大帮忙申请一个. ...
- ch02-HTML的基本概念
HTML的基本概念 Ch02: HTML的基本概念 1, 标记: 每一组HTML标记,都会被放在"<>"里面,用于控制里面的文字显示效果及其它一些用途. 语法: 开始标 ...
- HDU 5858 Hard problem
Hard problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- Android的SoundPool
开发Android软件中我们可能经常需播放多媒体声音文件,一般使用MediaPlayer类但该类占用资源较多,对于游戏等应用可能不是很适合,SoundPool类在SDK的android.media.S ...
- CCCallFuncN误用导致引用计数循环引用
昨天测试“角色被遮挡部分透明显示”功能时,发现角色死亡后,其轮廓精灵不会消失.调试发现,角色在死亡时,其引用计数retain_count居然是9.这是由引用计数混乱引起的内存泄露. 加了很多日志跟踪r ...
- bzoj 2134 单选错位(期望)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2134 [题意] ai与ai+1相等得1分,求期望. [思路] 每个题的期望都是独立的. ...
- oc_转_NSArrray 和 NSMutableArrray
Objective C 中除了可以使用C中的基本数组外,如 int[5];,char word[] = {‘a’, 'b’, 'c’};,Foundation 还提供了 NSArray 类.Found ...
- JAVA中的数据结构——集合类(线性表:Vector、Stack、LinkedList、set接口;键值对:Hashtable、Map接口<HashMap类、TreeMap类>)
Java的集合可以分为两种,第一种是以数组为代表的线性表,基类是Collection:第二种是以Hashtable为代表的键值对. ... 线性表,基类是Collection: 数组类: person ...
- linux常用命令[持续更新]
top 察看系统状态,退出按q ps -A 察看所有进程 ps -A|grep gcalc|awk '{print $1}'|xargs kill 杀掉所有gcalc进程
- 个人思考:能否sub.prototye=sup.prototype实现继承
var Sup=function(name){ this.name=name; }; var Sub=function(name){ this.name=name; }; Sup.prototype. ...
