276 条题解

  • 3
    @ 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;
    }
    
  • 2
    @ 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
    @ 2021-07-28 11:42:46
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
            int a[20];
            for (int i = 1; i <= 12; i++)
            {
                    //存入每个月的预算
                    cin >> a[i];
            }
            //sum:津津手里有的钱
            int sum = 0;
            //mum:存在妈妈那里的钱
            int mum = 0;
            for (int i = 1; i <= 12; i++)
            {
                    //每月300零花钱
                    sum += 300;
                    if (a[i] > sum)//如果这个月钱不够
                    {
                            //输出
                            cout << -i << endl;
                            return 0;
                    }
                    else if (sum - a[i] > 100)//如果津津剩下的钱多于100
                    {
                            mum += (sum - a[i]) / 100 * 100;//存在妈妈那里
                            sum = (sum - a[i]) % 100;
                    }
                    else//如果剩下的钱不够100
                    {
                            //直接花掉
                            sum -= a[i];
                    }
            }
            //剩下的钱=津津手里的钱+妈妈手里的钱*1.2
            cout << sum + mum * 1.2 << endl;
            system("pause");
    }
    
    
  • 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-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
    @ 2021-09-09 14:33:01

    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream>
    using namespace std;

    int main()
    {
    int q,w,a,b,c,d,e,f,g,h,i,j,k,l,m,n;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j>>k>>l;
    w=0;
    w=w+300;
    if(w-a>=0)
    {q=(w-a-((w-a)%100));//cun ru de qian
    w=w-a-(w-a-((w-a)%100));
    w=w+300;
    if(w-b>=0)
    {

    q=q+(w-b-((w-b)%100));
    w=w-b-(w-b-((w-b)%100))+300;
    if(w-c>=0)
    {q=q+(w-c-((w-c)%100));
    w=w-c-(w-c-((w-c)%100))+300;
    if(w-d>=0){
    q=q+(w-d-((w-d)%100));
    w=w-d-(w-d-((w-d)%100))+300;
    if(w-e>=0){
    q=q+(w-e-((w-e)%100));
    w=w-e-(w-e-((w-e)%100))+300;
    if(w-f>=0)
    { q=q+(w-f-((w-f)%100));
    w=w-f-(w-f-((w-f)%100))+300;
    if(w-g>=0)
    { q=q+(w-g-((w-g)%100));
    w=w-g-(w-g-((w-g)%100))+300;
    if(w-h>=0)
    q=q+(w-h-((w-h)%100));
    w=w-h-(w-h-((w-h)%100))+300;
    if (w-i>=0)
    { q=q+(w-i-((w-i)%100));
    w=w-i-(w-i-((w-i)%100))+300;
    if (w-j>=0)
    { q=q+(w-j-((w-j)%100));
    w=w-j-(w-j-((w-j)%100))+300;
    if(w-k>=0)
    {
    q=q+(w-k-((w-k)%100));
    w=w-k-(w-k-((w-k)%100))+300;
    if(w-l>=0)
    { q=q+(w-l-((w-l)%100));
    w=w-l-(w-l-((w-l)%100))+300;
    if (w-m>=0)
    {q=q*1.2;
    n=w-m+q;
    out<<n-300;

    }else cout<<-12;
    }else cout<<-11;

    }else cout<<-10;
    }else cout<<-9;
    }else cout<<-8;
    }else cout<<-7;

    }else cout<<-6;

    }
    else cout<<-5;
    }
    else cout<<-4;
    }
    else cout<<-3;
    }
    else
    cout<<-2;
    }
    else
    cout<<-1;

    return 0;
    }

  • 0
    @ 2020-06-29 13:06:36

    此题略水。纯枚举,用好整除和求模运算,不会太难的。另外,注意别模0,否则,你懂得。。。

    代码如下:
    ```
    01.var i,s,p,z:integer;

    02. a:array[1..12]of integer;

    03. tt:real;

    04. f:boolean;

    05.begin

    06. s:=0;p:=0;z:=0;f:=true;

    07. for i:=1 to 12 do begin

    08. readln(a[i]);

    09. s:=s+300-a[i];

    10. if(s<0)and f then begin
    11. z:=i;
    12. f:=false;
    13. end;
    14. if s>=100 then begin

    15. p:=p+(s div 100)*100;

    16. s:=s mod 100;

    17. end;

    18. end;

    19. tt:=s+p*1.2;

    20. if z=0 then writeln(tt:0:0)

    21. else writeln('-',z);

    22.end.

  • 0
    @ 2020-03-17 19:27:13
    #include<iostream>
    using namespace std;
    
    int month[12];
    
    int main() {
        int mother = 0;
        int jingjing = 0;
        
        for(int i = 0 ; i < 12 ; ++i) {
            cin >> month[i];    
        }
        
        for(int i = 0 ; i < 12 ; ++i) {
             jingjing = jingjing + 300 - month[i];  
             if(jingjing < 0) {
                cout << "-"<<i + 1<<endl;
                return 0;
             }          
             
             while(jingjing >= 100) {
                jingjing -= 100;
                mother += 100;
             }
        }
        
        cout << 1.2 * mother + jingjing << endl; 
        return 0;   
        
    } 
    
  • 0
    @ 2019-12-10 19:36:33

    #include <iostream>
    using namespace std;

    int main() {
    int money = 0;
    int store = 0;
    int i = 0;
    int moneyNeedNow = 0;
    int moneyWillStore = 0;
    int flag = 0;//不够
    while (i++ < 12) {
    cin >> moneyNeedNow;
    money = money+ 300- moneyNeedNow;
    if (money >= 100) {
    moneyWillStore = 100 * (money / 100);
    money -= moneyWillStore;
    store += moneyWillStore;
    }
    else if (money < 0) {
    flag = 1;
    break;
    }
    }
    if (flag == 1) {
    cout << "-" << i << endl;
    }
    else {
    cout << money + store * 1.2 << endl;
    }
    return 0;
    }

  • 0
    @ 2019-09-17 21:12:03
    #include <stdio.h>
    
    int main()
    {
        int str[12];
        int i, money = 0, m = 0;
        for (i = 0;i < 12;i++) scanf("%d", &str[i]);
        for (i = 1;(money >= 0)&&(i<13);i++)
        {
            money += 300 - str[i - 1]; //当前月份剩的钱
            while ((money>=0)&&(money / 100))
            {
                money -= 100;
                m++;
            }
        }
        if (money >= 0) printf("%d\n", 120 * m + money);
        else printf("-%d\n", i-1);
    }
    
  • 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-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;
    }
    

信息

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