結果
問題 | No.1632 Sorting Integers (GCD of M) |
ユーザー | KoD |
提出日時 | 2021-07-30 22:54:47 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 6,074 bytes |
コンパイル時間 | 2,060 ms |
コンパイル使用メモリ | 203,532 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 02:36:50 |
合計ジャッジ時間 | 7,205 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | RE | - |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | RE | - |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | RE | - |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | RE | - |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | RE | - |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | RE | - |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | RE | - |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | RE | - |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | RE | - |
testcase_44 | AC | 1 ms
5,376 KB |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 2 ms
5,376 KB |
testcase_49 | RE | - |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | AC | 1 ms
5,376 KB |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | AC | 2 ms
5,376 KB |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | AC | 2 ms
5,376 KB |
testcase_60 | AC | 1 ms
5,376 KB |
testcase_61 | AC | 2 ms
5,376 KB |
testcase_62 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using i32 = std::int32_t; using u32 = std::uint32_t; using i64 = std::int64_t; using u64 = std::uint64_t; using i128 = __int128_t; using u128 = __uint128_t; using isize = std::ptrdiff_t; using usize = std::size_t; class rep { struct Iter { usize itr; constexpr Iter(const usize pos) noexcept : itr(pos) {} constexpr void operator++() noexcept { ++itr; } constexpr bool operator!=(const Iter& other) const noexcept { return itr != other.itr; } constexpr usize operator*() const noexcept { return itr; } }; const Iter first, last; public: explicit constexpr rep(const usize first, const usize last) noexcept : first(first), last(std::max(first, last)) {} constexpr Iter begin() const noexcept { return first; } constexpr Iter end() const noexcept { return last; } }; template <class T> constexpr T totient(T x) { T ret = x; for (T i = 2; i * i <= x; ++i) { if (x % i == 0) { ret /= i; ret *= i - 1; while (x % i == 0) x /= i; } } if (x > 1) { ret /= x; ret *= x - 1; } return ret; } template <class T> constexpr T rem_euclid(T value, const T& mod) { return (value %= mod) >= 0 ? value : value + mod; } template <u32 MOD, std::enable_if_t<((u32)1 <= MOD and MOD <= ((u32)1 << 31))>* = nullptr> class StaticModint { using Mint = StaticModint; static inline constexpr u32 PHI = totient(MOD); u32 v; public: static constexpr u32 mod() noexcept { return MOD; } template <class T, std::enable_if_t<std::is_signed_v<T> and std::is_integral_v<T>>* = nullptr> static constexpr T normalize(const T x) noexcept { return rem_euclid<std::common_type_t<T, i64>>(x, MOD); } template <class T, std::enable_if_t<std::is_unsigned_v<T> and std::is_integral_v<T>>* = nullptr> static constexpr T normalize(const T x) noexcept { return x % MOD; } constexpr StaticModint() noexcept : v(0) {} template <class T> constexpr StaticModint(const T x) noexcept : v(normalize(x)) {} template <class T> static constexpr Mint raw(const T x) noexcept { Mint ret; ret.v = x; return ret; } constexpr u32 get() const noexcept { return v; } constexpr Mint neg() const noexcept { return raw(v == 0 ? 0 : MOD - v); } constexpr Mint inv() const noexcept { return pow(PHI - 1); } constexpr Mint pow(u64 exp) const noexcept { Mint ret(1), mult(*this); for (; exp > 0; exp >>= 1) { if (exp & 1) ret *= mult; mult *= mult; } return ret; } constexpr Mint operator-() const noexcept { return neg(); } constexpr Mint operator~() const noexcept { return inv(); } constexpr Mint operator+(const Mint& rhs) const noexcept { return Mint(*this) += rhs; } constexpr Mint& operator+=(const Mint& rhs) noexcept { if ((v += rhs.v) >= MOD) v -= MOD; return *this; } constexpr Mint operator-(const Mint& rhs) const noexcept { return Mint(*this) -= rhs; } constexpr Mint& operator-=(const Mint& rhs) noexcept { if (v < rhs.v) v += MOD; v -= rhs.v; return *this; } constexpr Mint operator*(const Mint& rhs) const noexcept { return Mint(*this) *= rhs; } constexpr Mint& operator*=(const Mint& rhs) noexcept { v = (u64)v * rhs.v % MOD; return *this; } constexpr Mint operator/(const Mint& rhs) const noexcept { return Mint(*this) /= rhs; } constexpr Mint& operator/=(const Mint& rhs) noexcept { return *this *= rhs.inv(); } constexpr bool operator==(const Mint& rhs) const noexcept { return v == rhs.v; } constexpr bool operator!=(const Mint& rhs) const noexcept { return v != rhs.v; } friend std::ostream& operator<<(std::ostream& stream, const Mint& rhs) { return stream << rhs.v; } }; using Modint1000000007 = StaticModint<1000000007>; using Modint998244353 = StaticModint<998244353>; template <class T> using Vec = std::vector<T>; using Fp = Modint1000000007; using F27 = StaticModint<27>; void main_() { u32 N; std::cin >> N; std::array<u32, 10> C{}; for (const auto i : rep(1, 10)) { std::cin >> C[i]; } for (const auto i : rep(1, 10)) { if (C[i] == N) { std::cout << Fp(i) * (Fp(10).pow(N) - Fp(1)) / Fp(9) << '\n'; return; } } u32 ans = 1, sum = 0; for (const auto i : rep(1, 10)) { sum += i * (C[i] % 9); } if (sum % 9 == 0) { assert(false); bool only = true; for (const auto i : rep(1, 10)) { for (const auto j : rep(1, i)) { if (C[i] > 0 and C[j] > 0 and (i - j) % 3 != 0) { only = false; } } } if (only) { // 27 の倍数か? std::array<F27, 30> repunit; { repunit[0] = 1; F27 ten = 10; for (const auto i : rep(1, 30)) { repunit[i] = repunit[i - 1] + repunit[i - 1] * ten; ten *= ten; } } F27 rem; F27 ten = 1; for (const auto i : rep(1, 10)) { for (const auto k : rep(0, 30)) { if (C[i] >> k & 1) { rem += repunit[k] * i * ten; ten *= F27(10).pow(1 << k); } } } if (rem == F27(0)) { ans *= 27; } else { ans *= 9; } } else { ans *= 9; } } else if (sum % 3 == 0) { ans *= 3; } if (C[1] + C[3] + C[5] + C[7] + C[9] == 0) { if (C[2] + C[6] == 0) { ans *= 4; } else { ans *= 2; } } std::cout << ans << '\n'; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); main_(); return 0; }