Official

B - レーティング / Rating Editorial by admin


問題文中の式の通りに計算すれば良いです。

以下のように整数の切り捨て除算の形に式変形を行うことで、浮動小数点数の丸め誤差の影響を考慮せずに計算することが出来ます。

\(\lfloor 0.9 \times R + 0.1 \times P \rfloor = \lfloor \frac{9 \times R + 1 \times P}{10} \rfloor\)

実装の詳細は下記の実装例 (C++, Python) を参考にしてください。

実装例 (C++) :

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

int main() {
  int R, P;
  cin >> R >> P;
  int ans = (9*R + 1*P) / 10;
  cout << ans << endl;
  return 0;
}

実装例 (Python) :

R,P = map(int, input().split())
ans = (9*R + 1*P) // 10
print(ans)

posted:
last update: