結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N, P, Q;
    cin >> N >> P >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    int ans = 0;
    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) {
                    int tmp = pow(10, A[i]) + pow(9, A[j]) + pow(7, A[k]) + pow(5, A[l]);
                    if (tmp % P == Q) {
                        ans++;
                    }
                }
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}
0