题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1551
input | output |
---|---|
3 Homasho Ishikawa Tamakasuga Tokyo Futeno Tochigi Takekaze Tokyo Kasugao Yamaguchi Kotoshogiku Ishikawa Kotomitsuki Tokyo Miyabiyama Shizuoka |
1 |
代码如下:
//#pragma warning (disable:4786) #include <cstdio> #include <cmath> #include <cstring> #include <string> #include <cstdlib> #include <climits> #include <ctype.h> #include <queue> #include <stack> #include <vector> #include <utility> #include <deque> #include <set> #include <map> #include <iostream> #include <algorithm> using namespace std; string a, b; map<string, int >m; int main() { int num[11] = {0,2,4,8,16,32,64,128,256,512,1024}; int n; while(~scanf("%d",&n)) { int nn = num[n]; int maxx = 0; for(int i = 0; i < nn; i++) { cin >> a >> b; m[b]++; if(m[b] > maxx) { maxx = m[b]; } } int ans = 0; while(1) { if(maxx <= nn/2) { ans++; nn/=2; } else { break; } } printf("%d\n",ans); } return 0; }
URAL 1551. Sumo Tournament(数学啊 )
原文地址:http://blog.csdn.net/u012860063/article/details/44498371