1 #include <iostream> 2 using namespace std; 3 int main(){ 4 int n,m; 5 cin>>n>>m; 6 int g=n,t=0,li,s[n+1],b; 7 for(int i=1;i<=n;i++){ 8 s[i]=i; 9 } 10 while(g){ 11 t+=1,b=0,li=0,g-=(g+2)/3; 12 cout<<"第"<<t<<"次,我拿了编号为"; 13 for(int i=1;i<=n;i++){ 14 if(s[i]!=0){ 15 li++; 16 if((li-1)%3==0){ 17 s[i]=0; 18 cout<<i<<","; 19 if(m==i)b=1; 20 } 21 } 22 } 23 cout<<"\b"; 24 cout<<"的苹果,还剩"<<g<<"个"; 25 if(b){ 26 cout<<",并且我这次拿到了编号为"<<m<<"的苹果!"; 27 } 28 cout<<endl; 29 } 30 return 0; 31 }
标签:小苹果,apple,int,-----------,2023,CSP From: https://www.cnblogs.com/liujiaxing-/p/18447185