标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 10627 | Accepted: 5121 |
Description
Input
Output
Sample Input
2 5 1 7 2 10 9 6 11 62 63 54 66 65 61 57 56 50 53 48 0 0
Sample Output
Case 1: 2 Case 2: 4
Source
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 using namespace std; 5 6 int card[25]; 7 int main() 8 { 9 int m,n,a,ca=1,cm,ans; 10 while(scanf(" %d%d",&m,&n)==2&&n&&m) 11 { 12 for(int i=0;i<n;i++){ 13 scanf("%d",&card[i]); 14 } 15 sort(card,card+n); 16 cm=n*m; ans=0; 17 for(int i=n-1;i>=0;i--) 18 { 19 if(cm==card[i]) ans++,cm--; //当前最大的卡在自己手里,必胜 20 else cm-=2;//对方胜,下一轮要获胜的话,卡的值要是当前最大值-2,因为没有重复的卡。 21 } 22 printf("Case %d: %d\n",ca++,ans); 23 } 24 }
标签:
原文地址:http://www.cnblogs.com/cumulonimbus/p/5830597.html