Submission #6841598


Source Code Expand

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

ll gcd(ll x, ll y){
  return y ? gcd(y, x%y) : x;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin>>N>>K;
    map<ll,ll> mp;
    ll ans = 0;
    REP(i,N){
        int x;
        cin>>x;
        mp[x%K]++;
    }

    for(auto r:mp){
        for(auto r2:mp){
            if(r.first*r2.first % K == 0){
                if(r.first == r2.first) ans += r.second*(r2.second-1) / 2;
                if(r.first < r2.first) ans += r.second*r2.second;
            }
        }
    }
    cout<<ans<<endl;
}

Submission Info

Submission Time
Task C - ロト2
User Bondo416
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1498 Byte
Status TLE
Exec Time 2104 ms
Memory 6400 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 16
TLE × 9
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_random_01.txt, 10_random_02.txt, 10_random_03.txt, 10_random_04.txt, 10_random_05.txt, 20_max_01.txt, 20_max_02.txt, 20_max_03.txt, 20_max_04.txt, 20_max_05.txt, 30_overflow_01.txt, 30_overflow_02.txt, 40_dmax_01.txt, 40_dmax_02.txt, 40_dmax_03.txt, 50_prime_01.txt, 50_prime_02.txt, 50_prime_03.txt, 60_prime_pow_01.txt, 60_prime_pow_02.txt, 60_prime_pow_03.txt, 70_one_01.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt AC 1 ms 256 KB
00_example_03.txt AC 1 ms 256 KB
10_random_01.txt AC 1 ms 256 KB
10_random_02.txt AC 4 ms 256 KB
10_random_03.txt AC 1 ms 256 KB
10_random_04.txt AC 2 ms 256 KB
10_random_05.txt AC 1 ms 256 KB
20_max_01.txt AC 29 ms 256 KB
20_max_02.txt AC 25 ms 256 KB
20_max_03.txt TLE 2103 ms 3840 KB
20_max_04.txt AC 24 ms 256 KB
20_max_05.txt AC 21 ms 256 KB
30_overflow_01.txt AC 23 ms 256 KB
30_overflow_02.txt AC 23 ms 256 KB
40_dmax_01.txt TLE 2104 ms 6400 KB
40_dmax_02.txt TLE 2104 ms 6400 KB
40_dmax_03.txt TLE 2104 ms 6400 KB
50_prime_01.txt AC 42 ms 384 KB
50_prime_02.txt TLE 2103 ms 4096 KB
50_prime_03.txt TLE 2103 ms 3840 KB
60_prime_pow_01.txt TLE 2103 ms 3968 KB
60_prime_pow_02.txt TLE 2103 ms 3712 KB
60_prime_pow_03.txt TLE 2103 ms 3712 KB
70_one_01.txt AC 19 ms 256 KB