标签:mes mil div nbsp memset tom 模拟 names col
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 7955 Accepted Submission(s): 2851
很经典的问题,利用vector的erase方法可以很方便的模拟
#include<bits/stdc++.h> using namespace std; int i,pos,n,m,f[100000]; int main() { while(cin>>n>>m) { memset(f,0,sizeof(f)); vector<int>a; for(i=0;i<2*n;i++) { a.push_back(i); } pos=0; for(i=0;i<n;i++) { pos=(pos+m-1)%a.size(); a.erase(a.begin()+pos); } for(i=0;i<a.size();i++) { f[a[i]]=1; } int k=1; for(i=0;i<2*n;i++) { if(f[i]==1) { cout<<"G"; } else { cout<<"B"; } if(k%50==0||i==(2*n-1)) { cout<<endl; } k++; } cout<<endl; } }
标签:mes mil div nbsp memset tom 模拟 names col
原文地址:https://www.cnblogs.com/dyhaohaoxuexi/p/12596424.html