結果

問題 No.2709 1975 Powers
ユーザー elphe
提出日時 2024-07-03 18:57:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 833 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 73,432 KB
最終ジャッジ日時 2025-02-22 01:54:23
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

constexpr unsigned int pow_mod(const unsigned long long a, const unsigned long long b, const unsigned int mod)
{
    return (b == 0 ? (mod == 1 ? 0 : 1) : (b & 1 ? a % mod : 1) * pow_mod((a % mod) * (a % mod) % mod, b >> 1, mod) % mod);
}

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, P, Q, A[200], i, a, b, c, d, ans = 0;
    cin >> N >> P >> Q;
    for (i = 0; i != N; ++i) cin >> A[i];

    for (a = 0; a != N; ++a)
        for (b = a + 1; b != N; ++b)
            for (c = b + 1; c != N; ++c)
                for (d = c + 1; d != N; ++d)
                    if ((pow_mod(10, A[a], P) + pow_mod(9, A[b], P) + pow_mod(7, A[c], P) + pow_mod(5, A[d], P)) % P == Q)
                        ++ans;

    cout << ans << '\n';
    return 0;
}
0