Sunday, April 20, 2014

Codechef April Cook-Off 2014 Snape and Ladder solution

Codechef April Cook-Off 2014 Snape and Ladder: http://www.codechef.com/COOK45/problems/SNAPE/

Codechef April Cook-Off 2014 Snape and Ladder editorial: http://discuss.codechef.com/questions/41500/snape-editorial

Codechef April Cook-Off 2014 Snape and Ladder solution: 

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    int t;
    float b, ls, rs;
    scanf("%d", &t);
    while(t--) {
        scanf("%f%f", &b, &ls);
        rs=sqrt(pow(ls, 2) - pow(b, 2));
        printf("%.6f ", rs);
        rs=sqrt(pow(ls, 2) + pow(b, 2));
        printf("%.6f\n", rs);
    }
    return 0;
}

No comments:

Post a Comment