# Questions

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 This problem has been solved by Eric.

 Sorter: meeting Ural Collegiate Programming Contest 1999 http://acm.pku.edu.cn/JudgeOnline/problem?id=2359

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

## Trivia

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.

## Solution

```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(System.in);

doStuff();
}

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++)

solve();
}

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;
list.remove(pointer);
len = list.size();
}

char ch = list.get(0);

switch (ch) {
case '?': System.out.println("Yes"); break;
case ' ': System.out.println("No"); break;
}
}
}
```