답안 #19722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19722 2016-02-25T04:57:54 Z exqt 창문 (kriii4_C) C++
3 / 100
0 ms 1720 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <cstdio>
#include <cmath>
#include <iterator>
using namespace std;

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPV(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back
#define isin(a,b,c) ((a)<=(c)&&(c)<=(b))
#define maxn(a,b) ((a)>(b)?(a):(b))
#define minn(a,b) ((a)<(b)?(a):(b))

#define ll long long
#define pii pair<ll, ll>
#define pdd pair<double, double>

#define X first
#define Y second

ll DV = 1000000007;
ll pow(ll a, ll b)
{
    ll t = a;
    ll res = 1;
    while(b)
    {
        if(b%2) res = (res * t) % DV;
        t = t % DV;
        t = (t*t) % DV;
        b = b >> 1;
    }

    return res;
}

ll inv(ll a)
{
    return pow(a, DV-2)%DV;
}

ll mul(ll a, ll b)
{
    return ((a%DV)*(b%DV))%DV;
}

ll sub(ll a, ll b)
{
    return ((a%DV)-(b%DV)+2*DV)%DV;
}

ll add(ll a, ll b)
{
    return ((a%DV)+(b%DV))%DV;
}


int main()
{
    ll w, h; in >> w >> h;
    w %= DV; h %= DV;
    ll wS = mul( mul(w, w+1), inv(2) );
    ll hS = mul( mul(h, h+1), inv(2) );
    ll wS2 = mul( mul(w, w+1), mul(2*w+1, inv(6)) );
    ll hS2 = mul( mul(h, h+1), mul(2*h+1, inv(6)) );

    ll res = 0;
    res = add(res, mul( mul(wS, hS),  mul(w,h) ));
    res = sub(res, mul( mul(wS, hS2),  mul(w,1) ));
    res = add(res, mul( mul(wS, hS),  mul(w,1) ));
    res = sub(res, mul( mul(wS2, hS),  mul(1,h) ));
    res = add(res, mul( mul(wS2, hS2),  mul(1,1) ));
    res = sub(res, mul( mul(wS2, hS),  mul(1,1) ));
    res = add(res, mul( mul(wS, hS),  mul(1,h) ));
    res = sub(res, mul( mul(wS, hS2),  mul(1,1) ));
    res = add(res, mul( mul(wS, hS),  mul(1,1) ));

    res = mul(res, mul(inv(hS), inv(wS)));
    res = (res*9)%DV;

    out << res;

    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 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
21 Incorrect 0 ms 1720 KB Output isn't correct
22 Halted 0 ms 0 KB -