結果

問題 No.2709 1975 Powers
ユーザー traindoggotraindoggo
提出日時 2024-03-31 14:12:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,704 bytes
コンパイル時間 2,187 ms
コンパイル使用メモリ 207,164 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:12:13
合計ジャッジ時間 7,977 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG_
#include <compe/debug.hpp>
#else
#define dump(...)
#endif

// clang-format off
struct  Fast{Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

#define rep(i,n) for (int i=0; i<(int)n; ++i)
#define rrep(i,a,n) for (int i=a; i<(int)n; ++i)
#define out(msg) cout << (msg) << '\n'
#define die(msg) do{ cout << (msg) << endl,exit(0); }while(0)
#define el '\n'

#define all(k)  k.begin(),  k.end()
#define rall(k) k.rbegin(), k.rend()

// const
#define INFi  1   << 30
#define INFll 1LL << 60
#define MOD17 10'0000'0007
#define MOD98  9'9824'4353

// alias
using ullint = unsigned long long int;
using llint  = long long int;

template <typename T> inline bool chmax(T& a, const T& b) {
  return ((a < b) ? (a = b, true) : false);
}
template <typename T> inline bool chmin(T& a, const T& b) {
  return ((a > b) ? (a = b, true) : false);
}
// clang-format on

llint modpow(llint x, llint n, llint mod) {
  x = x % mod;

  if (n == 0)
    return 1;

  else if (n % 2 == 1)
    return (x * modpow(x, n - 1, mod)) % mod;

  else
    return modpow((x * x) % mod, n / 2, mod) % mod;
}

int main() {
  llint n, p, q;
  cin >> n >> p >> q;

  vector<llint> ai(n);
  rep(i, n) cin >> ai[i];
  sort(all(ai));
  dump(ai);

  // TLE :smile:
  int cnt{};

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        for (int l = k + 1; l < n; ++l) {
          llint ans = modpow(10, ai[i], p) + modpow(9, ai[j], p) +
                      modpow(7, ai[k], p) + modpow(5, ai[l], p);
          if (ans % p == q) {
            cnt++;
          }
        }
      }
    }
  }
  cout << cnt << el;
}
0