Advertisement
Guest User

Untitled

a guest
Apr 24th, 2011
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. private void solve() {
  2. long x = in.readLong();
  3. long y = in.readLong();
  4. long r = in.readLong();
  5.  
  6. long[] squares = new long[1000001];
  7.  
  8. for(long i = 0; i <= 1000000; i++) {
  9. squares[(int) i] = i * i;
  10. }
  11.  
  12. long result = 0;
  13.  
  14. for(long i = 0; i < r; i++) {
  15. long current = r * r - i * i;
  16.  
  17. int b = Arrays.binarySearch(squares, current);
  18.  
  19. if(b < 0) {
  20. b = ~b;
  21. }
  22.  
  23. result += b;
  24. }
  25.  
  26. out.println(4 * result);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement