You are viewing a single comment's thread. Return to all comments →
here is my full code.. only four test cases are passed and for rest it shows timedout please help me where the problem is
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner sc=new Scanner(System.in); double kk=sc.nextDouble(); long k=(long)kk; long i,j,sum,total=0,r; for(i=1;i<=k;i++) { j=i; sum=0; while(j>0) { r=j%10; j=j/10; sum=sum+(r*r); } long n=(long)(Math.sqrt(sum)); if((n*n)==sum) total=total+i; } long p=(long)(Math.pow(10,9)+7); System.out.print(total%p); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #171: Finding numbers for which the sum of the squares of the digits is a square
You are viewing a single comment's thread. Return to all comments →
here is my full code.. only four test cases are passed and for rest it shows timedout please help me where the problem is
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}