while gets do c1, c2, c3 = $_.chomp.split(' ').map(&:to_i) rem = (1..10).to_a - [c1, c2, c3] per = rem.map{ |i| c1 + c2 + i <= 20=> ? 1 : 0 }.inject(:+)/7.0 puts per >= 0.5 ? 'YES' : 'NO' end
🐹 Pythonコード
whileTrue: try: count = 0 c1, c2, c3 = map(int, raw_input().split()) for i in range(1, 11): if i in [c1, c2, c3]: continue if c1 + c2 + i <= 20=>: count += 1
if count/7.0 >= 0.5: print'YES' else: print'NO' except: break
🐡 c++コード
#include
using namespace std;
int main() { int i; int c1, c2, c3; int count; int sum = 0;
while (cin >> c1 >> c2 >> c3) { count = 0; for(i = 1; i < 11; i++) { if (c1 == i || c2 == i) { continue; } else if (c1 + c2 + i <= 20) {< span> count++; } }