1
1

yukicoder No.32 貯金箱の憂鬱 解説

Last updated at Posted at 2024-07-24

問題文

解説

まずは、使う小銭・札を見てみよう。
・$1000mod100=0$
・$100mod25=0$
・$25mod1=0$
つまり、この問題は貪欲法が使える
できるだけ小銭の数を小さくするため、下から両替をできるだけする。
最終的に札は数えないことに注意。

解答例

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

int main(){
  int l,m,n;cin>>l>>m>>n;
  m+=n/25;
  n%=25;
  l+=m/4;
  m%=4;
  l%=10;
  cout<<n+m+l<<endl;
}
1
1
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
1
1