ABC158 C - Tax Increase
問題はこちら atcoder.jp
方針
によって税抜き価格のあたりをつけるのですが,int
型は小数点以下切り捨てであるという性質上,本当の税抜価格は,a_sup
,b_sup
以上の整数です。
a_sup
,b_sup
以上である周辺の整数のうち,条件を満たすものが見つかり次第それを出力します。
コード
#include <bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a>>b; int a_sup,b_sup; a_sup=a/0.08; b_sup=b/0.1; int m=max(a_sup,b_sup); bool check=false; for(int i=0; i<10; i++){ if((int)((m+i)*0.08)==a && (int)((m+i)*0.1)==b){ cout<<m+i<<endl; check=true; break; } } if(check==false){ cout<<-1<<endl; } }