Submission #19804

# Submission time Handle Problem Language Result Execution time Memory
19804 2016-02-25T05:46:14 Z exqt 창문 (kriii4_C) C++
3 / 100
0 ms 1720 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>

#include <iterator>
using namespace std;

#define in cin
#define out cout

#define ll unsigned long long

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

    return res%DV;
}

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)
{
    a += 10LL*DV;
    b += 10LL*DV;
    return ((a%DV)-(b%DV)+10LL*DV)%DV;
}

ll add(ll a, ll b)
{
      a += 10LL*DV;
    b += 10LL*DV;
    return ((a%DV)+(b%DV)+10LL*DV)%DV;
}


int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

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

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

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

    out << res;

    return 0;
}
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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 -