11646 - Athletics Track

All about problems in Volume 116. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
New poster
Posts: 1
Joined: Fri Sep 04, 2009 9:11 am

11646 - Athletics Track

Post by mklovemu » Fri Sep 04, 2009 9:16 am

Hi all,
I have tried to solve this problem but I got a runtime error. I found out that my program have not terminated, so can anybody how to built a loop input from keyboard tills stop typing anymore?
Here's my code:
import java.util.*;

public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
StringTokenizer temp=new StringTokenizer(s,":");
int length=Integer.parseInt(temp.nextToken());
int width=Integer.parseInt(temp.nextToken());
double tan=(double)(width)/(double)(length);
double angle=Math.atan(tan);
if(angle<0) angle=Math.PI+angle;
double r=Math.sqrt((double)(width*width+length*length))/2;
double perimeter=r*angle*2+(double)length*2;
double l=(double)(length*400)/perimeter;
double w=(double)(width*400)/perimeter;
System.out.printf("%.10f %.10f\n",l,w);


the sc.hasNect() always true, so how can I fix it?

Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong

Re: 11646 Atheletics Track

Post by arifcsecu » Wed Aug 11, 2010 9:19 pm

i solved it in C++

input :

int main()
flaoat a,b;
char ch;

while(scanf("%lf %s %lf",&a,ch,&b)==3)



return 0;
Try to catch fish rather than asking for some fishes.

User avatar
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 11646 Atheletics Track

Post by plamplam » Wed Jul 06, 2011 7:41 pm

I solved it in C. Input is terminated in this problem by eof.

for (; ;)
if (feof(stdin)) break;
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

Post Reply

Return to “Volume 116 (11600-11699)”