Official
A - Balloon Trip Editorial by en_translator
For beginners
- If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest. There you can find a sample code for each language.
- Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.
- 「Python入門 AtCoder Programming Guide for beginners (APG4bPython)」 is a Python tutorial for competitive programmers. Again, this is only in Japanese.
Original proposer: admin
What we want to find is the smallest integer \(n\) with \(1000W < nB\).
The possible approaches to find this include:
- running a for loop.
- Deform it to \(\displaystyle \frac{1000W}{B} < n\). This implies that the answer is \(\displaystyle \left \lfloor \frac{1000W}{B} \right \rfloor + 1\). (\(\lfloor x \rfloor\) is the value \(x\) but rounded down.)
Sample code 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;
}
Sample code 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: