求优化!!!!全RE,这是我目前想到最简的方法了
  • 板块B2020 分糖果
  • 楼主tuxxx
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/6/7 21:43
  • 上次更新2024/6/8 09:51:28
查看原帖
求优化!!!!全RE,这是我目前想到最简的方法了
371749
tuxxx楼主2024/6/7 21:43
#include<bits/stdc++.h>
using namespace std;
int a[5],sum=0;
int main(){
    for(int i=1;i<=5;i++) scanf("%d",&a[i]);
    for(int i=1;i<=5;i++){
        int t=a[i]/3;
        if(i==0) a[4]+=t;
        else a[i-1]+=t;
        if(i==1) a[0]+=t;
        else a[i+1]+=t;
        sum+=a[i]%3;
        a[i]=t;
    }
    for(int i=1;i<=5;i++) cout<<a[i]<<" ";
    cout<<endl;
    cout<<sum;
    return 0;
}
2024/6/7 21:43
加载中...