# Submitting to PKU

(Difference between revisions)
 Revision as of 18:42, 17 May 2007 (view source)Hjfreyer (Talk | contribs) (New page: 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. P...)← Older edit Revision as of 18:45, 17 May 2007 (view source)Hjfreyer (Talk | contribs) (→A+B Problem)Newer edit → Line 21: Line 21:

+                                                                                                       import java.util.*;

+                                                                                                       public class Main{
+
+                                                                                                       public static Scanner in;
+
+                                                                                                       public static void main(String[] args){
+                                                                                                       in=new Scanner(System.in);
+
+                                                                                                       doStuff();
+                                                                                                       }
+
+                                                                                                       public static void doStuff(){
+                                                                                                       System.out.println(in.nextInt()+in.nextInt());
+                                                                                                       }
+                                                                                                       }

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

## Revision as of 18:45, 17 May 2007

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.

## Guidelines

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

## Submitting

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

doStuff();
}

public static void doStuff(){
System.out.println(in.nextInt()+in.nextInt());
}
}
```

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.