P1909 [NOIP2016 普及组] 买铅笔

P1909 [NOIP2016 普及组] 买铅笔

在这里插入图片描述

#include<iostream>
using namespace std;
int main(void)
{
    
    
    //p1909
    int n,n1,n2,n3,p1,p2,p3,t1,t2,t3,total;
    cin>>n>>n1>>p1>>n2>>p2>>n3>>p3;

    t1 = n % n1 == 0 ? (n / n1) * p1 : (n / n1 + 1) * p1;
    t2 = n % n2 == 0 ? (n / n2) * p2 : (n / n2 + 1) * p2;
    t3 = n % n3 == 0 ? (n / n3) * p3 : (n / n3 + 1) * p3;

    total = t1;

    if(total > t2)
    {
    
    
        total = t2;
    }

    if(total > t3)
    {
    
    
        total = t3;
    }
    cout<<total<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_44653420/article/details/121503915