telling with camomile

404. Fortune-telling with camomile

Time limit per test: 0.25 second(s)Memory limit: 65536 kilobytes

input: standardoutput: standard

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

(1 ≤N≤ 100, 1 ≤M≤ 100), the number of petals and the number of phrases. Each of the followingMlines 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 inputsample output

6 4lovesdoesntsincerelydoubtsdoesnt

sample inputsample output

9 3lovesdoesnthateshates

思路:数花瓣,,每一次念一个字符串…….取个模就OK啦………

AC代码:

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char str[105][105];int main() {int N, M;while(scanf("%d %d", &N, &M) != EOF) {for(int i = 1; i <= M; i++) {scanf("%s", str[i]);}int ans = N % M;if(ans == 0) ans = M;printf("%s\n", str[ans]);}return 0;}

若不给自己设限,则人生中就没有限制你发挥的藩篱。

telling with camomile

相关文章:

你感兴趣的文章:

标签云: