6 条题解

  • 1
    @ 2025-2-16 10:06:30

    代码有点长,必须一步一步推

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int a,b,c,d,e,f=0;
        cin>>a>>b>>c>>d>>e;
        f=a+b+c+d+e;
        b+=a/3;
        e+=a/3;
        a=a/3;
        a+=b/3;
        c+=b/3;
        b=b/3;
        b+=c/3;
        d+=c/3;
        c=c/3;
        c+=d/3;
        e+=d/3;
        d=d/3;
        d+=e/3;
        a+=e/3;
        e=e/3;
        f=f-a-b-c-d-e;
        cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
        cout<<f;
        return 0;
    }
    
    • 0
      @ 2025-2-15 11:38:16

      #include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e; f=a+b+c+d+e; a=a/3; b=b+a; e=e+a; b=b/3; a=a+b; c=c+b; c=c/3; b=b+c; d=d+c; d=d/3; c=c+d; e=e+d; e=e/3; a=a+e; d=d+e; f=f-a-b-c-d-e; cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl; cout<<f; return 0; }

      • 0
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
          int a,b,c,d,e,f;
        	cin>>a>>b>>c>>d>>e;
        	f=a+b+c+d+e;
        	a=a/3;
        	b=b+a;
        	e=e+a;//第一次分糖
        	b=b/3;
        	a=a+b;
        	c=c+b;//第二次分糖
            c=c/3;
        	b=b+c;
        	d=d+c;//第三次分糖
        	d=d/3;
        	c=c+d;
        	e=e+d;//第四次分糖 
        	e=e/3; 
        	a=a+e;
        	d=d+e;//第五次分糖 
        	f=f-a-b-c-d-e; 
        	cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
        	cout<<f;
        	return 0;
        }
        • 0

          #include<bits/stdc++.h> using namespace std; int a,b,c,d,e,x; int main() { cin>>a>>b>>c>>d>>e; x=a+b+c+d+e; a/=3; b+=a; e+=a; b/=3; a+=b; c+=b; c/=3; b+=c; d+=c; d/=3; c+=d; e+=d; e/=3; a+=e; d+=e; cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl; cout<<x-a-b-c-d-e<<endl;; return 0; }

          • -1
            @ 2024-12-5 12:58:24

            #include<bits/stdc++.h> using namespace std; int num[5],ans=0; int main(){ for(int i=0;i<5;i++) cin >> num[i]; for(int i=0;i<5;i++){ int t=num[i]/3; if(i0)num[4]+=t; else num[i-1]+=t; if(i4)num[0]+=t; else num[i+1]+=t; ans+=num[i]%3; num[i]=t; } for(int i=0;i<5;i++)cout << num[i] << " "; cout << endl << ans << endl;

            return 0;
            

            }

            • -1
              @ 2024-12-5 12:57:50

              #include<bits/stdc++.h> using namespace std; int num[5],ans=0; int main(){ for(int i=0;i<5;i++) cin >> num[i]; for(int i=0;i<5;i++){ int t=num[i]/3; if(i0)num[4]+=t; else num[i-1]+=t; if(i4)num[0]+=t; else num[i+1]+=t; ans+=num[i]%3; num[i]=t; } for(int i=0;i<5;i++)cout << num[i] << " "; cout << endl << ans << endl;

              return 0;
              

              }

              • 1

              信息

              ID
              4470
              时间
              1000ms
              内存
              128MiB
              难度
              1
              标签
              (无)
              递交数
              269
              已通过
              112
              上传者