# Bullseye

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 This problem has been solved by msobell.

 Sorter: Uncategorized Unknown http://acm.pku.edu.cn/JudgeOnline/problem?id=2272

Bullseye is problem number 2272 on the Peking University ACM site.

## CODE

```//RUNNING: java Main < input.txt

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 N = in.nextInt();
//	for(int i = 0; i < N; i++) {
solve();
//	}
}

public static void solve(){
int[] score = new int[2];
while (true) {
score[0] = score[1] = 0;
for(int player = 0; player < 2; player++) {
for(int darts = 0; darts < 3; darts++) {
double x = in.nextDouble();
if( x == -100.0 ) System.exit(0);
double y = in.nextDouble();
double r = x*x + y*y;
r = Math.sqrt(r);
score[player] += scoreDart(r);
}
}
String result = new String();
if(score[0]>score[1]) {
result = "PLAYER 1 WINS.";
}
else if(score[0]<score[1]) {
result = "PLAYER 2 WINS.";
} else {
result ="TIE.";
}
System.out.println("SCORE: " + score[0] + " to " + score[1] + ", " + result);
}
}

public static int scoreDart( double r ) {
int score = 0;
if ( ((r/3) % 1 == 0) && (r/3) > 0 )  {
score = (int)(r / 3) - 1; //r is on a boundary
} else {
score = (int)Math.floor(r / 3); //put into the correct ring
}
//	System.out.print(score + " ");
if( score > 5 ) score = 5;
score = 100 - score * 20;
//	System.out.println(score);
return score;
}
}
```