“Sometimes it is the people no one can imagine anything of who do the things no one can imagine.” ― Sir Alan Turing


ADS

ADS

Saturday, April 8, 2017

UVa 11854 Egypt Solution in C / C++


Source Code

#include<stdio.h>

int main() {
  long int a, b, c, d, e, f;
  while (scanf("%ld%ld%ld", & a, & b, & c) == 3) {
    d = a * a;
    e = b * b;
    f = c * c;
    if (a != 0 || b != 0 || c != 0) {
      if (f == d + e)
        printf("right\n");
      else if (d == e + f)
        printf("right\n");
      else if (e == d + f)
        printf("right\n");
      else
        printf("wrong\n");
    }
  }
  return 0;
}

No comments:

Post a Comment