每日一题 Day8:CodeForces-996A.Hit the Lottery(贪心)
生活随笔
收集整理的這篇文章主要介紹了
每日一题 Day8:CodeForces-996A.Hit the Lottery(贪心)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?原題鏈接
因為數(shù)據(jù)太水,我直接一發(fā)暴力過了......
#include <cstdio> using namespace std;int value[5] = {100, 20, 10, 5, 1};int main() {int n, ans = 0;scanf("%d", &n);while(n > 0) {for(int i = 0; i < 5; i ++) {if(n >= value[i]) {ans ++;n -= value[i];break;}}}printf("%d\n", ans);return 0; } #include <cstdio> using namespace std;int value[5] = {100, 20, 10, 5, 1};int main() {int n, ans = 0;scanf("%d", &n);for(int i = 0; i < 5; i ++) {if(n >0) {ans += (n / value[i]);n = n % value[i];}}printf("%d\n", ans);return 0; }?
轉(zhuǎn)載于:https://www.cnblogs.com/bianjunting/p/10941200.html
總結(jié)
以上是生活随笔為你收集整理的每日一题 Day8:CodeForces-996A.Hit the Lottery(贪心)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微星主板怎么开启CPU虚拟化技术VT-X
- 下一篇: 计算机显示器本身物理分辨率,电脑显示器常