forked from cacophonix/SPOJ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BINGO.cpp
56 lines (50 loc) · 801 Bytes
/
BINGO.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
USER: zobayer
TASL: BINGO
ALGO: ad-hoc
*/
#include <set>
#include <string>
#include <cctype>
#include <iostream>
#include <sstream>
using namespace std;
void getlower(string &s)
{
int i, len = s.size();
for(i=0; i<len; i++)
{
if(isalpha(s.at(i))) s.at(i) = islower(s.at(i))? s.at(i)-32 : s.at(i);
else s.at(i) = ' ';
}
}
int gcd(int a, int b)
{
if(!b) return a;
else return gcd(b,a%b);
}
int main()
{
int game=0, total=0, g;
string line, str;
set< string > S;
ios::sync_with_stdio(false);
while(getline(cin,line))
{
getlower(line);
stringstream ss(line);
while(ss >> str)
{
if(str=="BULLSHIT")
{
total += S.size();
game++;
S.clear();
}
else S.insert(str);
}
}
g = gcd(total, game);
cout << total/g << " / " << game/g << endl;
return 0;
}