标签:vector mem cin ssi sample hellip 实现 sam NPU
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 6252 Accepted Submission(s): 2380
这个题思路其实很简单,就是把坏人踢出去,好人留下来,用vector可以很好的实现,这是数组很难实现的操作,但是用vector做起来就很简单
代码:
#include <bits/stdc++.h> using namespace std; int main() { vector<int>table; int n,m; while(cin>>n>>m){ table.clear(); for(int i = 0;i < 2*n; i++) table.push_back(i); int pos = 0; for(int i = 0;i <n; i++){ pos = (pos+m-1) % table.size(); table.erase(table.begin() + pos); } int j = 0; for(int i = 0;i < 2*n; i++){ if(!(i%50) && i) cout<<endl; if(j<table.size() && i==table[j]){ j++; cout<<"G"; } else cout<<"B"; } cout<<endl<<endl; } return 0; }
标签:vector mem cin ssi sample hellip 实现 sam NPU
原文地址:https://www.cnblogs.com/jingshixin/p/12236831.html