hdoj 5392 Infoplane in Tina Town
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5392
#include<stdio.h> #include<cstring> #include<cmath> #include<algorithm> #include<set> using namespace std; *1e6+; ; int n, T; int a[MAXN]; int vis[MAXN]; int num[MAXN]; int tmp; int t; int ct; long long ans; set<int>s; set<int>::iterator it; int cnt[MAXN]; int main(){ scanf("%d",&T); while(T--){ t = ; scanf("%d",&n); ; i <= n; ++i){ scanf("%d",&a[i]); } memset(vis,,sizeof(vis)); ; i <= n; ++i){ ) continue; tmp = a[a[i]]; num[t] = ; while( a[i] != tmp ){ vis[tmp] = ; tmp = a[tmp]; num[t]++; } vis[tmp] = ; t++; } memset(cnt,,sizeof(cnt)); ans = ; ; i < t; ++i){ ; d <= num[i]; ++d){ ct = ; ){ num[i] = num[i] / d; ct++; } s.insert(d); cnt[d] = max(cnt[d],ct); } } for(it = s.begin();it!=s.end();++it){ ans = ans*pow((*it),cnt[*it]); ans %= MOD; } printf("%I64d\n",ans); } }
hdoj 5392 Infoplane in Tina Town的更多相关文章
- HDU 5392 Infoplane in Tina Town
Infoplane in Tina Town Time Limit: 14000/7000 MS (Java/Others) Memory Limit: 524288/524288 K (Jav ...
- hdu 5392 Infoplane in Tina Town(数学)
Problem Description There is a big stone with smooth surface in Tina Town. When people go towards it ...
- hdu5392 Infoplane in Tina Town(LCM)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Infoplane in Tina Town Time Limit: 14000/ ...
- hdoj 5391 Zball in Tina Town
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5391 相关数论结论: 威尔逊定理——当且仅当p为素数时:( p -1 )! ≡ p-1 ( mod p ...
- [hdu5392 Infoplane in Tina Town]置换的最小循环长度,最小公倍数取模,输入挂
题意:给一个置换,求最小循环长度对p取模的结果 思路:一个置换可以写成若干循环的乘积,最小循环长度为每个循环长度的最小公倍数.求最小公倍数对p取模的结果可以对每个数因式分解,将最小公倍数表示成质数幂的 ...
- HDU-5391 Zball in Tina Town
(n-1)!/n 就是如果n为素数,就等于n-1else为0. 求素数表: Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others) Memo ...
- (hdu)5391 Zball in Tina Town
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5391 Problem Description Tina Town is a friendl ...
- hdu5391 Zball in Tina Town(威尔逊定理)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Zball in Tina Town Time Limit: 3000/1500 ...
- hdu 5391 Zball in Tina Town(打表找规律)
问题描述 Tina Town 是一个善良友好的地方,这里的每一个人都互相关心. Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大11倍.在第二天的时候, ...
随机推荐
- appserver配置虚拟主机
1, apach配置文件开启虚拟主机服务(C:\AppServ\Apache2.2\conf\httpd.conf)大概561行的位置 # Virtual hostsInclude conf/extr ...
- UVA 489 Hangman Judge (字符匹配)
题意:给一个字符串A,只含小写字符数个.再给一个字符串B,含小写字符数个.规则如下: 1.字符串B从左至右逐个字符遍历,对于每个字符,如果该字符在A中存在,将A中所有该字符删掉,若不存在,则错误次数+ ...
- type tips
网上有这么一篇文章,全文如下:http://bbs.9ria.com/blog-220191-18429.html AS3中一共有以下六种获取变量类型的方法: typeof instanceof ...
- HDU 4608 I-number 2013 Multi-University Training Contest 1
定义一个数 y 为 x 的 I-number.对于 y 有如下要求: 1.y > x; 2.y 的每一位之和要为10的倍数(例如 28 每一位之和为 10 ,为 10 的 1 倍); 3.这样的 ...
- Android 下实现图片的移动
网上看到的demo,感觉很有趣,但是 实用性不是太强,记录一下. 源码下载地址:请戳这里---------------->
- 基于HTTP的直播点播HLS
HLS(HTTP Live Streaming) 是Apple在2009年发布的,可以通过普通的web服务器进行分发的新型流媒体协议.苹果官方对于视频直播服务提出了 HLS 解决方案 ...
- AJax学习一
1.Ajax的准备工作,就是要先准备好服务器环境. 这边可以有好几种方式,例如服务器工具: http://www.php100.com/html/plugin/ser/2013/0905/91.htm ...
- Arduino 使用舵机库时 其它引脚输出怪异 解决方案
使用Servo.h时,不管你在初始化时用的是9还是10脚,都不要把这两个脚作为舵机以外的用途! 例: servo.attach(9); digitalWrite(10,1);//错,不能把第10脚用作 ...
- @Component @Repository @Service @Controller
Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...
- web-3g-(163)网易-邮箱-记事本-数据库设计
ylbtech-DatabaseDesgin:ylbtech-cnblogs(博客园)-数据库设计-2,Admin(用户后台) DatabaseName:cnblogs(博客园) Model:Admi ...