Official
A - Balloon Trip Editorial
by
A - Balloon Trip Editorial
by
physics0523
初心者の方へ
- プログラミングの学習を始めたばかりで何から手をつけるべきかわからない方は、まずは practice contest の問題A「Welcome to AtCoder」をお試しください。言語ごとに解答例が掲載されています。
- また、プログラミングコンテストの問題に慣れていない方は、 AtCoder Beginners Selection の問題をいくつか試すことをおすすめします。
- C++入門 AtCoder Programming Guide for beginners (APG4b) は、競技プログラミングのための C++ 入門用コンテンツです。
- Python入門 AtCoder Programming Guide for beginners (APG4bPython) は、競技プログラミングのための Python 入門用コンテンツです。
問題原案: admin
求めるべきは、 \(1000W < nB\) なる最小の整数 \(n\) です。
これを求めるための方針のうちいくつかは以下の通りです。
- for ループを回す。
- \(\displaystyle \frac{1000W}{B} < n\) と変形する。変形した結果、 \(\displaystyle \left \lfloor \frac{1000W}{B} \right \rfloor + 1\) が答えである。 ( \(\lfloor x \rfloor\) は \(x\) の小数点以下切り捨て)
実装例1 (C++):
#include<bits/stdc++.h>
using namespace std;
int main(){
int w,b;
cin >> w >> b;
for(int n=1;;n++){
if(1000*w < n*b){cout << n << "\n"; break;}
}
return 0;
}
実装例2 (C++):
#include<bits/stdc++.h>
using namespace std;
int main(){
int w,b;
cin >> w >> b;
cout << (1000*w/b)+1 << "\n";
return 0;
}
posted:
last update:
