Official

A - Alloy Editorial by en_translator


Read \(A\) and \(B\) from the standard input and divided into cases just as the problem statement instructs; it is sufficient to output

  • Gold if \(0 \lt A\) and \(B = 0\);
  • Silver if \(A = 0\) and \(B \lt 0\);
  • Alloy if \(0 \lt A\) and \(0 \lt B\).

Sample Code (Python)

A,B = map(int,input().split())
if 0 < A and B == 0:
    print('Gold')
if A == 0 and 0 < B:
    print('Silver')
if 0 < A and 0 < B:
    print('Alloy')

Note that we can simplify it by using elif / else statements in Python or else if / else statements in C++.

Sample Code (Python)

A,B = map(int,input().split())
if 0 < A and B == 0:
    print('Gold')
elif A == 0 and 0 < B:
    print('Silver')
else:
    print('Alloy')

Especially, the following case divisions make the code even shorter.

Sample Code (C++)

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

int main(){
	int A,B; cin >> A >> B;
	if(B == 0) cout << "Gold" << endl;
	else if(A == 0) cout << "Silver" << endl;
	else cout << "Alloy" << endl;
}

posted:
last update: