結果

問題 No.2710 How many more?
ユーザー shin3110shin3110
提出日時 2024-03-31 14:42:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,244 bytes
コンパイル時間 4,291 ms
コンパイル使用メモリ 237,176 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:43:01
合計ジャッジ時間 8,286 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*

              ∧∧∩ 
             ( ゚∀゚)/ キタ━━━━━━(゚∀゚)━━━━━━!!!!  
            ⊂   ノ  ゆっくり見てってね!!!!!!!!
             (つ ノ
    o          (ノ
     \      ☆
             |      o
          (⌒ ⌒ヽ   /     ☆
    \  (´⌒  ⌒  ⌒ヾ   /
      ('⌒ ; ⌒   ::⌒  )
     (´     )     ::: ) /
  ☆─ (´⌒;:    ::⌒`) :;  )

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


#define rep(i, s, n) for(int i=s; i<n; i++)
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef long double ld;

ld pi = 3.14159265358979;

// bool型に対して"Yes", "No" を出力する
bool printb(bool f) {if (f) cout << "Yes\n";else cout << "No\n";return f;}

//vectorのcout,cin
template<typename T>
std::istream &operator>>(std::istream&is,std::vector<T>&v){for(T &in:v){is>>in;}return is;}
template<typename T>
std::ostream &operator<<(std::ostream&os,const std::vector<T>&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;}

// 回文かどうかの判定 
bool iskaibun(string s){ll k = s.size();rep(i,0,k/2){if(s[i]!=s[k-1-i]){return false;}}return true;}

template<class T> void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> void chmin(T& a, T b) { if (a > b) a = b; }

// 余りが正になるような割り方
ll floor(ll x, ll m) {
    ll r = (x % m + m) % m;
    return (x - r) / m;
}

#define mod 998244353
using mint = modint998244353;
int op(int a, int b) {return max(a, b);}
int e() {return 0;}
int mapping(int f, int x) {return (f == 1e9 ? x : f);}
int composition(int f, int g) {return (f == 1e9 ? g : f);}
int id() {return 1e9;}


#define int ll
signed main() {
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    int n, p, q; cin >> n >> q >> p;
    vector<int> s(n); cin >> s;
    sort(all(s));
    vector<int> a(n, 1), b(n, 1), c(n, 1), d(n, 1);
    rep(i, 0, n) {
        vector<int> ta(q, -1), tb(q, -1), tc(q, -1), td(q, -1);
        rep(j, 0, s[i]) {
            a[i] *= 10;
            a[i] %= q;
            if(ta[a[i]] == -1) ta[a[i]] = j;
            else {
                rep(k, 0, q) if((s[i]-ta[a[i]])%(j-ta[a[i]]) == ta[k]) {
                    a[i] = k;
                    break;
                }
            }
        }
        rep(j, 0, s[i]) {
            b[i] *= 9;
            b[i] %= q;
            if(tb[b[i]] == -1) tb[b[i]] = j;
            else {
                rep(k, 0, q) if((s[i]-tb[b[i]])%(j-tb[b[i]]) == tb[k]) {
                    b[i] = k;
                    break;
                }
            }
        }
        rep(j, 0, s[i]) {
            c[i] *= 7;
            c[i] %= q;
            if(tc[c[i]] == -1) tc[c[i]] = j;
            else {
                rep(k, 0, q) if((s[i]-tc[c[i]])%(j-tc[c[i]]) == tc[k]) {
                    c[i] = k;
                    break;
                }
            }
        }
        rep(j, 0, s[i]) {
            d[i] *= 5;
            d[i] %= q;
            if(td[d[i]] == -1) ta[d[i]] = j;
            else {
                rep(k, 0, q) if((s[i]-td[d[i]])%(j-td[d[i]]) == td[k]) {
                    d[i] = k;
                    break;
                }
            }
        }
    }
    cout << a << endl << b << endl << c << endl << d << endl;
    vector<vector<int>> l(n, vector<int>(q, 0)), r(n, vector<int>(q, 0));
    rep(i, 0, n) rep(j, i+1, n) {
        l[j][(a[i]+b[j])%q]++;
        //if(j == 2) cout << "a:j" << a[i]+b[j] << endl;
    }
    rep(i, 0, n) rep(j, i+1, n) {
        rep(k, 0, i+1) {
            r[k][(c[i]+d[j])%q]++;
        }
    }
    //cout << a << endl << b << endl << c << endl << d << endl;
    ll ans = 0;
    rep(i, 0, n-1) {
        rep(j, 0, q) ans += r[i+1][(q+p-j)%q] * l[i][j];
    }
    cout << ans << endl;
}
0