結果

問題 No.72 そろばん Med
ユーザー not_522not_522
提出日時 2015-07-19 19:05:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 3,105 bytes
コンパイル時間 1,271 ms
コンパイル使用メモリ 147,440 KB
実行使用メモリ 18,696 KB
最終ジャッジ日時 2023-08-13 15:52:06
合計ジャッジ時間 4,068 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
18,516 KB
testcase_01 AC 59 ms
18,512 KB
testcase_02 AC 60 ms
18,576 KB
testcase_03 AC 61 ms
18,504 KB
testcase_04 AC 60 ms
18,496 KB
testcase_05 AC 59 ms
18,564 KB
testcase_06 AC 61 ms
18,560 KB
testcase_07 AC 61 ms
18,308 KB
testcase_08 AC 59 ms
18,564 KB
testcase_09 AC 59 ms
18,512 KB
testcase_10 AC 58 ms
18,516 KB
testcase_11 AC 59 ms
18,608 KB
testcase_12 AC 59 ms
18,332 KB
testcase_13 AC 60 ms
18,640 KB
testcase_14 AC 60 ms
18,636 KB
testcase_15 AC 59 ms
18,452 KB
testcase_16 AC 59 ms
18,556 KB
testcase_17 AC 60 ms
18,320 KB
testcase_18 AC 61 ms
18,540 KB
testcase_19 AC 61 ms
18,552 KB
testcase_20 AC 59 ms
18,696 KB
testcase_21 AC 60 ms
18,512 KB
testcase_22 AC 60 ms
18,696 KB
testcase_23 AC 60 ms
18,440 KB
testcase_24 AC 60 ms
18,632 KB
testcase_25 AC 60 ms
18,560 KB
testcase_26 AC 60 ms
18,504 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> {};

class Inverse {
private:
  long long mod;
	vector<long long> inv;
  
public:
  Inverse() {}
  
	Inverse(long long mod, long long n = 1000000) : mod(mod) {
    inv = vector<long long>(n, 1);
    for (int i = 2; i < n; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
  }
  
	long long operator()(long long a) const {
		if (a < (int)inv.size()) return inv[a];
		long long b = mod, x = 1, y = 0;
		while (b) {
			long long t = a / b;
			swap(a -= t * b, b);
			swap(x -= t * y, y);
		}
		return (x %= mod) < 0 ? x + mod : x;
	}
};

class Mint : public Arithmetic<Mint> {
private:
  static long long mod;
  static Inverse inverse;
  long long val;
	
public:
	Mint() {}

	Mint(const long long& val) {
    this->val = val % mod;
    if (this->val < 0) this->val += mod;
  }

  static void setMod(const long long& m) {
    mod = m;
    inverse = Inverse(m);
  }
	
	Mint operator+=(const Mint& m) {
		val += m.val;
		if (val >= mod) val -= mod;
		return *this;
	}
  
	Mint operator-=(const Mint& m) {
		val -= m.val;
		if (val < 0) val += mod;
		return *this;
	}
  
	Mint operator*=(const Mint& m) {
		val *= m.val;
		val %= mod;
		return *this;
	}
  
	Mint operator/=(const Mint& m) {
		val *= inverse(m.val);
		val %= mod;
		return *this;
	}
	
	Mint operator++() {return val += 1;}
	
	operator long long() {
		return val;
	}

  Mint identity() const {
    return 1;
  }
};

long long Mint::mod = 1000000007;
Inverse Mint::inverse(1000000007);

ostream& operator<<(ostream& os, Mint a) {
	os << (long long)a;
	return os;
}

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

int main() {
  Mint::setMod(1000007);
  long long n;
  cin >> n;
  Mint a = n / 2 + 1, b = (n + 1) / 2 + 1;
  cout << a * b - 1 << endl;
}
0