D - Game with Pearls
来源:互联网 发布:北京java晚班 编辑:程序博客网 时间:2024/05/22 17:35
#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <iostream>#include <queue>#include <map>#include <set>#include <vector>using namespace std;int tm[505]; int tmp[505]; int vis[505];int main(){int t,n,k,i;cin>>t;while(t--){int cun=0;memset(vis,0,sizeof(vis)); cin>>n;cin>>k;int flag=0;for (i=1;i<=n;i++){scanf("%d",&tm[i]);if (tm[i]==0) continue;if (vis[tm[i]]==0){vis[tm[i]]=1;tm[i]=-1;}}int ok=0;for (i=1;i<=n;i++){if (tm[i]>=0){tmp[++ok]=tm[i];}}sort(tmp+1,tmp+ok+1);int j;for (j=1;j<=n;j++){if (vis[j]==0){int tt;int ff=0;int mark=0;for (i=1;i<=ok;i++){if (tmp[i]<=j&&tmp[i]!=-1){tt=j-tmp[i];if (tt%k==0){mark=1;tmp[i]=-1;vis[j]=1; break;}}}if (mark==0){cun=1;break;}}}if (cun==1){cout<<"Tom\n";continue;}else{cout<<"Jerry\n";continue;}}return 0;}
0 0
- D - Game with Pearls
- D.Game with Pearls
- Game with Pearls
- hdu 5090 Game with Pearls
- hdu 5090 Game with Pearls
- HDU 5090 Game with Pearls
- HDU 5090 Game with Pearls
- HDU 5090 - Game with Pearls
- HDU-5090--Game with Pearls
- HDU 5090 Game with Pearls
- HDU 5090 Game with Pearls
- 【二分匹配】 HDU 5090 Game with Pearls
- hdu 5090 Game with Pearls (二分匹配)
- HDU 5090 Game with Pearls(贪心)
- hdu 5090 Game with Pearls(水题)
- HDU5090 Game with Pearls(贪心)
- hdu 5090 Game with Pearls 贪心
- Hdu 5090 Game with Pearls(二分匹配)
- 查看C++类的虚表(vtable)结构
- I - Faulty Odometer
- Hibernate中根据实体查询报错Ljava.lang.Object; cannot be。。。
- sdnu 1031 字母排序(拓扑排序的利用)
- 关于register修饰符以及在C 与 C++中的区别
- D - Game with Pearls
- 7/21 A 解题报告
- HDOJ_Problem Archive_1000_A + B Problem
- 安卓中的JSON解析
- Linux中出现/usr/bin/ld: cannot find -lxxx报错该怎么办?
- H - 24 Game
- linux awk命令详解
- 欢迎使用CSDN-markdown编辑器
- google ip 系列之一