Skip to content

Commit aa470c0

Browse files
authored
Merge pull request #395 from xirc/atcoder/abc003
AtCoder/ABC003{A,B,C}
2 parents 4a52ed3 + f9e70be commit aa470c0

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

atcoder/abc003/A/main.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 X;
12+
cin >> X;
13+
14+
int S = 0;
15+
for (int i = 1; i <= X; ++i) {
16+
S += i;
17+
}
18+
cout << fixed << setprecision(7) << (ll(S) * 10000 / ff(X)) << endl;
19+
20+
return 0;
21+
}

atcoder/abc003/B/main.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
string S, T;
12+
cin >> S >> T;
13+
assert(S.size() == T.size());
14+
15+
string wildcards = "atcoder";
16+
bool win = true;
17+
int N = S.size();
18+
for (int i = 0; i < N; ++i) {
19+
if (S[i] == T[i]) continue;
20+
if (S[i] != '@' && T[i] != '@') {
21+
win = false;
22+
break;
23+
}
24+
char c = ' ';
25+
if (S[i] == '@') c = T[i];
26+
if (T[i] == '@') c = S[i];
27+
if (c != '@' && wildcards.find(c) == string::npos) {
28+
win = false;
29+
break;
30+
}
31+
}
32+
if (win) {
33+
cout << "You can win" << endl;
34+
} else {
35+
cout << "You will lose" << endl;
36+
}
37+
38+
return 0;
39+
}

atcoder/abc003/C/main.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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, K;
12+
vector<int> R;
13+
14+
cin >> N >> K;
15+
R.assign(N, 0);
16+
for (auto &r : R) cin >> r;
17+
sort(R.begin(), R.end());
18+
ff rate = 0;
19+
for (int i = N - K; i < N; ++i) {
20+
rate = (rate + R[i]) / 2;
21+
}
22+
cout << fixed << setprecision(7) << rate << endl;
23+
24+
return 0;
25+
}

0 commit comments

Comments
 (0)