首页 > 其他分享 >15th

15th

时间:2023-05-08 18:46:42浏览次数:26  
标签:count 10 return int judge 15th

分糖果问题

源代码

#include <iostream>
using namespace std;
int judge(int c[]){
int i;
for(i=0;i<10;i++)
if(c[0]!=c[i])
return 1;
return 0;

}
int main(){
int count=0;
int a[10]={10,2,8,22,16,4,10,6,14,20};
int b[10];
while(judge(a)){
count++;
for(int i=0;i<10;i++){
if(a[i]%2==0){

b[i]=a[i]=a[i]/2;
}
else{

b[i]=a[i]=(a[i]+1)/2;
}
}
for(int k=0;k<9;k++){
a[k+1]=a[k+1]+b[k];
a[0]+=b[9];
}
}
cout<<count;
}

标签:count,10,return,int,judge,15th
From: https://www.cnblogs.com/wcy1111/p/17382793.html

相关文章

  • The 15th Jilin Provincial Collegiate Programming Contest(补题)
    The15thJilinProvincialCollegiateProgrammingContest(补题)这次只做了4个题,感觉自己还有很多不足,加油ヾ(◍°∇°◍)ノ゙这次发现好多题都需要cin加速器,好多题不加这......
  • 15th 2022/7/13 模拟赛总结8
    这次嗯,打得不大好总的来说,是T2正解打挂,然后看见了T3的解决方法却没有深入研究最后T4给了最少的时间然后打完也没有什么事情干,嗯,这种情况可以做出一些改进的方法当然是......