All about problems in Volume CIX. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
by arjun2304 » Mon Jun 04, 2012 11:23 am
- Code: Select all
#include<iostream>
#include<cstdio>
#include<cmath>
#include<climits>
using namespace std;
int xc[110],yc[110],r[110];
double a[110][110];
double min(double x,double y)
{
if(x>y)return y;
return x;
}
double max(double x,double y)
{
if(x>y)return x;
return y;
}
double distance(int x1,int y1,int x2,int y2)
{
return sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
}
int main()
{
int i,j,n,sx,sy,sr,dx,dy,dr;
double k,m;
while(scanf("%lf%lf",&k,&m)==2)
{
cin>>xc[0]>>yc[0]>>r[0]>>dx>>dy>>dr;
cin>>n;
for(i=1;i<=n;i++)
scanf("%d%d%d",&xc[i],&yc[i],&r[i]);
xc[n+1]=dx;yc[n+1]=dy;r[n+1]=dr;
for(i=0;i<=n+1;i++)
{
for(j=0;j<=n+1;j++)
{
a[i][j]=INT_MAX;
}
a[i][i]=0;
}
for(i=0;i<=n+1;i++)
{
for(j=i+1;j<=n+1;j++)
{
a[i][j]=a[j][i]=distance(xc[i],yc[i],xc[j],yc[j])-r[i]-r[j];
}
}
for(k=0;k<=n+1;k++)
{
for(i=0;i<=n+1;i++)
{
for(j=0;j<=n+1;j++)
{
a[i][j]=min(a[i][j],max(a[i][k],a[k][j]));
}
}
}
if(a[0][n+1]>(k*m)||a[0][n+1]==INT_MAX)
printf("Larry and Ryan will be eaten to death.\n");
else
printf("Larry and Ryan will escape!\n");
}
return 0;
}
-
arjun2304
- New poster
-
- Posts: 1
- Joined: Sat May 05, 2012 4:34 pm
by brianfry713 » Mon Jun 04, 2012 11:00 pm
Compile Error:
- Code: Select all
code.cpp: In function 'int main()':
code.cpp:57:31: error: invalid types 'double [110][double]' for array subscript
code.cpp:57:36: error: invalid types 'double [110][110][double]' for array subscript
-
brianfry713
- Guru
-
- Posts: 1742
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
by DD » Sat Mar 02, 2013 8:22 am
This problem is easy enough so you should not get W.A.
Have you ever...
Wanted to work at best companies?
Struggled with interview problems that could be solved in 15 minutes?
Wished you could study real-world problems?
If so, you need to read
Elements of Programming Interviews.
-
DD
- Experienced poster
-
- Posts: 145
- Joined: Thu Aug 14, 2003 8:42 am
- Location: Mountain View, California
-
Return to Volume CIX
Who is online
Users browsing this forum: No registered users and 1 guest