Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这样读数据会RuntimeError吗?

Posted by twf at 2008-03-12 15:22:53 on Problem 1276
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
  public static void main(String[] args)
    { Scanner sc = new Scanner(System.in);  PrintStream out = System.out;
      while(sc.hasNextInt())
        {
          int cash = sc.nextInt();
          int N = sc.nextInt();
          if (N == 0) { out.println(0); continue; }
          
          int sum = 0;
          for (int i = 0; i < N; i++)
            { n[i] = sc.nextInt(); D[i] = sc.nextInt();              
              sum += n[i]*D[i]; }
          sc.nextLine();
          if (sum <= cash) { out.println(sum); continue; }
          /*。。。*/    
          int max;
          for (max = cash; !c[max][N - 1]; max--);
          out.println(max);
        }
    } 
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator