結果

問題 No.98 円を描こう
ユーザー not_522not_522
提出日時 2015-07-14 21:00:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 4,997 bytes
コンパイル時間 4,015 ms
コンパイル使用メモリ 146,316 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 15:46:00
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

namespace arithmetic {
  template<typename T> class Addition {
  public:
    template<typename V> T operator+(const V& v) const {
      T res(static_cast<const T&>(*this));
      return res += static_cast<T>(v);
    }
  };

  template<typename T> class Subtraction {
  public:
    template<typename V> T operator-(const V& v) const {
      T res(static_cast<const T&>(*this));
      return res -= static_cast<T>(v);
    }
  };

  template<typename T> class Multiplication {
  public:
    template<typename V> T operator*(const V& v) const {
      T res(static_cast<const T&>(*this));
      return res *= static_cast<T>(v);
    }
  };

  template<typename T> class Division {
  public:
    template<typename V> T operator/(const V& v) const {
      T res(static_cast<const T&>(*this));
      return res /= static_cast<T>(v);
    }
  };

  template<typename T> class Modulus {
  public:
    template<typename V> T operator%(const V& v) const {
      T res(static_cast<const T&>(*this));
      return res %= static_cast<T>(v);
    }
  };
}

template<typename T> class IndivisibleArithmetic : public arithmetic::Addition<T>, public arithmetic::Subtraction<T>, public arithmetic::Multiplication<T> {};

template<typename T> class Arithmetic : public IndivisibleArithmetic<T>, public arithmetic::Division<T> {};

template<typename T> class Ordered {
public:
  template<typename V> bool operator==(const V& v) const {
    return !(static_cast<T>(v) < static_cast<const T&>(*this) || static_cast<const T&>(*this) < static_cast<T>(v));
  }
  
  template<typename V> bool operator!=(const V& v) const {
    return static_cast<T>(v) < static_cast<const T&>(*this) || static_cast<const T&>(*this) < static_cast<T>(v);
  }

  template<typename V> bool operator>(const V& v) const {
    return static_cast<T>(v) < static_cast<const T&>(*this);
  }

  template<typename V> bool operator<=(const V& v) const {
    return !(static_cast<T>(v) < static_cast<const T&>(*this));
  }

  template<typename V> bool operator>=(const V& v) const {
    return !(static_cast<const T&>(*this) < static_cast<T>(v));
  }
};

class Real : public Arithmetic<Real>, public arithmetic::Modulus<Real>, public Ordered<Real> {
private:
  static long double EPS;
  long double val;

public:
  Real() {}

  Real(long double val) : val(val) {}

  template<typename T> Real operator+=(const T& r) {
    val += static_cast<long double>(r);
    return *this;
  }
  
  template<typename T> Real operator-=(const T& r) {
    val -= static_cast<long double>(r);
    return *this;
  }
  
  template<typename T> Real operator*=(const T& r) {
    val *= static_cast<long double>(r);
    return *this;
  }
  
  template<typename T> Real operator/=(const T& r) {
    val /= static_cast<long double>(r);
    return *this;
  }

  template<typename T> Real operator%=(const T& r) {
    long double v = static_cast<long double>(r);
    val -= floor(val / v) * v;
    return *this;
  }
  
  template<typename T> bool operator<(const T r) const {
    return val < static_cast<long double>(r) - EPS;
  }

  operator long double() const {
    return val;
  }
};

long double Real::EPS = 1e-8;

inline ostream& operator<<(ostream& os, const Real& a) {
  stringstream ss;
	ss << fixed << setprecision(15) << (long double)a;
  os << ss.str();
  return os;
}

inline istream& operator>>(istream& is, Real& a) {
	long double n;
	is >> n;
	a = n;
	return is;
}

class Point : public Arithmetic<Point> {
public:
  Real x, y;

  Point() {}

  Point(const Real& x) : x(x), y(0) {}

  Point(const Real& x, const Real& y) : x(x), y(y) {}

  Point operator+=(const Point& p) {
    x += p.x;
    y += p.y;
    return *this;
  }

  Point operator-=(const Point& p) {
    x -= p.x;
    y -= p.y;
    return *this;
  }

  Point operator*=(const Point& p) {
    Real xx = x * p.x - y * p.y;
    y = x * p.y + y * p.x;
    x = xx;
    return *this;
  }

  Point operator/=(const Point& p) {
    Real nrm = p.norm();
    Real xx = (x * p.x + y * p.y) / nrm;
    y = (y * p.x - x * p.y) / nrm;
    x = xx;
    return *this;
  }

  Real norm() const {
    return x * x + y * y;
  }

  Real abs() const {
    return sqrt(norm());
  }
};

inline Real norm(const Point& point) {
  return point.norm();
}

inline ostream& operator<<(ostream& os, const Point& point) {
	os << point.x << " " << point.y;
	return os;
}

inline istream& operator>>(istream& is, Point& point) {
  Real x, y;
	is >> x >> y;
	point = Point(x, y);
	return is;
}

template<typename T> inline T gcd(T a, T b) {
  return __gcd(a, b);
}

template<typename T> inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

template<typename T> inline T floor(T a, T b) {
  return a / b * b <= a ? a / b : a / b - 1;
}

template<typename T> inline T ceil(T a, T b) {
  return floor(a + b - 1, b);
}

template<typename T> inline T round(T a, T b) {
  return floor(a + b / 2);
}

int main() {
  Point p;
  cin >> p;
  cout << (int)floor(p.abs() * 2 + 1, Real(1)) << endl;
}
0