Zhuge Liang's Stone Sentinel Maze

Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 385    Accepted Submission(s): 106

Problem Description

Zhuge Liang was a chancellor of the state of Shu Han during the Three Kingdoms period of Chinese history. He is often recognized as the greatest and most accomplished strategist of his era. He was so smart that his name also means “wise man” in Chinese.

One of Zhuge Liang’s achievements in legend is the Stone Sentinel Maze. It was an array of rocks and boulders built to defend against enemies. The formation was located on Yufu Shore by the Yangtze River near present-day Baidicheng, Chongqing, China, where supposed ruins of the array exist.

In chapter 84 of the historical novel Romance of the Three Kingdoms, as Lu Xun neared Baidicheng, he felt a strong enemy presence in the area and alerted his army to a possible ambush. He sent scouts ahead, who reported that the region was deserted except for some scattered piles of rocks. The bewildered Lu Xun asked a local, who told him that qi ("energy") started emerging from the area after Zhuge Liang arranged the rocks there. Lu Xun personally inspected the area and decided that the array was only a petty display of deception. Hence, Lu Xun led a few horsemen with him into the maze, and as he was about to exit, there was a strong gust of wind. At that moment, dust storms overshadowed the sky and the rocks appeared to become valleys; mountainous piles of dirt emerged and the roar of thunder rocked the skies while the waves of the nearby Yangtze River sounded like the clashing of swords and beating of war drums…

After the research on the Stone Sentinel Maze, scientists find some regulations. The rocks have m different kinds of weight (1<=m<=10,000). The weight of a rock is a positive integer not exceeding 10,000. There are n (3<=n<=100,000) rocks placed on a circle with equal spacing and the greatest common divisor of their weight is 1. They want to know in how many ways the rocks can be placed like that.

Notice:
1. Multiple rocks with the same weight can be placed on the circle.
2. If a solution will be the same as another one by rotation, these two solutions should be consider as the same.
3. The answer may be quite large. You just need to calculate the remainder of the answer when divided by 10,007.

 
Input
The input begins with a line containing an integer T, the number of test cases.
For each case, the first line begins with two integers --- the above mentioned m and n. Then m lines follow, each containing a positive integer representing rock weight. It is guaranteed that these m integers are different.
 
Output
For each case, output one integer in one line, representing the remainder of the number of ways when divided by 10,007.
 
Sample Input
2
2 3
2
3
3 3
6
10
15
 
Sample Output
2
2
 
Source
 
 
题意:给你m种石头子,每种无限多个,选出n个构成环,满足GCD(a1,a2,,,an)=1;
        如果通过旋转相同,看成一种。

HDU 4048 Zhuge Liang's Stone Sentinel Maze的更多相关文章

  1. hdu 4739 Zhuge Liang's Mines 随机化

    Zhuge Liang's Mines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...

  2. HDU 4772 Zhuge Liang&#39;s Password (简单模拟题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772 题面: Zhuge Liang's Password Time Limit: 2000/1000 ...

  3. hdu 4739 Zhuge Liang's Mines (简单dfs)

    Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  4. HDU 4772 Zhuge Liang's Password (2013杭州1003题,水题)

    Zhuge Liang's Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  5. HDU 4739 Zhuge Liang's Mines (2013杭州网络赛1002题)

    Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. hdu 4739 Zhuge Liang's Mines DFS

    http://acm.hdu.edu.cn/showproblem.php?pid=4739 题意: 给定100*100的矩阵中n(n<= 20)个点,每次只能一走能够形成正方形的四个点,正方形 ...

  7. hdu 4739 Zhuge Liang's Mines

    一个简单的搜索题,唉…… 当时脑子抽了,没做出来啊…… 代码如下: #include<iostream> #include<stdio.h> #include<algor ...

  8. HDU 4739 Zhuge Liang's Mines (状态压缩+背包DP)

    题意 给定平面直角坐标系内的N(N <= 20)个点,每四个点构成一个正方形可以消去,问最多可以消去几个点. 思路 比赛的时候暴力dfs+O(n^4)枚举写过了--无意间看到有题解用状压DP(这 ...

  9. HDOJ 4739 Zhuge Liang&#39;s Mines

    Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

随机推荐

  1. JSON与DataTable(DataSet)相互转化

    public static string CreateJsonParameters(DataTable dt)        {            /* /******************** ...

  2. 怎么在Centos7下添加win8.1的启动项

    首先找到启动文件. 在/boot/grub2目录下, 找到grub.cfg文件. 然后, sudo修改,  用gedit工具方便. 怎么修改? 打开文件, 找到有两个menuentry开头的部分, 然 ...

  3. BizTalk动手实验(八)消息路由

    1 课程简介 通过本课程熟悉BizTalk消息由的机制 2 准备工作 1. 熟悉XML.XML Schema.XSLT等相关XML开发技术 2. 新建BizTalk空项目 3 演示 3.1 动态消息路 ...

  4. Windows Server 2003修改远程桌面最大连接数的方法

    Windows Server 2003远程桌面允许的终端连接数默认情况下只有2个线程,也就是2个用户,当我们需要多人同时登录服务器的时候,就需要适当增加远程连接同时在线的用户数. 修改远程桌面最大连接 ...

  5. VS 调试

    Vs 单步调试 在vs中的单步调试: 调试重要的几个键: F9在当前光标所在的行下断点,如果当前行已经有断点,则取消断点. F5调试状态运行程序,程序执行到有断点的地方会停下来. F10单步执行程序. ...

  6. BLOB

    BLOB (binary large object),二进制大对象,是一个可以存储二进制文件的容器.在计算机中,BLOB常常是数据库中用来存储二进制文件的字段类型.BLOB是一个大文件,典型的BLOB ...

  7. springmvc Failed to load resource: the server responded with a status of 404 (Not Found)

    jsp页面导入css.js提示上述问题. Spring对静态资源的请求做专门处理 <!-- 对静态资源的请求 --><mvc:resources location="/js ...

  8. 腾迅股票数据接口 http/javascript

    腾迅股票数据接口 http/javascript 分类: Finance Perl2012-12-21 23:48 31132人阅读 评论(3) 收藏 举报 之前使用了新浪的股票数据,由于新浪http ...

  9. Box2D淌坑日记: 关节(Joint)和旋转关节(b2RevoluteJoint)

    关节在Box2D的对象组织结构中,与b2Body(刚体)并列.因此两种对象都是由b2World创建并直接管理. 然而Joint有依赖于b2Body的地方,就是它的销毁:当关节所涉及到的刚体被销毁,关节 ...

  10. Tomcat(JVM)性能监控方法

    Tomcat(JVM)监控方法 1.Tomcat自带的监控页面 配置详见Tomcat安装配置监控一文,如图所示为监控页面: 2.LoadRunner编写脚本实现Tomcat监控 采用编写VuGen脚本 ...