1098. Questions
2009-03-14 09:37
204 查看
http://acm.timus.ru/problem.aspx?space=1&num=1098
1098. Questions
Time Limit: 1.0 secondMemory Limit: 16 MB
Holding a collegiate programming contest is a very exhausting work. There is a well-known proverb that one fool can ask so many questions that a hundred clever men will not answer. And during a collegiate programming contest questions are asked by one hundred clever people.
The jury of the Third Urals Collegiate Programming Contest being clever enough has found a simple way to make its work easier. We have invented a simple algorithm that will help us answer ALL your numerous questions! Moreover, this algorithm guarantees that the same questions will have the same answers (this would be hardly possible, if we would undertook such a task ourselves). According to this algorithm a member of the jury starts to delete characters of the question in the following order:
Starting from the first character he or she counts out N−1 characters (spaces, punctuation marks etc. are considered to be characters too) and deletes the Nth character.
If a string ends the count continues from the beginning of the string.
After deleting a character the count restarts from the character that would be the (N+1)-st in the previous count.
If the last remaining character is a question-mark ("?") then the answer to the question is "Yes". If it is a space then the answer is "No". Any other character will lead to "No comments" answer.
You should help the jury and write a program that will do a hard work of answering your questions tomorrow. The number N is secret and will not be announced even after the end of the contest. Your program should use N = 1999.
For example, taking a string "Is it a good question?" (its length is 22) the characters will be counted in the following way: "Is it a good question?Is it … quest" and "i" will be deleted. Then the count restarts from "on?Is it…" etc., until "s" will be left (thus the answer is "No comments", as usual).
Input
The input is a question, that is any text file containing at least one character (end of line is not a character). Each character of the input (excepting the ends of lines) is a part of the question. You should read question from input.The size of the input is not more than 30000.
Output
The answer.Samples
input | output |
---|---|
Does the jury of this programming contest use the algorithm described in this problem to answer my questions? | Yes |
At least, will anybody READ my question? | No |
This is UNFAIR! | No comments |
Hint
There are no spaces in the sample inputs except for those between words in one line. Thus the first question contains 108 characters, the second contains 40 and the third contains 14.using System; class Program { static void Main(string[] args) { string text = Console.In.ReadToEnd().Replace("/r/n", ""); int length = text.Length; char ch = text[ReturnLastIndex(length)]; if (ch == '?') Console.WriteLine("Yes"); else if (ch == ' ') Console.WriteLine("No"); else Console.WriteLine("No comments"); } static int ReturnLastIndex(int length) { if (length == 0) return 1; return (ReturnLastIndex(length - 1) + 1999) % length; } }
相关文章推荐
- URAL 1098 Questions 约瑟夫环
- URAL 1098 Questions 约瑟夫环
- poj 2359 || ural 1098 Questions
- URAL - 1098 Questions——约瑟夫环
- Interview Questions for Software Testing Engineers
- Java Interview Questions
- 5 Questions With Herb Sutter
- STL(shipped with VC6) Questions & Answers(四)
- Pku acm 2371 Questions and answers 排序算法解题报告(三)----二叉查找数(BST)排序
- How To Ask Questions The Smart Way 提问的智慧
- SAP MM Questions & Answer
- .NET Interview Questions And Answers
- Questions
- Java/J2EE Job Interview Companion - 400+ Questions & Answers
- 100 Interview Questions for Software Developers-软件开发者面试百问
- SCEA_Questions
- FICO certification 125 questions
- Important FAQ questions for WPF and Silverlight - Part 3
- BSP TREE FREQUENTLY ASKED QUESTIONS
- Asp Interview Questions and Answers