公式

A - Raise Both Hands 解説 by en_translator


For beginners

Divide into cases based on the values \(L\) and \(R\).

If \(L = 0\) and \(R = 0\), then print Invalid; if \(L = 0\) and \(R = 1\), print No; if \(L = 1\) and \(R = 0\), print No; and if \(L = 1\) and \(R = 1\), print Invalid.

Sample code

#include <bits/stdc++.h>
using namespace std;

int main() {
	int l, r;
	cin >> l >> r;
	if (l == 0 && r == 0) cout << "Invalid\n";
	else if (l == 0 && r == 1) cout << "No\n";
	else if (l == 1 && r == 0) cout << "Yes\n";
	else cout << "Invalid\n";
}

投稿日時:
最終更新: