题解

22 条题解

  • 2
    @ 2017-10-28 17:45:55

    var n,s,min,a,b,x,y,i,j:longint;
    begin
    read(n,a,b,x,y,i,j);
    min:=n div ab;
    if n mod a<>0 then inc(min,b);
    s:=n div xy;
    if n mod x<>0 then inc(s,y);
    if s<min then min:=s;
    s:=n div ij;
    if n mod i<>0 then inc(s,j);
    if s<min then min:=s;
    write(min);
    end.

  • 2
    @ 2017-10-20 22:37:23

    var n,a,b,c,d,e,f,min,tot:longint;
    begin
    readln(n);
    readln(a,b);
    readln(c,d);
    readln(e,f);
    if (n mod a=0) then tot:=(n div a)*b
    else tot:=((n div a)+1)*b;
    min:=tot;
    if (n mod c=0) then tot:=(n div c)*d
    else tot:=((n div c)+1)*d;
    if tot<min then
    min:=tot;
    if (n mod e=0) then tot:=(n div e)*f
    else tot:=((n div e)+1)*f;
    if tot<min then
    min:=tot;
    writeln(min);
    end.

    • @ 2017-10-28 17:46:23

      var n,s,min,a,b,x,y,i,j:longint;
      begin
      read(n,a,b,x,y,i,j);
      min:=n div a*b;
      if n mod a<>0 then inc(min,b);
      s:=n div x*y;
      if n mod x<>0 then inc(s,y);
      if s<min then min:=s;
      s:=n div i*j;
      if n mod i<>0 then inc(s,j);
      if s<min then min:=s;
      write(min);
      end.

  • 2
    @ 2017-02-15 13:32:04
    #include <algorithm>
    #include <cstdio>
    using namespace std;
    int main() {
        //freopen("pencil.in","r",stdin);
        //freopen("pencil.out","w",stdout);
        int n,Min = 0x7fffffff;
        scanf("%d",&n);
        for (int i = 1;i <= 3;i++) {
            int number,money,count;
            scanf("%d%d",&number,&money);
            count = n/number;
            if (n%number) count++;
            Min = min(Min,count*money);
        }
        printf("%d",Min);
        return 0;
    }
    
  • 1
    @ 2021-08-30 09:09:31
    #include<bits/stdc++.h>
    using namespace std;
    
    int i,j,k,n,m,w,ans;
    int main(){
        cin>>n;
        for(i=0; i<3; i++){
            cin>>j>>k;
            m=j;
            w=k;
            while(j<n){
                j<<=1;
                k<<=1;
            }
            while(j>n){
                j-=m;
                k-=w;
            }
            while(j<n){
                j+=m;
                k+=w;
            }
            if(k<ans || ans==0)
                ans=k;
        }
        cout<<ans;
        return 0;
    }
    
  • 1
    @ 2018-11-03 15:41:54

    其实比赛时还没看题面时,看到数据还以为是背包

    然后再看看题面…

    什么玩意????纯模拟????

    这边一个简便做法

    STL自带ceil,直接向上取整

    其他还有什么好说的吗

    #include<cmath>
    #include<cstdio>
    #include<algorithm>
    int n,a,b,c,ans=2100000000,x,i;
    int main()
    {
    scanf("%d",&n);
    for (;i<3;i++)
    {
    scanf("%d%d",&a,&b);
    x=std::ceil(n*1.0/a)*b;
    ans=std::min(x,ans);
    }
    printf("%d\n",ans);
    return 0;
    }

  • 1
    @ 2017-11-04 20:58:22

    {
    描述

    P老师需要去商店买n支铅笔作为小朋友们参加NOIP的礼物。她发现商店一共有3种包装的铅笔,不同包装内的铅笔数量有可能不同,价格也有可能不同。为了公平起见,**P老师决定只买同一种包装的铅笔。**
    商店不允许将铅笔的包装拆开,因此P老师可能需要购买超过n支铅笔才够给小朋友们发礼物。
    现在P老师想知道,在商店每种包装的数量都足够的情况下,要买够至少n支铅笔 最少 需要花费多少钱。
    格式

    输入格式

    输入的第一行包含一个正整数n,表示需要的铅笔数量。
    接下来三行,每行用两个正整数描述一种包装的铅笔:其中第一个整数表示这种包装内铅笔的数量,第二个整数表示这种包装的价格。
    保证所有的7个数都是不超过10000的正整数。
    输出格式

    输出一行一个整数,表示P老师最少需要花费的钱。
    样例1

    样例输入1

    57
    2 2
    50 30
    30 27
    Copy
    样例输出1

    54
    Copy
    样例2

    样例输入2

    9998
    128 233
    128 2333
    128 666
    Copy
    样例输出2

    18407
    Copy
    样例3

    样例输入3

    9999
    101 1111
    1 9999
    1111 9999
    Copy
    样例输出3

    89991
    Copy
    限制

    【子任务】
    子任务会给出部分测试数据的特点。如果你在解决题目中遇到了困难,可以尝试只解决一部分测试数据。
    每个测试点的数据规模及特点如下表:
    图片
    上表中“整倍数”的意义为:若为“V”,表示对应数据所需要的铅笔数量n—定是每种包装铅笔数量的整倍数(这意味着一定可以不用多买铅笔)。
    提示

    【样例1说明】
    铅笔的三种包装分别是:
    2支装,价格为2;
    50支装,价格为30;
    30支装,价格为27。
    P老师需要购买至少57支铅笔。
    如果她选择购买第一种包装,那么她需要购买29份,共计2 x 29 = 58支,需要花费的钱为2 x 29 = 58。
    实际上,P老师会选择购买第三种包装,这样需要买2份。虽然最后买到的铅笔数量更多了,为30 x 2 = 60支,但花费却减少为27 x 2 = 54,比第一种少。
    对于第二种包装,虽然每支铅笔的价格是最低的,但要够发必须买2份,实际的花费达到了30 x 2 = 60,因此P老师也不会选择。
    所以最后输出的答案是54。
    来源

    NOIP 2016 普及组 第一题
    }
    var n,a1,a2,b1,b2,c1,c2,ans:longint;
    function fmin(x,y:longint):longint;
    begin
    if x<y then exit(x)
    else exit(y);
    end;
    begin
    readln(n);
    readln(a1,a2);
    readln(b1,b2);
    readln(c1,c2);
    ans:=maxlongint;
    if n mod a1=0 then ans:=fmin(ans,n div a1*a2)
    else ans:=fmin(ans,(n div a1+1)*a2);
    if n mod b1=0 then ans:=fmin(ans,n div b1*b2)
    else ans:=fmin(ans,(n div b1+1)*b2);
    if n mod c1=0 then ans:=fmin(ans,n div c1*c2)
    else ans:=fmin(ans,(n div c1+1)*c2);
    writeln(ans);
    end.

  • 1
    @ 2017-11-04 16:09:57

    var n,s,min,i,a,b:longint;
    begin
    read(n);
    min:=maxlongint;
    for i:=1 to 3 do begin
    read(a,b);
    s:=n div ab;
    if n mod a<>0 then inc(s,b);
    if s<min then min:=s;
    end;
    write(min);
    end.

  • 1
    @ 2017-10-28 17:52:02

    var n,s,min,a,b,x,y,i,j:longint;
    begin
    read(n,a,b,x,y,i,j);
    min:=n div ab;
    if n mod a<>0 then inc(min,b);
    s:=n div xy;
    if n mod x<>0 then inc(s,y);
    if s<min then min:=s;
    s:=n div ij;
    if n mod i<>0 then inc(s,j);
    if s<min then min:=s;
    write(min);
    end.

  • 1
    @ 2017-10-18 11:54:54

    #include<iostream>
    using namespace std;
    int jh(int t,int u,int ls){
    ls=t;
    t=u;
    u=ls;
    return t;
    }
    int main(){
    int n,shl[3],jg[3],t[3],i;
    cin>>n;
    for(i=0;i<3;i++){
    cin>>shl[i]>>jg[i];
    if(n%shl[i]==0){
    t[i]=n/shl[i];
    }else{
    t[i]=n/shl[i]+1;
    }
    jg[i]*=t[i];
    }
    if(jg[0]>jg[1]) jg[0]=jh(jg[0],jg[1],0);
    if(jg[0]>jg[2]) jg[0]=jh(jg[0],jg[2],0);
    cout<<jg[0];
    return 0;
    }

  • 1
    @ 2017-10-15 15:27:58

    #include<bits/stdc++.h>
    using namespace std;
    int q[10]={0};
    int main(){
    int n,x,y;
    cin>>n;
    int a,b;
    for(int i=1;i<=3;i++){
    cin>>a>>b;
    int num=0;
    while(num<n){
    q[i]+=b;
    num+=a;
    }
    }
    x=min(q[1],q[2]);
    y=min(q[3],x);
    cout<<y;
    }

  • 1
    @ 2017-07-22 17:36:25

    #include <iostream>
    #include <iomanip>
    #include <cmath>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    #include <cctype>
    #include <vector>
    #include <queue>
    #include <set>
    #include <bitset>
    #include <cassert>
    #include <map>
    #include <string>
    #include <sstream>
    #include <ctime>
    using namespace std;
    int main()
    {
    int a,b,c,d,e,f,g,x,y,z;
    scanf("%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g);
    if(a%b!=0)
    {
    x=(a/b+1)*c;
    }
    else
    {
    x=(a/b)*c;
    }
    if(a%d!=0)
    {
    y=(a/d+1)*e;
    }
    else
    {
    y=(a/d)*e;
    }
    if(a%f!=0)
    {
    z=(a/f+1)*g;
    }
    else
    {
    z=(a/f)*g;
    }
    if(x<=y&&x<=z)
    {
    printf("%d",x);
    }
    else
    {
    if(y<=z)
    {
    printf("%d",y);
    }
    else
    {
    printf("%d",z);
    }
    }
    return 0;
    }

  • 0
    @ 2020-05-20 21:25:07

    枚举算法出奇迹!
    c
    #include<stdio.h>
    int min(int a,int b){
    if(a>b)return b;
    else return a;
    }
    int main(){
    int n,a,b,Min=0x7ffffff,i,j;
    scanf("%d",&n);
    for(i=1;i<=3;i++){
    scanf("%d%d",&a,&b);
    for(j=0;;j++)
    if((j*a)>=n){
    Min=min(Min,j*b);
    break;
    }
    }
    printf("%d",Min);
    return 0;
    }

  • 0
    @ 2018-11-04 09:50:43

    Pascal代码
    var
    x,y,i,n,m,t:longint;
    begin
    read(n);
    dec(n);
    m:=maxlongint;
    for i:=1 to 3 do
    begin
    read(x,y);
    t:=(n div x+1)*y;
    if t<m then m:=t;
    end;
    write(m);
    end.

  • 0
    @ 2018-11-03 15:39:31

    其实比赛时还没看题面时,看到数据还以为是背包

    然后再看看题面…

    什么玩意????纯模拟????

    这边一个简便做法

    STL自带ceil,直接向上取整

    其他还有什么好说的吗

    #include<cmath>
    #include<cstdio>
    #include<algorithm>
    int n,a,b,c,ans=2100000000,x,i;
    int main()
    {
    scanf("%d",&n);
    for (;i<3;i++)
    {
    scanf("%d%d",&a,&b);
    x=std::ceil(n*1.0/a)*b;
    ans=std::min(x,ans);
    }
    printf("%d\n",ans);
    return 0;
    }

  • 0
    @ 2018-08-20 09:10:11
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <queue>
    #include <stack>
    using namespace std;
    
    char rd;    int pn;
    template<typename Type>
    inline void read(Type& v)
    {
        pn=1;
        while((rd=getchar())<'0'||rd>'9')
            if(rd=='-')
                pn=-1;
        v=rd-'0';
        while((rd=getchar())>='0'&&rd<='9')
            v=v*10+rd-'0';
        v*=pn;
    }
    template<typename Type>
    inline void out(Type v,bool c=1)
    {
        if(v==0)
            putchar(48);
        else  
        {
            if(v<0)
            {
                putchar('-');
                v=-v;
            }
            int len=0,dg[20];  
            while(v>0)
            {
                dg[++len]=v%10;
                v/=10;
            }  
            for(int i=len;i>=1;i--)
                putchar(dg[i]+48);  
        }
        if(c)
            putchar('\n');
        else
            putchar(' ');
    }
    
    int n;
    int a1,b1;
    int a2,b2;
    int a3,b3;
    
    void init()
    {
        read(n);
        read(a1);   read(b1);
        read(a2);   read(b2);
        read(a3);   read(b3);
    }
    
    int work(int x,int y)
    {
        if(x>=n)
            return y;
        if(n%x==0)
            return (n/x)*y;
        else
            return ((n/x)+1)*y;
    }
    
    int main()
    {
        init();
        cout<<min(work(a1,b1),min(work(a2,b2),work(a3,b3)))<<endl;
        return 0;
    }
         
    
  • 0
    @ 2018-06-21 15:03:20

    a = int(input(' '))
    c = 3
    d = list()
    e = list()
    h = list()
    while c >= 1:
    b = input(' ')
    d.append(b.split())
    c = c - 1
    for e in d:
    if a % int(e[0]) == 0:
    cost = (a / int(e[0])) * int(e[1])
    else:
    cost = (a - (a % int(e[0]))) / int(e[0]) * int(e[1]) + int(e[1])
    h.append(cost)
    i = min(h)
    print(round(i))

  • 0
    @ 2017-09-21 20:45:09

    NOIP真是水王……
    ……
    ……
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    long long i,all,a,b,answer=9999999999;
    scanf("%lld",&all);
    for(i=1;i<=3;i++)
    {
    long long e=0;
    scanf("%lld %lld",&a,&b);
    if(all%a!=0)
    e=1;
    answer=min(answer,(all/a+e)*b);
    }
    printf("%lld",answer);
    return 0;
    }

  • 0
    @ 2017-08-20 16:38:40

    #include <iostream>
    #include <stdio.h>
    #include <cmath>
    using namespace std;
    int maxn=2147483647;
    int n,a,b;
    int main(){
    cin>>n;
    for(int i=1;i<=3;i++)
    {
    cin>>a>>b;
    int num=n/a;
    if(n%a>0)
    num++;
    maxn=min(maxn,num*b);
    }
    cout<<maxn;
    return 0;
    }

  • -1
    @ 2017-08-24 01:33:12

    so water

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    int main()
    {
        long long i,all,a,b,answer=9999999999;
        scanf("%lld",&all);
        for(i=1;i<=3;i++)
        {
            long long e=0;
            scanf("%lld %lld",&a,&b);
            if(all%a!=0)
                e=1;
            answer=min(answer,(all/a+e)*b);
        }
        printf("%lld",answer);
        return 0;
    }
    
  • -1
    @ 2017-03-24 15:41:20

    var n,a,b,c,d,e,f,min,tot:longint;

    begin
    readln(n);
    readln(a,b);
    readln(c,d);
    readln(e,f);

    if (n mod a=0) then tot:=(n div a)*b
    else tot:=((n div a)+1)*b;

    min:=tot;

    if (n mod c=0) then tot:=(n div c)*d
    else tot:=((n div c)+1)*d;

    if tot<min then
    min:=tot;

    if (n mod e=0) then tot:=(n div e)*f
    else tot:=((n div e)+1)*f;

    if tot<min then
    min:=tot;

    writeln(min);
    end.

    表示笑笑,直接弱智读入,然后每个数据做一遍,结束

信息

ID
2009
难度
3
分类
(无)
标签
递交数
1671
已通过
545
通过率
33%
被复制
20
上传者