Skip to content

Commit b703a84

Browse files
committed
ABC354のDを解説AC
1 parent a4b043b commit b703a84

File tree

7 files changed

+30
-0
lines changed

7 files changed

+30
-0
lines changed

Diff for: AtCoderBeginnerContest354/D/Program.cs

+24
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,32 @@ public static void Main() {
1919
}
2020

2121
public class Solver {
22+
// 左下が[0, 0], 右上が[3, 1]
23+
long[,] _areaRui = new long[,]
24+
{
25+
{0, 0, 0, 0, 0},
26+
{0, 2, 3, 3, 4},
27+
{0, 3, 6, 7, 8},
28+
};
29+
2230
public void Solve()
2331
{
32+
var ABCD = Rla();
33+
var M = 1000000000;
34+
var l = ABCD[0] + M; var b = ABCD[1] + M; var r = ABCD[2] + M; var u = ABCD[3] + M;
35+
var ans = F(u, r) - F(u, l) - F(b, r) + F(b, l);
36+
Console.WriteLine(ans);
37+
}
38+
39+
long F(long y, long x)
40+
{
41+
var yCnt = y / 2; var xCnt = x / 4;
42+
var yRem = y % 2; var xRem = x % 4;
43+
var lb = yCnt * xCnt * _areaRui[2, 4];
44+
var rb = yCnt * _areaRui[2, xRem];
45+
var lu = xCnt * _areaRui[yRem, 4];
46+
var ru = _areaRui[yRem, xRem];
47+
return lb + rb + lu + ru;
2448
}
2549

2650
static string Rs(){return Console.ReadLine();}

Diff for: AtCoderBeginnerContest354/DTest/SampleInOut/1In.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0 0 3 3

Diff for: AtCoderBeginnerContest354/DTest/SampleInOut/1Out.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10

Diff for: AtCoderBeginnerContest354/DTest/SampleInOut/2In.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-1 -2 1 3

Diff for: AtCoderBeginnerContest354/DTest/SampleInOut/2Out.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11

Diff for: AtCoderBeginnerContest354/DTest/SampleInOut/3In.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-1000000000 -1000000000 1000000000 1000000000

Diff for: AtCoderBeginnerContest354/DTest/SampleInOut/3Out.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4000000000000000000

0 commit comments

Comments
 (0)