题目链接: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. (六) 6.3 Neurons Networks Gradient Checking

    BP算法很难调试,一般情况下会隐隐存在一些小问题,比如(off-by-one error),即只有部分层的权重得到训练,或者忘记计算bais unit,这虽然会得到一个正确的结果,但效果差于准确BP得 ...

  2. 【英语】Bingo口语笔记(24) - L的发音技巧

    舌头往上跑

  3. phonegap 清空页面缓存

    访问页面添加 <meta HTTP-EQUIV="pragma" CONTENT="no-cache"> <meta HTTP-EQUIV=& ...

  4. 基于catalog 创建RMAN存储脚本

    --============================== -- 基于catalog 创建RMAN存储脚本 --============================== 简言之,将rman的 ...

  5. phonegap 使用极光推送实现消息推送

    最近一直在研究各种推送,ios的由于是apns,比较容易实现,但是andriod的就比较麻烦.后来看了很多解决方案,gcm明显是不行的,其他的方案更是一头雾水,而且需要做第二次开发,太麻烦,后来就选择 ...

  6. 构建 XCache 的基本步骤

    构建 XCache 的基本步骤 在开始之前,首先确保 PHP 正常安装并核实 phpize 是否位于 shell 的 PATH 下.同时,还需要一个 C 编译器,例如 GNU Compiler Col ...

  7. sqlplus常用命令

    原文 sqlplus常用命令 desc 表名            显示表的结构 show user           显示当前连接用户 show error            显示错误 sho ...

  8. ANT 发布项目中 build.xml 文件的详细配置

    xml 代码 <?xml version="1.0" encoding="UTF-8"?> <!-- name:对应工程名字 default: ...

  9. YII 快速创建项目GII

    Yii 是一个基于组件.纯OOP的.用于开发大型 Web 应用的高性能PHP框架. 它将Web编程中的可重用性发挥到极致,能够显著加速开发进程 .Yii适合大流量的应用,如门户.BBS.CMS及B2B ...

  10. Selenium2Library系列 keywords 之 _SelectElementKeywords 之 select_from_list_by_label(self, locator, *labels)

    def select_from_list_by_label(self, locator, *labels): """Selects `*labels` from list ...