| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:Runtime error, admin帮看看,谢过In Reply To:Runtime error, admin帮看看,谢过 Posted by:gniuxiao at 2007-04-12 16:23:08 > import static java.lang.Math.*;
> import static java.lang.Integer.*;
> import static java.lang.Long.*;
> import static java.math.BigInteger.*;
> import static java.util.Arrays.*;
> import static java.util.Collections.*;
> import java.math.*;
> import java.text.*;
> import java.util.*;
> import java.io.*;
>
> class Node
> {
> Node(int lo, int hi, Node p)
> {
> this.lo = lo;
> this.hi = hi;
> this.p = p;
> }
>
> int v, lo, hi;
> Node lt, rt, p;
> }
>
> public class Main
> {
> static int[] res;
>
> static Node build(int lo, int hi, Node p)
> {
> Node n = new Node(lo, hi, p);
> if (hi-lo > 0) {
> n.lt = build(lo, (lo+hi)/2, n);
> n.rt = build((lo+hi)/2+1, hi, n);
> }
> return n;
> }
>
> static void run(String[] args) throws Exception
> {
> int i, j, k, t, m, n;
> Scanner cin = new Scanner(System.in);
> n = cin.nextInt();
> res = new int[n+5];
>
> Node root = build(1, 32767, null);
>
> for (i=0; i<n; ++i) {
> int idx = cin.nextInt();
> cin.nextInt(); // no use
> m = 0;
> Node cur = root;
> while (true) {
> if (cur.hi == idx) {
> m += cur.v;
> ++cur.v;
> break;
> }
> else if (cur.hi < idx) {
> m += cur.v;
> cur = cur.p.rt;
> }
> else {
> ++cur.v;
> cur = cur.lt;
> }
> }
> ++res[m];
> }
> for (i=0; i<n; ++i)
> out.println(res[i]);
> }
>
> public static void main(String[] args) throws Exception
> {
> run(args);
> }
>
> static PrintStream out = System.out;
> static PrintStream err = System.err;
> }
我用的也是java也是runtime errer
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator