This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub granddaifuku/library
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_B" #include <bits/stdc++.h> using namespace std; #include "../../Math/modint.cpp" int main() { int n, k; Modint<> mint = Modint<>(1); cin >> n >> k; if (n > k) { cout << 0 << endl; return 0; } for (int i = k, j = 0; j < n; --i, ++j) mint *= i; cout << mint.v << endl; }
#line 1 "test/aoj/DPL_5_B.test.cpp" #define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_B" #include <bits/stdc++.h> using namespace std; #line 1 "Math/modint.cpp" #line 5 "Math/modint.cpp" using namespace std; template<typename T = long long, T Modulus = 1000000007> class Modint { public: T v; constexpr Modint(signed v_) : v(v_) {} constexpr Modint(long long v_ = 0) noexcept : v(v_ % Modulus) { if (v < 0) v += Modulus; } Modint pow (long long k) { Modint res(1), tmp(v); while (k) { if (k & 1) res *= tmp; tmp *= tmp; k >>= 1; } return res; } constexpr int getMod() { return Modulus; } constexpr Modint operator - () const noexcept { return v ? Modulus - v : 0; } constexpr Modint operator + (const Modint& m) const noexcept { return Modint(*this) += m; } constexpr Modint operator - (const Modint& m) const noexcept { return Modint(*this) -= m; } constexpr Modint operator * (const Modint& m) const noexcept { return Modint(*this) *= m; } constexpr Modint operator / (const Modint& m) const noexcept { return Modint(*this) /= m; } constexpr Modint& operator += (const Modint& m) noexcept { v += m.v; if (v >= Modulus) v -= Modulus; return *this; } constexpr Modint& operator -= (const Modint& m) noexcept { v -= m.v; if (v < 0) v += Modulus; return *this; } constexpr Modint& operator *= (const Modint& m) noexcept { v = v * m.v % Modulus; return *this; } constexpr Modint& operator /= (const Modint& m) noexcept { long long a = m.v, b = Modulus, t = 1, u = 0; while (b) { long long w = a / b; a -= w * b; swap(a, b); t -= w * u; swap(t, u); } v = v * t % Modulus; if (v < 0) v += Modulus; return *this; } constexpr bool operator == (const Modint& m) const noexcept { return this->v == m.v; } constexpr bool operator != (const Modint& m) const noexcept { return this->v != m.v; } constexpr bool operator < (const Modint& m) const noexcept { return this->v < m.v; } constexpr bool operator > (const Modint& m) const noexcept { return this->v > m.v; } friend constexpr ostream& operator << (ostream &os, const Modint<T, Modulus>& x) noexcept { return os << x.v; } }; #line 8 "test/aoj/DPL_5_B.test.cpp" int main() { int n, k; Modint<> mint = Modint<>(1); cin >> n >> k; if (n > k) { cout << 0 << endl; return 0; } for (int i = k, j = 0; j < n; --i, ++j) mint *= i; cout << mint.v << endl; }