i was trying to solve this problem "Elevator" from the Brazilian National Contest

http://uva.onlinejudge.org/index.php?op ... oblem=2934

my approach is to get the minimum diagonal of a rectangle to enclose the 2 circles, and if this diagonal is <= the diagonal of the elevator, then i print 'S', else i print 'N'. however this approach fails in the fourth sample test case and i can't think of any other approach. i also don't see how we can pack the 2 circles in the fourth test case :S

Code: Select all

```
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <complex>
using namespace std;
#define epsilon 0.00000000001
int main(){
int h,w,r1,r2;
double needed, actual;
scanf("%d %d %d %d",&h,&w,&r1,&r2);
while(h||w||r1||r2){
needed = r1+hypot(r1,r1)+r2+hypot(r2,r2);
actual = hypot(h,w);
if(needed-actual < epsilon) printf("S\n");
else printf("N\n");
}
return 0;
}
```