0
0

yukicoder No.46 初めのN歩 解説

Last updated at Posted at 2024-07-27

問題文

解説

まず、$BmodA=0$なら答えは$B/A$になる。
そうでないなら答えは$B/A+1$になる。
今回の場合だとbool型で$BmodA$がTrueになるか判定すればいい。

C++での解答例

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

int main(){
  int a,b;cin>>a>>b;
  cout<<b/a+(bool)(b%a)<<endl;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0