Skip to content

Commit 6a353b4

Browse files
authored
Merge pull request #510 from xirc/atcoder/abc186
AtCoder/ABC186
2 parents 21c306a + 4e75a48 commit 6a353b4

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

atcoder/abc186/A/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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, W;
12+
cin >> N >> W;
13+
int C = N / W;
14+
cout << C << endl;
15+
16+
return 0;
17+
}

atcoder/abc186/B/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 H, W;
12+
cin >> H >> W;
13+
14+
vector<int> A(H * W);
15+
for (int i = 0; i < H * W; ++i) {
16+
cin >> A[i];
17+
}
18+
int mini = *min_element(A.begin(), A.end());
19+
int ans = accumulate(A.begin(), A.end(), 0, [&](int s, int v) {
20+
return s + (v - mini);
21+
});
22+
cout << ans << endl;
23+
24+
return 0;
25+
}

atcoder/abc186/C/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+
bool contains7_on_10base(int N) {
8+
while (N > 0) {
9+
if (N % 10 == 7) return true;
10+
N /= 10;
11+
}
12+
return false;
13+
}
14+
15+
bool contains7_on_8base(int N) {
16+
while (N > 0) {
17+
if (N % 8 == 7) return true;
18+
N /= 8;
19+
}
20+
return false;
21+
}
22+
23+
int main() {
24+
ios_base::sync_with_stdio(false);
25+
cin.tie(0); cout.tie(0);
26+
27+
int N;
28+
cin >> N;
29+
30+
int ans = 0;
31+
for (int i = 1; i <= N; ++i) {
32+
if (contains7_on_10base(i)) continue;
33+
if (contains7_on_8base(i)) continue;
34+
++ans;
35+
}
36+
cout << ans << endl;
37+
38+
return 0;
39+
}

atcoder/abc186/D/main.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
vector<ll> A;
13+
14+
cin >> N;
15+
A.assign(N, 0);
16+
for (auto &a : A) cin >> a;
17+
18+
sort(A.begin(), A.end());
19+
ll rhs = 0;
20+
for (int i = 0; i < N; ++i) {
21+
rhs += (N - i) * A[i];
22+
}
23+
ll lhs = 0;
24+
for (int i = N - 1; i >= 0; --i) {
25+
if (i + 1 < N) {
26+
A[i] += A[i+1];
27+
}
28+
lhs += A[i];
29+
}
30+
ll ans = lhs - rhs;
31+
cout << ans << endl;
32+
33+
return 0;
34+
}

0 commit comments

Comments
 (0)