Submitting to PKU

From Progteam

Revision as of 18:46, 17 May 2007 by Hjfreyer (Talk | contribs)
Jump to: navigation, search

Submitting a problem's solution at PKU is a very important part of the programming team. Nine times out of ten, a tough problem you thought you solved actually fails in some edge case. PKU will get you proof that your answer is correct or incorrect.


Getting Started

First, you need to have a PKU JudgeOnline login. Go to the JudgeOnline Homepage to get a login. You can also search for problems here by name or number. Note that in the template for each problem in the wiki, there is a direct link to that problems's entry on PKU.


All solutions submitted must follow certain guidelines:

  1. The solution must be contained in one file.
  2. The file must have one and only one public class, called "Main"
  3. The program must take in the input from Standard Input (this can be done by hooking up a scanner to
  4. The program must write all output to Standard Output (this is done with regular old System.out.print).

Note that the Progteam's Skeleton File already observes all these conventions. You should always start with it as a template.


Go to the PKU page for the problem, scroll to the bottom and hit 'Submit'. Then copy-paste your solution into the text field. Hit submit, and cross your fingers.

A+B Problem

Problem 1000 (A+B) is a simple check to see if everything's working right. The input consists of two integers, the output should consist of their sum. We simply need to take the template, pull the first two integers from the input, and print them to the output:

import java.util.*;

public class Main{

    public static Scanner in;
    public static void main(String[] args){
        in=new Scanner(;


    public static void doStuff(){

Note that in the original file, doStuff contains a loop that calls solve() a number of times equal to the first integer it reads in. This is because the majority of problems on PKU give multiple iterations of the same problem, with the first integer on the input being the number of iterations. This is not the case for this file, so solve() and the loop have been removed.

Personal tools