HDU 5090 Game with Pearls
来源:互联网 发布:linux创建新用户和组 编辑:程序博客网 时间:2024/06/13 03:00
直接贪心就可以了,接收的时候把0都加上k,每次从最小的数开始找,如果有多个相同的,那么保留一个,其他的都加上k
#include<stdio.h>#include<algorithm>using namespace std;int a[105];int main(){#ifndef ONLINE_JUDGEfreopen("in.txt","r",stdin);#endifint T,n,k;scanf("%d",&T);while(T--){scanf("%d%d",&n,&k);for(int i=0;i<n;i++) {scanf("%d",&a[i]);if(a[i]==0) a[i]+=k;}sort(a,a+n);int flag=1;for(int i=0;i<n;i++){if(a[i]==i+1){int j=1;while(a[i+j]==a[i]){a[i+j]+=k;j++;}sort(a+i,a+n);}else{flag=0;printf("Tom\n");break;}}if(flag==1) printf("Jerry\n");}}
0 0
- 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(水题)
- 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(二分匹配)
- 内联函数(To be update)
- 浅谈WebService
- Spring和SpringMVC的区别
- 【codechef】Clash of Clans
- QT4.8下 MD5的编码
- HDU 5090 Game with Pearls
- Struts2学习
- poj 1084 Square Destroyer dlx解重复覆盖
- Google Gson 使用简介
- leetcode044:Wildcard Matching
- angularjs中的$degist,$watch,$apply
- EXT学习之基础框架-apply
- PHP扩展开发-Hello World
- 块状数组(hdu3207 Highway)