結果

問題 No.2709 1975 Powers
ユーザー ococonomy1ococonomy1
提出日時 2024-03-31 13:40:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,364 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 114,456 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 13:40:33
合計ジャッジ時間 8,924 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'

ll bekizyou(ll a,ll b,int mod){
    ll ans = 1,temp = a % mod;
    while(b){
        if(b % 2){
            ans *= temp; ans %= mod;
        }
        temp *= temp;
        temp %= mod;
        b /= 2;
    }return ans;
}

#define MULTI_TEST_CASE false
void solve(void){
    //問題を見たらまず「この問題設定から言えること」をいっぱい言う
    //一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
    //添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える
    //ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
    //よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
    int n,p,q;
    cin >> n >> p >> q;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    //10,9,7,5
    vector<ll> b(n),c(n),d(n),e(n);
    for(int i = 0; i < n; i++){
        b[i] = bekizyou(10,a[i],p);
        c[i] = bekizyou(9,a[i],p);
        d[i] = bekizyou(7,a[i],p);
        e[i] = bekizyou(5,a[i],p);
    }
    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++){
                    if((b[i] + c[j] + d[k] + e[l]) % p == q)ans++;
                }
            }
        }
    }
    cout << ans << El;
    return;
}

void calc(void){
    return;
}

signed main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE)cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
0