A - Duplex Printing
解説
- n / 2 + n % 2 で求められる
実装例(C++)
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int result = n / 2 + n % 2;
cout << result << endl;
}
B - Bingo
解説
- Aを保存する二次元配列と印がついているかの二次元配列を作成する
- 判定の部分は自由に書いた(効率は良くない)
実装例(C++)
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<vector<int>> a(3, vector<int>(3));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
cin >> a[i][j];
}
}
int n;
cin >> n;
vector<vector<bool>> bool_a(3, vector<bool>(3));
for (int i = 0; i < n; i++){
int b;
cin >> b;
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
if (a[i][j] == b) {
bool_a[i][j] = true;
}
}
}
}
bool ans = false;
for (int i = 0; i < 3; i++) {
if (bool_a[i][0] && bool_a[i][1] && bool_a[i][2]) {
ans = true;
}
if (bool_a[0][i] && bool_a[1][i] && bool_a[2][i]) {
ans = true;
}
}
if (bool_a[0][0] && bool_a[1][1] && bool_a[2][2]) {
ans = true;
}
if (bool_a[0][2] && bool_a[1][1] && bool_a[2][0]) {
ans = true;
}
if (ans == true) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}