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;
}
目录
相关文章
|
1月前
|
Python
Calculating Dates
Calculating Dates
A. Calculating Function
A. Calculating Function
49 0
Calculating Function
Calculating Function
94 0
Calculating Function
|
Go
HDOJ 1012 u Calculate e
HDOJ 1012 u Calculate e
111 0
HDOJ 1012 u Calculate e
|
算法
HDOJ 1202 The calculation of GPA
HDOJ 1202 The calculation of GPA
118 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.
2660 0
What Is ElectronJS and Why Should You Use It?