1069 微博转发抽奖 (20 分)

#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;
}

原文地址:https://www.cnblogs.com/Hk456/p/10798876.html

时间: 2024-07-30 15:30:15

1069 微博转发抽奖 (20 分)的相关文章

PTA乙级 (1069 微博转发抽奖 (20分)(vector,map))

1069 微博转发抽奖 (20分) https://pintia.cn/problem-sets/994805260223102976/problems/994805265159798784 1.使用vector来保存输入的用户名. 2.使用map来进行筛选,记录用户是否已经中奖. 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cmath> 5 #in

PAT Basic 1069 微博转发抽奖 (20 分)

小明 PAT 考了满分,高兴之余决定发起微博转发抽奖活动,从转发的网友中按顺序每隔 N 个人就发出一个红包.请你编写程序帮助他确定中奖名单. 输入格式: 输入第一行给出三个正整数 M(≤ 1000).N 和 S,分别是转发的总量.小明决定的中奖间隔.以及第一位中奖者的序号(编号从 1 开始).随后 M 行,顺序给出转发微博的网友的昵称(不超过 20 个字符.不包含空格回车的非空字符串). 注意:可能有人转发多次,但不能中奖多次.所以如果处于当前中奖位置的网友已经中过奖,则跳过他顺次取下一位. 输

1069. 微博转发抽奖(20)

1069. 微博转发抽奖(20) 小明PAT考了满分,高兴之余决定发起微博转发抽奖活动,从转发的网友中按顺序每隔N个人就发出一个红包.请你编写程序帮助他确定中奖名单. 输入格式: 输入第一行给出三个正整数M(<= 1000).N和S,分别是转发的总量.小明决定的中奖间隔.以及第一位中奖者的序号(编号从1开始).随后M行,顺序给出转发微博的网友的昵称(不超过20个字符.不包含空格回车的非空字符串). 注意:可能有人转发多次,但不能中奖多次.所以如果处于当前中奖位置的网友已经中过奖,则跳过他顺次取下

PAT 1069. 微博转发抽奖

PAT 1069. 微博转发抽奖 小明PAT考了满分,高兴之余决定发起微博转发抽奖活动,从转发的网友中按顺序每隔N个人就发出一个红包.请你编写程序帮助他确定中奖名单. 输入格式: 输入第一行给出三个正整数M(<= 1000).N和S,分别是转发的总量.小明决定的中奖间隔.以及第一位中奖者的序号(编号从1开始).随后M行,顺序给出转发微博的网友的昵称(不超过20个字符.不包含空格回车的非空字符串). 注意:可能有人转发多次,但不能中奖多次.所以如果处于当前中奖位置的网友已经中过奖,则跳过他顺次取下

PAT 甲级 1069 The Black Hole of Numbers (20 分)(内含别人string处理的精简代码)

1069 The Black Hole of Numbers (20 分) For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by taking the second

pat 1124 Raffle for Weibo Followers(20 分)

1124 Raffle for Weibo Followers(20 分) John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts.

1124 Raffle for Weibo Followers (20 分)

1124 Raffle for Weibo Followers (20 分) John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts

B站动态转发抽奖脚本+教程

运行python脚本需要的条件: 1.连通的网络 2.已安装Python2并配置环境变量 3.Python脚本源码 环境搭建: 网络就不用我说了("'▽'")  那么下面我们来安装python吧. Python官网有2个版本2和3,我们选择2,因为语法等方面会有所不同. Python2下载:https://www.python.org/downloads/windows/ 具体安装教学可百度,或参考 教程:https://www.runoob.com/python/python-ins

PTA-C-4-7 统计某类完全平方数 (20分)

4-7 统计某类完全平方数   (20分) 本题要求实现一个函数,判断任一给定整数N是否满足条件:它是完全平方数,又至少有两位数字相同,如144.676等. 函数接口定义: int IsTheNumber ( const int N ); 其中N是用户传入的参数.如果N满足条件,则该函数必须返回1,否则返回0. 裁判测试程序样例: #include <stdio.h> #include <math.h> int IsTheNumber ( const int N ); int ma