Skip to content

Commit 94a196c

Browse files
authored
Merge pull request #398 from xirc/atcoder/abc008
AtCoder/ABC008
2 parents e31d1ca + 0de80fc commit 94a196c

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

atcoder/abc008/A/main.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
int S, T;
12+
cin >> S >> T;
13+
cout << (T - S + 1) << endl;
14+
15+
return 0;
16+
}

atcoder/abc008/B/main.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
int N;
12+
cin >> N;
13+
14+
map<string,int> votes;
15+
string s;
16+
for (int i = 0; i < N; i++) {
17+
cin >> s;
18+
votes[s]++;
19+
}
20+
21+
int maxi = 0;
22+
string top;
23+
for (auto const& e : votes) {
24+
if (e.second > maxi) {
25+
maxi = e.second;
26+
top = e.first;
27+
}
28+
}
29+
cout << top << endl;
30+
31+
return 0;
32+
}

atcoder/abc008/C/main.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int N;
8+
vector<int> C;
9+
10+
ff solve() {
11+
ff exp = 0;
12+
for (int i = 0; i < N; ++i) {
13+
int M = 0;
14+
for (int j = 0; j < N; ++j) {
15+
if (i == j) continue;
16+
if (C[i] % C[j] == 0) ++M;
17+
}
18+
ff px = ff(M / 2 + 1) / (M + 1);
19+
exp += px;
20+
}
21+
return exp;
22+
}
23+
24+
int main() {
25+
ios_base::sync_with_stdio(false);
26+
cin.tie(0); cout.tie(0);
27+
28+
cin >> N;
29+
C.assign(N, 0);
30+
for (int i = 0; i < N; ++i) {
31+
cin >> C[i];
32+
}
33+
cout << fixed << setprecision(12) << solve() << endl;
34+
35+
return 0;
36+
}

0 commit comments

Comments
 (0)