#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int M=510;
int m,n;
int map[M][M], match[M], chk[M]; int dfs(int p)
{
int i;
for(i=1;i<=m;i++)
if( map[p][i] && chk[i]==0 )
{
chk[i]=1;
if( match[i]==0 || dfs( match[i] ) )
{
match[i]=p;
return 1;
}
}
return 0;
} int solve()
{
int i,res;
for(i=1,res=0; i<=n; i++)
{
memset(chk,0,sizeof(chk));
res+=dfs(i);
}
return res;
} int main()
{
// freopen("in","r",stdin);
// freopen("out","w",stdout); int k,i,x,t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&k);
memset(map,0,sizeof(map));
memset(match,0,sizeof(match));
for(i=1;i<=n;i++)
{
scanf("%d",&x);
while(x<=n){
map[i][x]=1;
x+=k;
}
}
m=n; if(solve()==n)
printf("Jerry\n");
else
printf("Tom\n");
}
return 0;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

2014ACM上海邀请赛A解释称号的更多相关文章

  1. [POI 2001+2014acm上海邀请赛]Gold Mine/Beam Cannon 线段树+扫描线

    Description  Byteman, one of the most deserving employee of The Goldmine of Byteland, is about to re ...

  2. HDU5092——Seam Carving(动态规划+回溯)(2014上海邀请赛重现)

    Seam Carving DescriptionFish likes to take photo with his friends. Several days ago, he found that s ...

  3. HDU5093——Battle ships(最大二分匹配)(2014上海邀请赛重现)

    Battle ships Problem DescriptionDear contestant, now you are an excellent navy commander, who is res ...

  4. HDU5099——Comparison of Android versions(简单题)(2014上海邀请赛重现)

    Comparison of Android versionsProblem DescriptionAs an Android developer, itˇs really not easy to fi ...

  5. HDU5090——Game with Pearls(匈牙利算法|贪心)(2014上海邀请赛重现)

    Game with Pearls Problem DescriptionTom and Jerry are playing a game with tubes and pearls. The rule ...

  6. [java线段树]2015上海邀请赛 D Doom

    题意:n个数 m个询问 每个询问[l, r]的和, 再把[l, r]之间所有的数变为平方(模为9223372034707292160LL) 很明显的线段树 看到这个模(LLONG_MAX为922337 ...

  7. [java]2015上海邀请赛 B Base64

    题意: 给n和一个字符串(可以有空格) 求字符串编码n次后的字符串 编码方式:字符串的每个字符转化成ASCII码, ASCII码转化成8位2进制,    将二进制数分割成6位为一组的(不够的补0), ...

  8. ZOJ 3820 2014ACM/ICPC牡丹江司B称号

    3797714 2014 - 10 - 12 21:58 : 19 Accepted 3820 C++ 1350 70240 zz_1215 比較麻烦的一道题吧,開始的时候不停的段异常,后面知道是爆栈 ...

  9. “纽劢科技杯”第十六届同济大学程序设计竞赛暨上海邀请赛同步赛 J-张老师的游戏

    传送门 题目描述     在空闲时间,张老师习惯性地和菜哭武玩起了取石子游戏,这次的游戏规则有些不同,在他们面前有n堆石子,其中,第i堆石子的个数为a[i],现在制定规则如下:     从张老师开始, ...

随机推荐

  1. cocos2d-x 2.2.3 创建项目的方法

    直接复制粘贴到txt文本,然后修改后缀为.bat,然后将bat文件放到tools\project-creator的目录下即可. :project_input @echo 请输入项目名称,按回车,例:H ...

  2. 熬之滴水穿石:Spring--精简的J2EE(6)

                                           48--曾用过的View 在Spring MVC架构中View实际上是有多种选择的.JSP是首选的view,实际上在J2E ...

  3. 同时显示多个 Notification

    主要出在PendingIntent.getActivity();的第二个参数,API文档里虽然说是未被使用的参数(给出的例子也直接写0的),实际上是通过该参数来区别不同的Intent的,如果id相同, ...

  4. HDU1194_Beat the Spread!

    Beat the Spread! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  5. 宏碁宣布Liquid Jade智能机和Leap袖口

    据科技网站Android Community 4月29日覆盖,宏碁29公布的新智能机Liquid Jade而随着智能手镯部署Liquid Leap.尽管宏碁已经宣布了一项新的外部基本信息.但价格格和商 ...

  6. SSO(Single Sign On)系列(一)--SSO简单介绍

    任何类型的站点,到达一定规模之后一定会存在这种问题:比方我们有N个系统.传统方式下我们就须要有N对不同的username和password,本来这些系统的开发都能为我们带来良好的效益,用户在用的时候并 ...

  7. 【原创】poj ----- 2524 Ubiquitous Religions 解题报告

    题目地址: http://poj.org/problem?id=2524 题目内容: Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 6 ...

  8. virtio-blk分析

    和virtio-network相同,virtio-blk驱动程序使用Virtio机制Guest它提供了一个高性能的设备I/O方法.我们期待在这里virtio-blk实现. [点击查看全文] http: ...

  9. 【Win7】【磁盘管理】删除相似“33fbc1d57e9aaf1ea88e6f08”缓存目录

    一般,在计算机磁盘.移动硬盘.或U盘出现,类别似"33fbc1d57e9aaf1ea88e6f08",你不能删除缓存目录.能Win7删除. (1).使用管理员,打开命令提示符窗口( ...

  10. Easy 2048 Again - ZOJ 3802 像缩进dp

    Easy 2048 Again Time Limit: 2 Seconds      Memory Limit: 65536 KB Dark_sun knows that on a single-tr ...