Don't like ads? PRO users don't see any ads ;-)
Guest

NSV

By: a guest on Apr 28th, 2012  |  syntax: C++  |  size: 0.36 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. typedef long long LL;
  5.  
  6. int main()
  7. {    
  8.     LL r; cin >> r;
  9.     LL cnt = 0;
  10.     for (LL x = 0; x < r; ++x)
  11.     {
  12.         double y = sqrt(double(r * r - x * x));
  13.         LL Y = y;
  14.         if (y > Y)
  15.             ++Y;
  16.         cnt += Y;
  17.     }
  18.     cnt *= 4;
  19.  
  20.     cout << cnt << endl;
  21.     return 0;
  22. }