Skip to content

AtCoder/ABC186 #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions atcoder/abc186/A/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
using ff = long double;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

int N, W;
cin >> N >> W;
int C = N / W;
cout << C << endl;

return 0;
}
25 changes: 25 additions & 0 deletions atcoder/abc186/B/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
using ff = long double;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

int H, W;
cin >> H >> W;

vector<int> A(H * W);
for (int i = 0; i < H * W; ++i) {
cin >> A[i];
}
int mini = *min_element(A.begin(), A.end());
int ans = accumulate(A.begin(), A.end(), 0, [&](int s, int v) {
return s + (v - mini);
});
cout << ans << endl;

return 0;
}
39 changes: 39 additions & 0 deletions atcoder/abc186/C/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
using ff = long double;

bool contains7_on_10base(int N) {
while (N > 0) {
if (N % 10 == 7) return true;
N /= 10;
}
return false;
}

bool contains7_on_8base(int N) {
while (N > 0) {
if (N % 8 == 7) return true;
N /= 8;
}
return false;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

int N;
cin >> N;

int ans = 0;
for (int i = 1; i <= N; ++i) {
if (contains7_on_10base(i)) continue;
if (contains7_on_8base(i)) continue;
++ans;
}
cout << ans << endl;

return 0;
}
34 changes: 34 additions & 0 deletions atcoder/abc186/D/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
using ff = long double;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

int N;
vector<ll> A;

cin >> N;
A.assign(N, 0);
for (auto &a : A) cin >> a;

sort(A.begin(), A.end());
ll rhs = 0;
for (int i = 0; i < N; ++i) {
rhs += (N - i) * A[i];
}
ll lhs = 0;
for (int i = N - 1; i >= 0; --i) {
if (i + 1 < N) {
A[i] += A[i+1];
}
lhs += A[i];
}
ll ans = lhs - rhs;
cout << ans << endl;

return 0;
}