279 条题解

  • 0
    @ 2018-08-26 13:51:01
    nowm = 0
    savem = 0
    for i in range(1,13):
        tmp = int(input())
        nowm += 300
        if tmp > nowm:
            print("-{}".format(i))
            exit()
        else:
            nowm -= tmp
            savem += (nowm // 100)
            nowm %= 100
    nowm += savem * 120
    print(nowm)
    

    python 就是简洁

  • 0
    @ 2018-08-18 18:01:25

    p党标程
    var
    i,s,x,bank:longint;
    begin
    for i:=1 to 12 do
    begin
    s:=s+300;
    readln(x);
    if s<x then
    begin
    writeln(-i);
    halt;
    end;
    s:=s-x;
    bank:=bank+s div 100;
    s:=s mod 100;
    end;
    writeln(bank*120+s);
    end.

  • 0
    @ 2018-08-18 09:56:50

    绝对的一A

    #include<iostream>
    using namespace std;
    int main()
    {
        int y=0,ans=0,s=0,n,c=0;
        bool a=1;
        for(int i=1;i<=12;i++)
        {
            cin>>n;
            y=s+300;
            if(a&&y<n)
            {
                ans=i-i-i;
                a=0;
            }
            else
            {
                c+=(y-n)/100*100;
                s=(y-n)%100;
                y-=(y-n)/100*100;
                y-=n;
            }
        }
        if(a) cout<<c/100*120+s;
        else cout<<ans;
        return 0;
    }
    
  • 0
    @ 2018-08-18 09:56:32
    #include<iostream> 
    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    using namespace std;
    int main()
    {
        int i=0,x,y=0,a;
        float t=0;
        while(i<12)
        {
            ++i;
            cin>>x;
            if(300+y-x<0) 
            {
                cout<<"-"<<i;
                return 0;
            }
            a=(300+y-x)/100;
            t=t+1.2*100*a;
            y=300-100*a+y-x;
        }
        cout<<t+y;
        return 0;
    }
    
  • 0
    @ 2018-08-09 19:39:09

    托儿索来助你们一臂之力
    var

    s,h,t,i:longint;

    begin

    s:=0;

    h:=0;

    for i:=1 to 12 do
    begin

    read(t);

    inc(s,300);

    if t>s then
    begin
    write('-',i);
    exit;
    end;

    inc(h,(s-t) div 100);

    dec(s,(s-t) div 100*100+t);

    end;

    write(s+h*120);

    end.

  • 0
    @ 2018-06-22 20:01:01

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a,b=0;
    double c=0;
    for(int i=1;i<=12;i++){
    cin>>a;
    b+=300;
    if(b<a){cout<<-i;
    return 0;
    }
    b-=a;
    if(b>100){c+=b/100*100;
    b=b%100;}
    }
    cout<<c*1.2+b<<endl;
    return 0;
    }

  • 0
    @ 2018-06-02 19:12:39

    【分析】
    此题考查的是模拟:
    1)框架
    int main()
    {
    int 定义:结余,预算,存款;
    for (从1月~12月)
    {
    输入预算;
    得出本月结余并存款;
    当结余出现负数时:
    }
    输出总的攒钱数;
    return 0;
    }
    2)运行过程当中(样例),可能会输入一半就输出-7了,很正常。若想全部输出,可以利用文件的输入与输出,这里介绍一下文件的处理方法:
    [注意:双斜线中的内容]
    #include <cstdio> //文件所用到的头文件cstdio
    using namespace std;
    int main()
    {
    freopen("a+b=c.in","r",stdin); //将输入文件开
    freopen("a+b=c.out","w",stdout);//将输出文件开
    int a,b,c;
    scanf("%d%d",&a,&b);
    c=a+b; //操作
    printf("%d\n",c);
    fclose(stdin);fclose(stdout); //将输入、输出文件关
    return 0; //结束程序
    }
    【标程】
    #include <iostream>
    #define MONTH 300
    using namespace std;
    int main()
    {
    int change=0,cost,bank=0;//结余,预算,存款
    for (int i=1;i<=12;i++)//从1月~12月
    {
    cin>>cost;//输入
    change+=MONTH-cost;//得出本月结余
    if (change>=100)//如果本月结余可以存款
    {
    bank+=change/100*100;//存款累计
    change%=100;//求出存款后的结余
    }
    if(change<0)//当结余出现负数时
    {
    cout<<"-"<<i<<endl;//输出
    return 0;
    }
    }
    cout<<bank*(1+20*1.0/100)+change<<endl;//输出月末钱
    return 0;
    }

  • 0
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int arr1[13];//数组越界问题
        int sum=0,a=0,c=0;
        for(int i=1;i<=12;i++){
            cin>>arr1[i];
        }
    
        for(int i=1;i<=12;i++){
            if(i==1){
                a=300-arr1[i];//剩余的钱
                if(a<0){
                    cout<<"-1"<<endl;
                    break;
                }else{
                    sum+=(a/100)*100;//存的钱
                     c=a-((a/100)*100);//除去存的钱之外,还剩下多少钱?
                }
            }
        }
        for(int i=2;i<=12;i++){
                  a=300-arr1[i]+c;
                   if(a<0){
                       cout<<"-"<<i<<endl;
                       break;
                   }else{
                        sum+=(a/100)*100;
                        c=a-((a/100)*100);
                   }
                   if(i==12){
                       cout<<sum*1.2+c<<endl;
                   }
        }
        return 0;
    }
    
    

    这个题不是很难理解,但是一直想不通不能AC,
    困扰我一两天,突然突发奇想,是不是数组的空间不够啊,
    改了下,果然成功了,心态崩了

  • 0
    @ 2018-04-29 15:49:49

    简单C++程序
    #include<iostream>
    using namespace std;
    int main(){
    int c,s=0,h=0;
    for(int i=1;i<=12;i++)
    {
    cin>>c;
    s-=c-300;
    if(s<0)
    {
    cout<<"-"<<i;
    return 0;
    }
    else h+=s/100,s%=100;
    }
    cout<<(120*h+s);
    return 0;
    }

  • 0
    @ 2018-03-10 19:44:13

    #include<cstdio>
    int a,num=0,add;
    int main(){
    for(int i=1;i<=12;i++){
    scanf("%d",&a);
    num+=300-a;
    if(num>=100)
    {add+=num/100;num=num%100;}
    if(num<0)
    {printf("%d",-i);break;}
    if(i==12)
    {printf("%d",num+add*120);}
    }
    }

  • 0
    @ 2018-01-06 22:25:23

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    int a[13],s,ans=0,k=0,j=0;
    float x;
    for (int i=1;i<=12;i++)
    {
    scanf("%d",&a[i]);
    s=300+ans-a[i];
    if (s<0)
    {
    printf("%d",-i);
    return 0;
    }
    j=s;
    s/=100;
    k+=s*100;
    j-=s*100;

    ans=j;
    }
    x=k*1.2;
    ans+=x;
    printf("%d",ans);
    return 0;
    }

  • 0
    @ 2017-11-21 16:36:07
    #include <iostream>
    #include<cstdlib>
    #include<cstdio>
    #include<map>
    #include<vector>
    #include<cstring>
    #include<algorithm>
    #define mod 7654321
    #define FOR(i,x,y) for(i=x;i<=y;++i)
    #define maxa 1000+100
    using namespace std;
    int a[maxa];
    int main()
    {
        int i;
        FOR(i,1,12)
        cin>>a[i];
        int t,m,s = 0;
        t =0;
        FOR(i,1,12)
        {
            s+=300;
            if(s<a[i])
            {
                cout<<"-"<<i<<endl;
                return 0;
            }
            else
            {
                s-=a[i];
                t+=s/100;
                s = s%100;
            }
        }
        cout<<t*120+s<<endl;
    }
    
    
  • 0
    @ 2017-09-03 11:31:07
    #include<iostream>
    using namespace std;
    int main(){
        int x,s=0,t=0,i;
        for(i=1;i<13;i++){
        cin >> x;
        t=t+300-x;
        if(t<0) break;
        s=s+(t/100)*100;
        t=t-(t/100)*100;
        }
        if(t<0) cout << "-" << i <<endl;
        else cout << s+s/5+t << endl;
        return 0;
    }
    
  • 0
    @ 2017-09-01 15:31:47

    嗯。很可爱的题。

    #include <iostream>
    using namespace std;
    int N=12;
    int A, B;
    int main () {
        
        int C;
        for(int i=1; i<=N; i++) {
            A+=300;
            cin >> C; 
            if (C>A) {
                cout << -1*i;   
                return 0;
            }   
            A-=C;
            B+=A-(A%100);
            A%=100; 
        }
        cout << (int)(A+B*1.2);
        return 0;
        
    }
    
  • 0
    @ 2017-08-29 11:31:19

    #include<iostream>
    int main()
    {
    using namespace std;
    int sum=0,x=0,y,a[13];
    for (int i=1;i<=12;i++) cin>>a[i];
    for (int i=1;i<=12;i++)
    {
    sum+=300;
    if (sum<a[i])
    {
    cout<<-i;return 0;
    }
    while (sum-a[i]>=100)
    {
    sum-=100;
    y+=100;
    }
    sum-=a[i];
    }
    cout<<sum+y*1.2<<endl;
    return 0;
    }
    c++新人,,,刚开始用pascal提交,好无语

  • 0
    @ 2017-08-25 11:37:10

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cstdlib>
    #include <cmath>
    #define pi 3.14159265358979
    #define eps 1e-10
    #define TN 50002
    using namespace std;
    int a[101];
    int ans,tt,l;
    int main()
    {
    for(int i=1;i<=12;i++) scanf("%d",&a[i]);
    for(int i=1;i<=12;i++)
    {
    ans+=300;
    if(ans<a[i]) {printf("-%d",i);return 0;}

    //if(ans-a[i]>=100)
    {l=(ans-a[i])/100;ans=(ans-a[i])%100;tt+=l*100;}
    }
    printf("%d",120*tt/100+ans);
    return 0;
    }

  • 0
    @ 2017-08-23 19:01:14

    #include<cmath>
    #include<iostream>
    using namespace std;
    int cant=0;
    double mid;
    double ans;
    int ys[12],nd;
    int own,mom;
    int main()
    {
    for(int i=1;i<=12;i++)
    cin>>ys[i-1];
    for(int i=1;i<=12;i++)
    {
    own=own-ys[i-1];
    if(own<0)
    {
    nd=-own;
    mid=(double)nd/100;
    if(floor(mid)==mid)
    nd=(floor(mid))*100;
    else
    nd=(floor(mid)+1)*100;
    if(nd>300)
    {
    cant=1;
    ans=-i;
    break;
    }

    }
    own=own+nd;
    mom=mom-nd+300;
    nd=0;
    }
    if(cant==0)
    ans=(double)own+(mom*1.2);
    cout<<ans;
    return 0;
    }

  • 0
    @ 2017-08-18 11:13:31

    真的很简单……
    include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    long long a[13],m=1,n,sum=0,x,f;
    double v=0;
    for(int i=1;i<=12;++i)
    {
    cin>>a[i];
    sum=sum+300-a[i];
    if(sum<0)
    {
    m=0;
    f=i;
    break;
    }
    else
    {
    n=sum/100;
    v=v+n*100;
    sum=sum%100;
    }
    }
    if(m==1)
    {
    v=v*1.2+sum;
    printf("%.0f",v);
    }
    else
    {
    cout<<"-"<<f;
    }
    }

  • 0
    @ 2017-07-20 04:39:45

    #include <iostream>
    using namespace std;
    int main(){
    int money=0;
    int count=0;
    int j;
    for( j=1;j<=12;j++){
    int cost;
    cin>>cost;
    money+=300;
    if(money<cost){
    cout<<-j<<endl;
    break;
    }
    else {
    int n=(money-cost)/100;
    count+=n;
    money=money-cost-n*100;
    }
    }
    if(j==13)cout<<(money+1.2*count*100)<<endl;
    return 0;
    }

  • 0
    @ 2017-03-30 15:49:34

    WHAT A PITY!
    #include<stdio.h>
    int main()
    {
    int month[13]={0};
    int j=0,mom=0,i;
    float all;
    for(i=1;i<13;i++)
    scanf("%d",&month[i]);
    for(i=1;i<13;i++)
    {
    j=300-month[i];
    if(j<0)
    {
    printf("-%d",i);
    return 0;
    }
    mom=j/100*100;
    j=j%100;
    }
    all=mom*1.2+j;
    printf("%g",all);
    }

信息

ID
1096
难度
5
分类
模拟 点击显示
标签
递交数
15974
已通过
5661
通过率
35%
被复制
35
上传者