题目链接: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的更多相关文章

  1. HDU 5392 Infoplane in Tina Town

    Infoplane in Tina Town Time Limit: 14000/7000 MS (Java/Others)    Memory Limit: 524288/524288 K (Jav ...

  2. hdu 5392 Infoplane in Tina Town(数学)

    Problem Description There is a big stone with smooth surface in Tina Town. When people go towards it ...

  3. hdu5392 Infoplane in Tina Town(LCM)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Infoplane in Tina Town Time Limit: 14000/ ...

  4. hdoj 5391 Zball in Tina Town

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5391 相关数论结论: 威尔逊定理——当且仅当p为素数时:( p -1 )! ≡ p-1 ( mod p ...

  5. [hdu5392 Infoplane in Tina Town]置换的最小循环长度,最小公倍数取模,输入挂

    题意:给一个置换,求最小循环长度对p取模的结果 思路:一个置换可以写成若干循环的乘积,最小循环长度为每个循环长度的最小公倍数.求最小公倍数对p取模的结果可以对每个数因式分解,将最小公倍数表示成质数幂的 ...

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

  7. (hdu)5391 Zball in Tina Town

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5391 Problem Description Tina Town is a friendl ...

  8. hdu5391 Zball in Tina Town(威尔逊定理)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Zball in Tina Town Time Limit: 3000/1500 ...

  9. hdu 5391 Zball in Tina Town(打表找规律)

    问题描述 Tina Town 是一个善良友好的地方,这里的每一个人都互相关心. Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大11倍.在第二天的时候, ...

随机推荐

  1. 封装sharedPreferences SettingsSPData

    /*************************************************************************** * 封装sharedPreferences S ...

  2. .Net dll多个同名的程序集版本冲突共存与通过基本代码或探测定位程序集方案

    .Net dll多个同名的程序集版本冲突共存与通过基本代码或探测定位程序集方案 在使用调用程序集的引用中的信息和配置文件中的信息确定了正确的程序集版本之后,并且在公共语言运行时在全局程序集缓存中进行检 ...

  3. dede 5.7进后台卡死解决办法

    注释后台文件dede/templets/index_body.htm(大概在第18行) <script type="text/javascript"> function ...

  4. vm虚拟机挂载usb

    首先得保证能在VM里看到usb设备,如图

  5. UVa 11520 Fill the Square 填充正方形

    在一个 n * n 网格中填了一些大写字母,你的任务是把剩下的格子中也填满大写字母,使得任意两个相邻格子(即有公共边的格子)中的字母不同.如果有多重填法,则要求按照从上到下,从左到右的顺序把所有格子连 ...

  6. 嵌入式 Linux下修改MAC地址

    Linux下修改MAC地址 方法一: 1.关闭网卡设备ifconfig eth0 down2.修改MAC地址ifconfig eth0 hw ether MAC地址3.重启网卡ifconfig eth ...

  7. c#中const、static、readonly的区别

    1. const与readonly const ,其修饰的字段只能在自身声明时初始化. Readonly 是只读变量,属于运行时变量,可以在类初始化的时候改变它的值.该类型的字段,可以在声明或构造函数 ...

  8. PHP开发常见问题解决列表

    1. 学习Zend Framework tutorial过程中的问题 (1)执行"zf create project zf-tutorial"出现如下错误: '"php. ...

  9. 【LeetCode 238】Product of Array Except Self

    Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...

  10. 【转】linux之ln命令

    转自:http://www.cnblogs.com/peida/archive/2012/12/11/2812294.html ln是linux中又一个非常重要命令,它的功能是为某一个文件在另外一个位 ...