CSES - Putka Open 2015 – 2/6 - Results
Submission details
Task:Kertotaulu
Sender:
Submission time:2015-08-16 17:19:26 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED26
#2ACCEPTED23
#3ACCEPTED51
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.05 s1details
#3ACCEPTED0.05 s1details
#4ACCEPTED0.04 s1details
#5ACCEPTED0.05 s1details
#6ACCEPTED0.05 s2details
#7ACCEPTED0.07 s2details
#8ACCEPTED0.05 s2details
#9ACCEPTED0.06 s2details
#10ACCEPTED0.05 s2details
#11ACCEPTED0.05 s3details
#12ACCEPTED0.05 s3details
#13ACCEPTED0.05 s3details
#14ACCEPTED0.06 s3details
#15ACCEPTED0.06 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:36:5: warning: unused variable 'ed' [-Wunused-variable]
  ll ed = (y2*x2)-(y1*x1);
     ^

Code

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

#define pii pair<int, int>
#define pll pair<long long, long long>

#define defmod 1000000007
using namespace std;

ll pot(ll x, int n) {
	if (n == 0) return 1;
	if (n%2 == 1) return (pot(x,n-1)*x)%defmod;
	ll t = pot(x,n/2);
	return (t*t)%defmod;
}

ll inv(ll x) {
	return pot(x, defmod-2);
}

ll asum(ll n, ll a1, ll d){
	return ((n*((a1%defmod+((n-1)*d)%defmod+a1)%defmod))%defmod*inv(2LL))%defmod;
}
ll asumnomod(ll n, ll a1, ll d){
	return (n*(a1+(n-1)*d+a1))/2;
}
int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	ll y1, x1, y2, x2;
	cin >> y1 >> x1 >> y2 >> x2;
	
	ll ed = (y2*x2)-(y1*x1);
	ll n = (x2-x1)+1;
	ll m = (y2-y1)+1;
	
	if(n == 1){
		cout << asum(m, y1*x1, x1) << endl;
		return 0;
	}
	if(m == 1){
		cout << asum(n, y1*x1, y1) << endl;
		return 0;
	}
	ll eka = asum(n, y1*x1, y1);
	ll toka = asum(n, (y1+1)*x1, y1+1);
	ll d = toka-eka;
	d = ((d%defmod)+defmod)%defmod;
	//cout << eka << " " << toka << endl;
	cout << (((asum(m, eka, d)%defmod)+defmod)%defmod) << endl;

	return 0;
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
242 232 976 976

correct output
417796293

user output
417796293

Test 2

Group: 1

Verdict: ACCEPTED

input
12 645 476 899

correct output
335735446

user output
335735446

Test 3

Group: 1

Verdict: ACCEPTED

input
435 460 792 681

correct output
816738894

user output
816738894

Test 4

Group: 1

Verdict: ACCEPTED

input
318 389 441 799

correct output
488457695

user output
488457695

Test 5

Group: 1

Verdict: ACCEPTED

input
211 640 623 951

correct output
744563022

user output
744563022

Test 6

Group: 2

Verdict: ACCEPTED

input
201976 387454 920309 673120

correct output
946933548

user output
946933548

Test 7

Group: 2

Verdict: ACCEPTED

input
779381 684472 984138 828099

correct output
121907300

user output
121907300

Test 8

Group: 2

Verdict: ACCEPTED

input
284954 437564 777701 638386

correct output
321734745

user output
321734745

Test 9

Group: 2

Verdict: ACCEPTED

input
296035 308490 853604 668978

correct output
802693678

user output
802693678

Test 10

Group: 2

Verdict: ACCEPTED

input
460731 148462 619190 626173

correct output
264761756

user output
264761756

Test 11

Group: 3

Verdict: ACCEPTED

input
381626897 590403175 501559980 ...

correct output
258247883

user output
258247883

Test 12

Group: 3

Verdict: ACCEPTED

input
597399975 685346584 618318138 ...

correct output
390332938

user output
390332938

Test 13

Group: 3

Verdict: ACCEPTED

input
247307039 323856912 812562646 ...

correct output
89821592

user output
89821592

Test 14

Group: 3

Verdict: ACCEPTED

input
900181910 768404361 943052600 ...

correct output
242545884

user output
242545884

Test 15

Group: 3

Verdict: ACCEPTED

input
815 528 999999994 999999992

correct output
103780099

user output
103780099