AtCoderABC257E - Addition and Multiplication

简介: AtCoderABC257E - Addition and Multiplication

题目链接

nyist最终淘汰赛第一场 - Virtual Judge (csgrandeur.cn)


一些话

用0x3f初始化minn,结果wa了

发现0x四个3f才是1e9,一个3f只有63,之前归纳的有问题

流程

贪心题,先保证位数,再从大到小贪


套路


ac代码

#include <iostream>
using namespace std;
const int N = 1e6 + 10;
int a[N];
int main(){
    int n;
    cin >> n;
    int minn = 1e9;
    for(int i = 1; i <= 9;i++){
        cin >> a[i];
        minn = min(minn,a[i]);
    }
    int k = n / minn;
    for(int i = 1;i <= k;i++){
        for(int j = 9;j >= 1;j--){
            if(n - a[j] >= minn * (k - i)){
                n -= a[j];
                cout << j;
                break;
            }
        }
    }
    return 0;
}
目录
相关文章
|
4月前
|
前端开发 JavaScript 算法
shouldComponentUpdate 是做什么的?
shouldComponentUpdate 是做什么的?
52 0
ValueError: Sample larger than population or is negative
ValueError: Sample larger than population or is negative
146 0
|
算法
HDOJ 1202 The calculation of GPA
HDOJ 1202 The calculation of GPA
73 0
|
JavaScript 安全 前端开发
What Is ElectronJS and Why Should You Use It?
In this three-part tutorial, we will explore how to create a fully functional invoice application using ElectronJS and ApsaraDB for MongoDB.
2616 0
What Is ElectronJS and Why Should You Use It?