题解 | #买铅笔#

买铅笔

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

#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int b,c,ans=10000000;
    for(int i=0;i<3;i++){
     int  a=0;
    cin>>b>>c;
    int t=n/b;
    if(n%b==0){
     a=t*c;
    }
    else if(b>n){
        a=c;
    }
    else{
        a=(t+1)*c;
    }
        if(ans>a){
            ans=a;
        }
    }
  cout<<ans;
    return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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