Submitting to PKU

From Progteam

(Difference between revisions)
Jump to: navigation, search
(A+B Problem)
(A+B Problem: marginally clarified code)
Line 33: Line 33:
     }
     }
-
     public static void doStuff(){
+
     public static void doStuff(){
-
         System.out.println(in.nextInt()+in.nextInt());     
+
         int a=in.nextInt();
 +
        int b=in.nextInt();
 +
 
 +
        System.out.println(a+b);     
     }
     }
}
}

Revision as of 03:31, 28 September 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.

Contents

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(){  
        int a=in.nextInt();
        int b=in.nextInt();
  
        System.out.println(a+b);    
    }
}

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