前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ACMSGURU 404 - Fortune-telling with camomile

ACMSGURU 404 - Fortune-telling with camomile

作者头像
Reck Zhang
发布2021-08-11 10:12:16
2100
发布2021-08-11 10:12:16
举报
文章被收录于专栏:Reck Zhang

Fortune-telling with camomile

Problem Description

Masha loves Petya. The following question gives her no rest: does Petya love her too? The best way to find this out is a fortune-telling. There are plenty ways of fortune predicting, but Masha prefers fortune-telling with camomile more than others. It’s rules are simple. You should take camomile into the right hand and start picking petals one by one. After each petal you should pronounce one phrase from the predefined list. Such phrases like “loves”, “doesn’t love”, “loves sincerely”, “doubts”, “wants to date”, “laughs” are usually used. Phrases are pronounced from the first to the last. The list of phrases is cyclic, so after the last phrase you should pronounce the first one. The phrase that you pronounce after the last petal will be an answer.

Since Masha doesn’t want to go to the forest and look for camomiles, she asks you to write the program which will simulate the process.

Input

First line of the input file contains two integer numbers N and M (1 <= N <= 100, 1 <= M <= 100), the number of petals and the number of phrases. Each of the following M lines contains one phrase. Phrases consist only of latin letters and their lengths are between 1 and 100.

Output

Output the resulting phrase.

Example(s)

sample input

sample output

6 4

lovesdoesntsincerelydoubtsdoesnt

|sample input|sample output| |9 3| |loves doesnt hates hates|

Solution

代码语言:javascript
复制
#include <bits/stdc++.h>

int main() {
    std::ios::sync_with_stdio(false);

    int n{};
    int m{};

    std::cin >> n >> m;
    std::vector<std::string> dict(m, "");

    for(int i = 0; i < m; i++) {
        std::cin >> dict[i];
    }

    std::cout << dict[(n - 1) % m];

    return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-10-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Fortune-telling with camomile
    • Problem Description
      • Input
        • Output
          • Example(s)
            • Solution
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档