280 条题解

  • 3
    @ 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

      谢谢。。。

  • 2
    @ 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
    @ 2023-07-02 23:03:47
    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
        double ans=0;
        int a[12]={},j,k,s=0;
        for(j=0;j<12;j++)  cin>>a[j];
        for(j=0;j<12;j++){
            s+=300;
            s-=a[j];
            if(s<0){
                j++;
                cout<<-j;
                return 0;
            }
            for(k=0;k<37;k++){
                if(s>=100){
                    s-=100;
                    ans+=100;
                }
                else{
                    break;
                }
            }
        }
        ans*=1.2;
        cout<<ans+s;
    }
    
  • 1
    @ 2023-05-15 19:10:33

    这题看得我意犹未尽。。。给我3分钟都能做出来
    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    double ans=0;
    int a[12]={},j,k,s=0;
    for(j=0;j<12;j++) cin>>a[j];
    for(j=0;j<12;j++){
    s+=300;
    s-=a[j];
    if(s<0){
    j++;
    cout<<-j;
    return 0;
    }
    for(k=0;k<37;k++){
    if(s>=100){
    s-=100;
    ans+=100;
    }
    else{
    break;
    }
    }
    }
    ans*=1.2;
    cout<<ans+s;
    }

  • 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
    @ 2024-07-12 15:02:39

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    int n=0,cq=0;
    int a[15];
    for(int i=1;i<=12;i++){
    cin>>a[i];
    }
    for(int i=1;i<=12;i++){
    n+=300;
    if(n<a[i]){
    cout<<"-"<<i;
    return 0;
    }else if((n-a[i])>100){
    cq+=((n-a[i])-(n-a[i])%100);
    n-=((n-a[i])-(n-a[i])%100);
    }
    n-=a[i];
    }
    cout<<n+(cq*1.2);
    return 0;
    }

  • 0
    @ 2021-10-29 18:45:32

    **//废话不多说,代码如下
    #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;
    }

  • 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.

信息

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