답안 #19895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19895 2016-02-25T06:48:49 Z isac322 창문 (kriii4_C) C++
3 / 100
1000 ms 1720 KB
#include <iostream>
using namespace std;

unsigned long long GetGCM(unsigned long long m, unsigned long long n)
{
    unsigned long long q;
    if(m==0 || n==0) return 0;
    do{
        q = m%n;
        if(q){
            m = n;
            n = q;
        }
    }while(q);
    return n;
}

const long long MOD = 1000000007;
unsigned long long aNum;

unsigned long long solve1(unsigned long long n) {
    if (n == 1) return aNum;
    unsigned long long ret = solve1(n >> 1);
    return (((ret*ret) % MOD) * (n & 1LL ? aNum : 1LL)) % MOD;
}

unsigned long long solve(unsigned long long a, unsigned long long x) {
    aNum = a % MOD;
    return solve1(x);
}

int main()
{
    unsigned long long H=0,W=0;
    unsigned long long answer=0,gcm=0;
    cin>>H>>W;
    for(unsigned long long i=0; i<H; i++){
        for(unsigned long long j=0; j<W; j++){
            answer+=(i+1)*(j+1)*(W-j)*(H-i);
        }
    }
    unsigned long long temp=H*(H+1)/2*W*(W+1)/2;
    answer=answer*9;
    gcm = GetGCM(answer,temp);

    if(gcm!=0){
        answer/=gcm;
        temp/=gcm;
    }

    
    cout<<(answer*solve(temp,1000000005))%1000000007<<endl;


    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1720 KB Output is correct
2 Correct 0 ms 1720 KB Output is correct
3 Correct 0 ms 1720 KB Output is correct
4 Correct 0 ms 1720 KB Output is correct
5 Correct 0 ms 1720 KB Output is correct
6 Correct 0 ms 1720 KB Output is correct
7 Correct 0 ms 1720 KB Output is correct
8 Correct 0 ms 1720 KB Output is correct
9 Correct 0 ms 1720 KB Output is correct
10 Correct 0 ms 1720 KB Output is correct
11 Correct 0 ms 1720 KB Output is correct
12 Correct 0 ms 1720 KB Output is correct
13 Correct 0 ms 1720 KB Output is correct
14 Correct 0 ms 1720 KB Output is correct
15 Correct 0 ms 1720 KB Output is correct
16 Correct 0 ms 1720 KB Output is correct
17 Correct 0 ms 1720 KB Output is correct
18 Correct 0 ms 1720 KB Output is correct
19 Correct 0 ms 1720 KB Output is correct
20 Correct 0 ms 1720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 1716 KB Program timed out
2 Halted 0 ms 0 KB -