10478 - The Falling Pillars
Moderator: Board moderators
nevermind, thats not a good example of what i was looking for.......
is it possible that as successive blocks fall on each other then one block misses the corner of the one to the right and ends up resting on the underside of the the one to its right ? anyway my code should handle this case but its still wa......
is it possible that as successive blocks fall on each other then one block misses the corner of the one to the right and ends up resting on the underside of the the one to its right ? anyway my code should handle this case but its still wa......
-
- System administrator & Problemsetter
- Posts: 399
- Joined: Sat Jan 12, 2002 2:00 am
hmm
Have u considered the case when all the pillars stand straight.
specify???
Can any one tell mee abot any resource or yet at least any primary topic
which will be helpful???
i read the statement and the discussion
unfortunately still in problem
regards
nikhil
which will be helpful???
i read the statement and the discussion
unfortunately still in problem
regards
nikhil
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
Could anyone help me and say, why this code is wrong ? I don't like to post codes, but I think that from amthematical point of view it should be OK, but maybe I'm wrong or I missed something ...
Best regards
DM
Best regards
DM
Code: Select all
#include <stdio.h>
#include <math.h>
#define MAX 10
int main(void)
{
double n,d,h,w,alfa[MAX],z,PI;
int N,k,i,unstable,impossible;
scanf("%d",&N);
PI = acos(-1.0);
for(k=0;k<N;k++)
{
impossible = unstable = 0;
if(scanf("%lf %lf %lf %lf",&n,&d,&h,&w) != 4) break;
alfa[0] = acos((d-w)/h);
if((d <= w) || (h < d-w)) impossible = 1;
if(!impossible)
for(i=1;i<n-1;i++)
{
z = w/sin(alfa[i-1]);
alfa[i] = alfa[i-1] - asin((d - z)*sin(PI - alfa[i-1])/h);
if(!unstable)
if(PI/2.0-alfa[i] < atan(w/h)) unstable = 1;
}
printf("Case %d:\n",k+1);
if(impossible)
printf("Impossible.\n");
else
{
if(unstable) printf("Unstable Situation.\n");
for(i=0;i<n-1;i++) printf("%.3lf\n",alfa[i]*180.0/PI);
}
}
return 0;
}
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany