Skip to content

Commit f34b773

Browse files
authored
Merge pull request #406 from xirc/atcoder/abc050
AtCoder/ABC050
2 parents c211c04 + 9a8fef1 commit f34b773

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

atcoder/abc050/A/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 A, B;
12+
string op;
13+
14+
cin >> A >> op >> B;
15+
16+
int ans = 0;
17+
if (op == "+") {
18+
ans = A + B;
19+
} else if (op == "-") {
20+
ans = A - B;
21+
} else throw;
22+
cout << ans << endl;
23+
24+
return 0;
25+
}

atcoder/abc050/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, M;
12+
vector<int> T;
13+
14+
cin >> N;
15+
T.assign(N, 0);
16+
for (auto &t : T) cin >> t;
17+
cin >> M;
18+
for (int i = 0; i < M; ++i) {
19+
int p, x;
20+
cin >> p >> x;
21+
--p;
22+
23+
int ans = 0;
24+
for (int j = 0; j < N; ++j) {
25+
if (j == p) ans += x;
26+
else ans += T[j];
27+
}
28+
cout << ans << endl;
29+
}
30+
31+
return 0;
32+
}

atcoder/abc050/C/main.cpp

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

0 commit comments

Comments
 (0)