1069 微博轉發抽獎 (20 分)
阿新 • • 發佈:2019-05-01
out ++ esp spa lse 轉發 clas mes include
#include <iostream> #include <set> #include <string> using namespace std; set<string>ss; void tmp() { int n, m, t; cin >> t >> n >> m; for (int i = 1; i <= t; i++) { string s; cin >> s; if (i == m && ss.count(s) == 0) { // count() 用來查找set中某個某個鍵值出現的次數 cout << s << endl; ss.insert(s); m += n; } else if (i == m && ss.count(s) != 0) { // 如果當前的重復了就往後遍歷 m++; } } if (ss.empty()) { // 如果set容器為空就是代表沒有 cout<< "Keep going..." << endl; } } int main() { tmp(); return 0; }
1069 微博轉發抽獎 (20 分)