| ||||||||||
| 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 | |||||||||
有谁能帮我看看程序吗?poj1328,小弟刚来,帮帮忙?看看有什么错。。In Reply To:POJ的论坛功能太好太强大了~~~ Posted by:goodhorsezxj at 2007-11-13 16:47:46 package poj;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Vector;
public class poj1328 {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
Vector<Integer> vec =new Vector<Integer>();
while(cin.hasNext()){
int temp=cin.nextInt();
int num=0;
int cov=0;
while(cin.hasNext()){
cov=cin.nextInt();
break;
}
if(temp==0&&cov==0)
break;
double[][] a = new double[temp][2];
while(cin.hasNext()){
int x=cin.nextInt();
int y=0;
while(cin.hasNext()){
y=cin.nextInt();
break;
}
//求出该岛屿在海岸上所能放的范围
double t=Math.sqrt(cov*cov-y*y);
a[num][0]=x-t;
a[num][1]=x+t;
if(temp-1==num)break;
num++;
}
double dt=0;
//按照范围的右端进行升序排序
for(int i=0;i<temp;i++){
for(int j=i+1;j<temp;j++){
if(a[i][1]>a[j][1]){
dt=a[i][1];a[i][1]=a[j][1];a[j][1]=dt;
dt=a[i][0];a[i][0]=a[j][0];a[j][0]=dt;
}
}
}
int count =0;
int total = 0;
int[] flag=new int[temp];
for(int i=0;i<temp;i++){
count=0;
for(int j=0;j<temp;j++){
if(flag[j]!=1)
if(a[i][1]>=a[j][0]){
count++;
flag[j]=1;
}
}
if(count>0)
total+=1;
}
vec.add(total);
}
Iterator<Integer> e=vec.iterator();
int Case=1;
while(e.hasNext()){
System.out.println("Case "+Case+": "+e.next());
Case++;
}
vec.clear();
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator