Submission #2670060


Source Code Expand

#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;

const long long MOD = 1e9 + 7;

template <typename T>
T inv(T x) {
    T a(x), b(MOD), u(1), v(0);
    while (b) {
        T t(a / b);
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    if (u < 0) {
        u += MOD;
    }
    return u;
}

template <typename T>
T cbn(T n, T r){
    r = min(r, n - r);
    T a(1);
    for (T i(0); i < r; ++i) {
        a = a * (n - i) % MOD;
        a = a * inv(r - i) % MOD;
    }
    return a;
}

int main(){
    long long N, M;
    scanf("%lld %lld", &N, &M);
    if (N < 0) { N = -N; }
    vector<long long> vp(0);
    long long i(2);
    while(i <= static_cast<long long>(pow(N, 0.5) + 1) && N != 1) {
        long long k(0);
        while (N % i == 0) {
            N /= i;
            ++k;
        }
        if(k){
            vp.emplace_back(k);
        }
        ++i;
    }
    if (N != 1) {
        vp.emplace_back(1);
    }
    long long ans(1);
    for (long long j(0); j != vp.size(); ++j) {
        ans = ans * cbn(vp[j] + M - 1, vp[j]) % MOD;
    }

    long long mul(0);
    for (long long i(0); i < M - 1; ++i) {
        ans = ans * 2 % MOD;
    }
    printf("%lld\n", ans);
}

Submission Info

Submission Time
Task D - 表現の自由 ( Freedom of expression )
User taku0728
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1332 Byte
Status AC
Exec Time 4 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld", &N, &M);
                               ^

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 40
Set Name Test Cases
All 00_max.txt, 00_max2.txt, 00_max3.txt, 00_min.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 01_rnd_20.txt, 01_rnd_21.txt, 01_rnd_22.txt, 01_rnd_23.txt, 01_rnd_24.txt, 01_rnd_25.txt, 01_rnd_26.txt, 01_rnd_27.txt, 01_rnd_28.txt, 01_rnd_29.txt, 04_primes_01.txt, 04_primes_02.txt
Case Name Status Exec Time Memory
00_max.txt AC 4 ms 384 KB
00_max2.txt AC 1 ms 256 KB
00_max3.txt AC 2 ms 256 KB
00_min.txt AC 1 ms 256 KB
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
00_sample_03.txt AC 1 ms 256 KB
00_sample_04.txt AC 1 ms 256 KB
01_rnd_00.txt AC 1 ms 256 KB
01_rnd_01.txt AC 2 ms 256 KB
01_rnd_02.txt AC 1 ms 256 KB
01_rnd_03.txt AC 2 ms 256 KB
01_rnd_04.txt AC 1 ms 256 KB
01_rnd_05.txt AC 1 ms 256 KB
01_rnd_06.txt AC 2 ms 256 KB
01_rnd_07.txt AC 1 ms 256 KB
01_rnd_08.txt AC 2 ms 256 KB
01_rnd_09.txt AC 2 ms 256 KB
01_rnd_10.txt AC 1 ms 256 KB
01_rnd_11.txt AC 1 ms 256 KB
01_rnd_12.txt AC 1 ms 256 KB
01_rnd_13.txt AC 1 ms 256 KB
01_rnd_14.txt AC 1 ms 256 KB
01_rnd_15.txt AC 1 ms 256 KB
01_rnd_16.txt AC 1 ms 256 KB
01_rnd_17.txt AC 2 ms 256 KB
01_rnd_18.txt AC 2 ms 256 KB
01_rnd_19.txt AC 1 ms 256 KB
01_rnd_20.txt AC 3 ms 256 KB
01_rnd_21.txt AC 1 ms 256 KB
01_rnd_22.txt AC 1 ms 256 KB
01_rnd_23.txt AC 2 ms 256 KB
01_rnd_24.txt AC 2 ms 256 KB
01_rnd_25.txt AC 2 ms 256 KB
01_rnd_26.txt AC 1 ms 256 KB
01_rnd_27.txt AC 2 ms 256 KB
01_rnd_28.txt AC 1 ms 256 KB
01_rnd_29.txt AC 2 ms 256 KB
04_primes_01.txt AC 4 ms 256 KB
04_primes_02.txt AC 4 ms 256 KB