We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #229: Four Representations using Squares
  4. Discussions

Project Euler #229: Four Representations using Squares

Contest ends in
Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • shubhamprakash13
    4 years ago+ 1 comment

    import java.io.; import java.util.; public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
    
    Scanner scan= new Scanner(System.in);
    int a= scan.nextInt();
    long []ar= new long[a];
    for(int i=0;i<a;i++)
    {
    ar[i]= scan.nextInt();
    }  
    long count=0;
    long count1=0;
    for(long x=1;x<ar[0];x++)
    {
        for(int y=1;y<ar[0];y++)
        {
          if(((ar[0]==((x*x)+(y*y)))) &&((ar[0]==((x*x)+(2*y*y))))
          && ((ar[0]==((x*x)+(3*y*y)))) &&((ar[0]==((x*x)+(7*y*y)))))
           {
            ++count;
           }
        }
    }
    for(long x=1;x<ar[1];x++)
    {
         for(int y=1;y<ar[1];y++)
        {
        if(((ar[1]==((x*x)+(y*y)))) &&((ar[1]==((x*x)+(2*y*y))))
          && ((ar[1]==((x*x)+(3*y*y)))) &&((ar[1]==((x*x)+(7*y*y)))))
           {
            ++count1;
           }
    }
    }
    System.out.println(count);     
    System.out.println(count1);
    }
    

    }

    NOTE:- Guys m' not able to find the mistake please refer this code and ping me.

    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy