ラーメントッピング問題
問題概要
ラーメンを注文した。700 円である。
トッピングは 3 種類ある。それらのトッピングを注文したかどうかは 3 文字の文字列 で表される ("oxo" などのように)。
トッピングは 1 種類につき 100 円加算される。ラーメンの代金を求めよ。
解法
Placing Marble と大体同じ。次のように解ける。
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int res = 700; if (S[0] == 'o') res += 100; if (S[1] == 'o') res += 100; if (S[2] == 'o') res += 100; cout << res << endl; }