第1問 PracticeA - Welcome to AtCoder
practice.cpp
#include <iostream>
using namespace std;
int main() {
int a, b, c; cin >> a >> b >> c;
string s; cin >> s;
cout << a + b + c << " " << s;
return 0;
}
第2問 ABC086A - Product
abc086a.cpp
#include <iostream>
using namespace std;
int main() {
int a, b; cin >> a >> b;
int ans = a * b;
if (ans % 2 == 0)
cout << "Even";
else
cout << "Odd";
return 0;
}
第3問 ABC081A - Placing Marbles
abc081a.cpp
#include <iostream>
using namespace std;
int main() {
string s; cin >> s;
int cnt = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '1')
cnt++;
}
cout << cnt;
return 0;
}
第4問 ABC081B - Shift only
abc081b.cpp
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N; cin >> N;
vector<int>A(N, 0);
for (int i = 0; i < N; i++)
cin >> A[i];
int ans = 1000000000;
for (int i = 0; i < N; i++) {
int cnt = 0;
while (A[i]%2 == 0) {
A[i] = A[i] / 2;
cnt++;
}
ans = min(ans, cnt);// 2 で割れる回数の最小値が答え
}
cout << ans * (ans != 1000000000);
//while (1) {}
return 0;
}
第5問 ABC087B - Coins
abc087b.cpp
#include <iostream>
using namespace std;
int main() {
int A, B, C,X; cin >> A >> B >> C >> X;
int cnt = 0;
for (int a = 0; a <= A; a++) {
for (int b = 0; b <= B; b++) {
for (int c = 0; c <= C; c++) {
if (500 * a + 100 * b + 50 * c == X)
cnt++;
}
}
}
cout << cnt;
//while (1) {}
return 0;
}
第6問 ABC083B - Some Sums
abc083b.cpp
#include <iostream>
using namespace std;
int main() {
int N, A, B; cin >> N >> A >> B;
long long sum = 0;
for (int i = 1; i <= N; i++) {
int num = 0,k=i;
while (k>0) {
num += k % 10;// 一桁ずつ取り出して足し合わせる
k = k / 10;
}
if (A <= num && num <= B)
sum += i;
}
cout << sum;
//while (1) {}
return 0;
}
第7問 ABC088B - Card Game for Two
abc088c.cpp
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int N; cin >> N;
vector<int>A(N);
for (int i = 0; i < N; i++)
cin >> A[i];
sort(A.begin(), A.end(), greater<int>());
int Alice = 0, Bob = 0;
for (int i = 0; i < N; i++) {
if (i % 2 == 0)
Alice += A[i];
else
Bob += A[i];
}
cout << Alice - Bob;
//while (1) {}
return 0;
}
第8問 ABC085B - Kagami Mochi
abc085b.cpp
#include <iostream>
#include <set>
using namespace std;
int main() {
int N,a; cin >> N;
set<int>num;
for (int i = 0; i < N; i++) {
cin >> a;
num.insert(a);
}
cout << num.size();
//while (1) {}
return 0;
}
第9問 ABC085C - Otoshidama
abc085c.cpp
#include <iostream>
using namespace std;
int main() {
int N, Y; cin >> N >> Y;
for (int i = 0; i <= N; i++) {
for (int l = 0; l <= N; l++) {
if ((N - i - l >= 0) && (10000 * i + 5000 * l + 1000 * (N - i - l) == Y)) {
cout << i << " " << l << " " << N - i - l << "\n";
//while (1) {}
return 0;
}
}
}
cout << -1 << " " << -1 << " " << -1 << "\n";
//while (1) {}
return 0;
}
第10問 ABC049C - 白昼夢
abc049c.cpp
#include <iostream>
#include <string>
#include <vector>
using namespace std;
//dream
//dreamer
//erase
//eraser
int main() {
string S;
cin >> S;
vector<int>dp(S.size()+1, 0);
dp[0] = 1;
for (int i = 0; i < S.size(); i++) {
if (dp[i] != 0 && (S.substr(i, 5) == "dream" || S.substr(i, 5) == "erase"))
dp[i + 5] += dp[i];
if (dp[i] != 0 && (S.substr(i, 6) == "eraser"))
dp[i + 6] += dp[i];
if (dp[i] != 0 && (S.substr(i, 7) == "dreamer"))
dp[i + 7] += dp[i];
}
if (dp[S.size()] != 0)
cout << "YES";
else
cout << "NO";
//while (1) {}
return 0;
}
第11問 ABC086C - Traveling
abc086c.c
#include <iostream>
using namespace std;
int main() {
int N; cin >> N;
int t, x, y;
int ct=0, cx=0, cy=0;
for (int i = 0; i < N; i++) {
cin >> t >> x >> y;
if (t - ct >= abs(x - cx) + abs(y - cy)) {
if ((t - ct - (abs(x - cx) + abs(y - cy))) % 2 != 0) {
cout << "No";
//while (1) {}
return 0;
}
ct = t;
cx = x;
cy = y;
}
else {
cout << "No";
//while (1) {}
return 0;
}
}
cout << "Yes";
//while (1) {}
return 0;
}