Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.Math;
- public class task3 {
- static int r,a,b,s,h,last,now,i,j;
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- r=sc.nextInt();
- b=r-1;
- a=(int) Math.floor((Math.sqrt(r*r-b*b)));
- s=a*b*4;
- h=b;
- while (true){
- last=now;
- h--;
- now= (int) Math.floor((Math.sqrt(r*r-h*h)));
- if (last==now) break;
- i++;
- }
- h=b;
- for (j=0; j<i; j++){
- h--;
- s+=4*h;
- }
- if (r==2) System.out.println("4");
- else System.out.println(s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement