270 条题解

  • 4
    @ 2017-10-27 20:54:08
    #include<iostream>
    using namespace std;
    int a[13];
    int main()
    {
        int sum=0,sum2=0;
        for(int i=0;i<12;i++)
        {
            cin>>a[i];
        }
        for(int i=0;i<12;i++)
        {
            sum+=300;
            sum-=a[i];
            if(sum<0)
            {
                cout<<"-"<<i+1<<endl;
                return 0;
            }
            sum2+=sum/100*100;
            sum%=100;
        }
        cout<<sum+sum2*1.2<<endl;
        return 0;
    }
    
  • 1
    @ 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;
    }
    
  • 1
    @ 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;
    }
    
  • 1
    @ 2017-08-25 11:37:30

    #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;
    }

  • 1
    @ 2017-05-08 07:52:04

    暴力模拟就好啦~

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <iomanip>
    #include <cstdlib>
    using namespace std;
    
    int a[13];
    int b;
    int n;
    
    int main()
    {
        for(int i=1;i<=12;i++)
            cin>>a[i];
        for(int i=1;i<=12;i++)
        {
            b+=300;
            if(b<a[i])
            {
                cout<<-i<<endl;
                return 0;
            }
            else
                b-=a[i];
            while(b>=100)
                {b-=100,n++;}
        }
        cout<<n*120+b<<endl;
        return 0;
    }
         
    
  • 1
    @ 2017-05-01 11:23:30

    注意加上没有存进储蓄的自己手里的钱……低级错误

    #include<iostream>
    using namespace std;
    
    int main()
    {
        int ys,money,chux=0;
        for (int i=1;i<=12;i++)
        {
            cin>>ys;
            money=300+money-ys;
            if (money<0)
            {
            cout<<-i;
            return 0;
            }
            if (money>=100)
            {
                chux=chux+money-money%100;
                money%=100;
            }
        }
        cout<<chux*120/100+money;
        return 0;
    }
    
    • @ 2017-11-06 19:57:50

      谢谢。。。

  • 1
    @ 2017-03-29 20:12:21

    #include<stdio.h>
    int main()
    {
    int year[12];
    int money=0;
    int mom=0;
    for(int i=0;i<12;i++)
    {
    scanf("%d",&year[i]);
    }
    for(int i=0;i<12;i++)
    {
    money+=300;
    if(money>=year[i])
    {
    money-=year[i];
    if(money>=100)
    {
    mom+=money-money%100;
    money-=money-money%100;
    }
    else
    {
    money+=0;
    }
    }
    else
    {
    printf("-%d",i+1);
    return 0;
    }
    }
    money+=(mom/100)*120;
    printf("%d",money);
    }

  • 0
    @ 2019-02-21 16:40:36

    #include <stdio.h>

    int main()
    {
    int money[12],i=0;
    int in=0,out=0,total,con=1,month,TotalOut=0;
    for (i=0; i<12;i++)
    {
    scanf("%d",&money[i]);
    }
    i=0;
    for (i=0;i<12;i++)
    {
    in+=300;
    in-=money[i];
    if (in<0)
    {
    month=i+1;
    con=0;
    break;
    }
    out=in-in%100;
    TotalOut+=out;
    in-=out;
    }
    if (con==1)
    {
    total=in+TotalOut*1.2;
    printf("%d",total);
    }
    else
    {
    printf("-%d",month);
    }
    return 0;
    }

  • 0
    @ 2018-12-27 21:54:29
    #Python 解法,请多指教
    def process(budget, balance, Mama):
    
        if balance + 300 - budget >= 100:
            Mama = 100 * ((balance + 300 - budget) // 100) + Mama
            balance = (balance + 300 - budget) % 100
        
             
        else:
            balance = balance + 300 - budget
        return balance, Mama
    
    
    balance = 0
    Mama = 0
    
    for i in range(1, 13):
        budget = int(input())
        balance, Mama = process(budget, balance, Mama)
        
        if balance < 0:
            print("-{}".format(i))
            break
        if i == 12:
            print(int(Mama*1.2 + balance))
        i = i + 1
        
    
  • 0
    @ 2018-11-03 21:06:38

    c++代码
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a,s=0,t=0;
    for(int i=1;i<=12;i++){
    cin>>a;
    s=s+300-a;
    if(s<0){
    cout<<"-"<<i;
    return 0;
    }
    if(s>=100){
    t=t+s/100*100;
    s=s-s/100*100;
    }
    }
    cout<<fixed<<setprecision(0)<<s+t*1.2;
    return 0;
    }

  • 0
    @ 2018-10-20 12:09:55

    program jingjing;
    var n,ans,m,i:longint;
    a:array[1..12] of longint;
    begin
    n:=0;
    ans:=0;
    m:=0;
    for i:=1 to 12 do
    readln(a[i]);
    for i:=1 to 12 do
    begin
    n:=n+300-a[i];
    if n<0 then
    begin
    m:=-i;
    writeln(m);
    exit;
    end;
    if n>100 then
    begin
    ans:=ans+n div 100;
    n:=n mod 100;
    end;
    end;
    n:=n+ans*120;
    writeln(n);
    end.

  • 0
    @ 2018-10-20 12:09:08

    program jingjing;
    var a:array [1..12] of longint;
    yuan,cun,c1,c2,i,n:longint;
    begin
    yuan:=0;
    for i:=1 to 12 do
    readln(a[i]);
    for i:=1 to 12 do
    begin
    yuan:=yuan+300-a[i];
    if yuan<0 then
    begin n:=-i; writeln(n); exit; end;
    if yuan>=100 then
    begin
    cun:=cun+yuan div 100;
    yuan:=yuan mod 100;
    end;
    end;
    cun:=cun*120;
    yuan:=yuan+cun;
    writeln(yuan);
    end.

  • 0
    @ 2018-10-14 22:33:52

    #include<iostream>
    #include<math.h>
    using namespace std;
    int a[13] = { 0 };
    struct money
    {
    int moneyToMum = 0;
    int remain[13] = {0};
    }jing;
    int main()
    {
    int j = 1;
    for (int i = 1; i <= 12; i++)
    cin >> a[i];
    while(j <= 12)
    {
    jing.remain[j] = jing.remain[j - 1] + 300 - a[j];
    if (jing.remain[j] < 0)
    {
    cout << "-" << j;
    return 0;
    }
    if (jing.remain[j] >= 100)
    {
    int temp;
    temp = jing.remain[j] % 100;
    jing.moneyToMum += jing.remain[j]-temp;
    jing.remain[j]=temp;
    }
    j++;
    }
    cout << jing.remain[12] + jing.moneyToMum + jing.moneyToMum*0.2;
    return 0;
    }

  • 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-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;
    }

信息

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