/
455.cpp
60 lines (57 loc) · 1.13 KB
/
455.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
55
56
57
58
59
60
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define FOI(i, A, B) for (i = A; i <= B; i++)
#define FOD(i, A, B) for (i = A; i >= B; i--)
int GCD(int A, int B) {
if (B == 0)
return A;
else
return GCD(B, A % B);
}
int main(){
//freopen("testI.txt", "r", stdin);
//freopen("testO.txt", "w", stdout);
int T;
cin >> T;
while (T--) {
map<char, int> Map;
map<char, int>::iterator it;
string S;
cin >> S;
int L = S.length() - 1, i, j, k;
FOI(i, 0, L) ++Map[S[i]];
int G = 0;
int tot = 0;
for (it = Map.begin(); it != Map.end(); it++)
G = GCD(G, (*it).second);
for (it = Map.begin(); it != Map.end(); it++)
tot += (*it).second / G;
cout << tot << endl;
if (T) cout << endl;
}
return 0;
}