Could not resolve: (Domain name not found) TJU Problem 3013 Solution | Gal Appelbaum

TJU Problem 3013 Solution


First problem I solve on TJU… figured I’d start posting these up here…

Alfredo’s Pizza Restaurant¬†isn’t such a complex question, very straight forward math… There aren’t any secrets to the code really, fairly simple question to solve.


C++ Solution: This solution is linear, brute force solution.

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

int main()
   int r, w, l, count=1;
   double pizzaRadius=0.0;

      if(r==0) break;
      pizzaRadius = sqrt( (w*1.0)*(w*1.0) + (l*1.0)*(l*1.0) ) / 2.0;
      if( pizzaRadius <= r*1.0 )
         printf("Pizza %d fits on the table.n",count);
         printf("Pizza %d does not fit on the table.n",count);

   return 0;

**For some odd reason the code box is eliminating small things like back slashes (\). So the little typos aren’t really my fault… this question has been submitted and accepted by the TJU website. **


Java Solution: It has a small bug… not in the Algorithm, but somewhere small… I wanna show an algorithm, not give code for free solutions :P

import java.util.Scanner;
import java.lang.Math;

public class TJU3013 {

  public static void main (String[] args){
    Scanner input = new Scanner(;
    int count = 1;
    int r, l, w;
    double PizzaRadius = 0.0;
      r = input.nextInt();
      if(r == 0)
      l = input.nextInt();
      w = input.nextInt();
      PizzaRadius = Math.sqrt((w*1.0)*(w*1.0) + (l*1.0)*(l*1.0)) / 2.0;
      if(PizzaRadius <= r*1.0)
        System.out.printf("Pizza %d fits on table.n", count);
        System.out.printf("Pizza %d does not fit on the table.n", count);

Leave a Reply

Your email address will not be published. Required fields are marked *