File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 438
438
* [x] D - Hachi
439
439
* [ ] E - Transformable Teacher
440
440
* [ ] F - Silver Woods
441
+
442
+ ## AtCoder Beginner Contest 191
443
+
444
+ < https://atcoder.jp/contests/abc191 >
445
+
446
+ * [ ] A - Vanishing Pitch
447
+ * [ ] B - Remove It
448
+ * [ ] C - Digital Graffiti
449
+ * [x] D - Circle Lattice Points
450
+ * [ ] E - Come Back Quickly
451
+ * [ ] F - GCD or MIN
Original file line number Diff line number Diff line change
1
+ -- https://github.com/minoki/my-atcoder-solutions
2
+ {-# LANGUAGE TypeApplications #-}
3
+ {-# LANGUAGE BangPatterns #-}
4
+ import Data.Int (Int64 )
5
+ import qualified Data.ByteString.Char8 as BS
6
+ import Data.Ratio
7
+
8
+ main = do
9
+ [cx,cy,r] <- map (read @ Double . BS. unpack) . BS. words <$> BS. getLine
10
+ let cx4, cy4, r4 :: Int64
11
+ cx4 = round (cx * 10 ^ 4 )
12
+ cy4 = round (cy * 10 ^ 4 )
13
+ r4 = round (r * 10 ^ 4 )
14
+ isInside x y = (10 ^ 4 * x - cx4)^ 2 + (10 ^ 4 * y - cy4)^ 2 <= r4^ 2
15
+ minX = ceiling $ (cx4 - r4) % (10 ^ 4 )
16
+ maxX = floor $ (cx4 + r4) % (10 ^ 4 )
17
+ go1 ! acc ! x ! yB ! yT | x > maxX = acc
18
+ | otherwise = let yB' = if isInside x yB then
19
+ let go ! y | isInside x (y - 1 ) = go (y - 1 )
20
+ | otherwise = y
21
+ in go yB
22
+ else
23
+ let go ! y | isInside x (y + 1 ) = y + 1
24
+ | y > yT = y
25
+ | otherwise = go (y + 1 )
26
+ in go yB
27
+ yT' = if isInside x yT then
28
+ let go ! y | isInside x (y + 1 ) = go (y + 1 )
29
+ | otherwise = y
30
+ in go yT
31
+ else
32
+ let go ! y | isInside x (y - 1 ) = y - 1
33
+ | y < yB = y
34
+ | otherwise = go (y - 1 )
35
+ in go yT
36
+ in if yT' < yB' then
37
+ acc
38
+ else
39
+ go1 (acc + yT' - yB' + 1 ) (x + 1 ) yB' yT'
40
+ y0 = round cy
41
+ go0 ! x | x > maxX = 0
42
+ | otherwise = if isInside x y0 then
43
+ go1 0 x y0 y0
44
+ else
45
+ go0 (x + 1 )
46
+ print $ go0 minX
You can’t perform that action at this time.
0 commit comments