結果

問題 No.304 鍵(1)
ユーザー not_522not_522
提出日時 2016-06-20 01:33:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 3,058 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 168,928 KB
実行使用メモリ 15,384 KB
最終ジャッジ日時 2023-09-24 00:08:58
合計ジャッジ時間 7,774 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

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

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

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

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

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

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

template<typename T> class Arithmetic : public IndivisibleArithmetic<T>, public 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(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() : val(0) {}

  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 *this += 1;}

  Mint operator--() {return *this -= 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 a, b, c;
  cin >> a >> b >> c;
  cout << (b * c - a * c) / (a * c - b * c + a * b) << " ";
  cout << (b * c - a * b) / (a * c - b * c + a * b) << endl;
}
0