zoukankan      html  css  js  c++  java
  • SGU 404 Fortune-telling with camomile

    404. Fortune-telling with camomile

    Time limit per test: 0.25 second(s)
    Memory limit: 65536 kilobytes
    input: standard
    output: 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

    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
    loves
    doesnt
    sincerely
    doubts
    
    doesnt
    
    sample input
    sample output
    9 3
    loves
    doesnt
    hates
    
    hates
    
     1 #include<iostream>  
     2 #include<string.h>  
     3 #include<stdio.h>  
     4 #include<ctype.h>  
     5 #include<algorithm>  
     6 #include<stack>  
     7 #include<queue>  
     8 #include<set>  
     9 #include<math.h>  
    10 #include<vector>  
    11 #include<map>  
    12 #include<deque>  
    13 #include<list>  
    14 using namespace std;
    15 char str[110][110];
    16 int main()
    17 {
    18     int n,m;
    19     while(scanf("%d%d",&n,&m)==2){
    20         for(int i=1;i<=m;i++){
    21             scanf("%s",str[i]);
    22         }
    23         int ans=n%m;
    24         if(ans==0) printf("%s
    ",str[m]);
    25         else printf("%s
    ",str[ans]);
    26     }
    27     return 0;
    28 }
    View Code
  • 相关阅读:
    解决SharePoint 文档库itemadded eventhandler导致的上传完成后,编辑页面保持报错的问题,错误信息为“该文档已经被编辑过 the file has been modified by...”
    解决SharePoint 2013 designer workflow 在发布的报错“负载平衡没有设置”The workflow files were saved but cannot be run.
    随机实例,随机值
    Spring4笔记
    struts2笔记(3)
    struts2笔记(2)
    获取文本的编码类型(from logparse)
    FileUtil(from logparser)
    DateUtil(SimpleDateFormat)
    struts2笔记
  • 原文地址:https://www.cnblogs.com/qscqesze/p/3880004.html
Copyright © 2011-2022 走看看