题解 | #买铅笔#

买铅笔

https://ac.nowcoder.com/acm/problem/16437

10行代码,o(1)级别时间复杂度
#include<bits/stdc++.h>
using namespace std;
int main(){
    double num,price,n,min=999999999;
        cin>>n;
    while(cin>>num>>price){
        if(ceil(n/num)*price<min) min=ceil(n/num)*price;
    }
    cout<<int(min);
}


全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务