From Progteam

Revision as of 08:04, 18 October 2008 by MuGMaN (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Checkmark.jpg This problem has been solved by Eric.

Problem Number 2359
Sorter: meeting
Source: Ural Collegiate Programming Contest 1999

Questions is problem number 2359 on the Peking University ACM site.


Problem Information

Problem Name: Questions
Problem Number on PKU: 2359
Synopsis: Writing a program that automatically answers the questions based on a certain algorithm.

Solver Information

Solver: Eric Hong
Date: October 18, 2008


I got a run-time error at first because Scanner did not recognize a space as an input.

General Strategy

  1. Using Scanner, take the input.
  2. If Scanner returns false for hasNext(), automatically add a space.
  3. Populate a Character array list with each character in a string.
  4. Find a new position for the pointer, wrapping around the array.
  5. Get rid of the characters until only one remains.
  6. Using switch statement, print out the final result.


import java.util.*;

public class Main {

    public static Scanner in;
    public static ArrayList<Character> list = new ArrayList<Character>();
    public static int pointer = 0;
    public static void main(String[] args){
        in=new Scanner(;


   public static void doStuff(){
      String s = "";
      if (in.hasNext() == false) 
         s += " ";
      while (in.hasNext()) 
         s += in.nextLine();
      int len = s.length();
      for (int i = 0; i < len; i++) 

   public static void solve() {	
      final int N = 1999;	
      int round = 1;
      int jump;
      int len = list.size();
      while (len > 1) {
         pointer = (pointer + ((N % len) - 1)) % len;
	 len = list.size();
      char ch = list.get(0);
      switch (ch) {
         case '?': System.out.println("Yes"); break;
	 case ' ': System.out.println("No"); break;
	 default: System.out.println("No comments"); break;

Additional Remarks

Memory: 4868K
Time: 2219MS

This solution may not be as efficient as it can be.

Personal tools