| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | adamant | 153 |
| 3 | Um_nik | 146 |
| 3 | Proof_by_QED | 146 |
| 5 | Dominater069 | 145 |
| 6 | errorgorn | 141 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | TheScrasse | 134 |
| 10 | chromate00 | 133 |
|
+13
WLOG we can just consider x, y > 0. A coordinate (x, y) is visible if and only x and y are relatively prime. So for each x coordinate, we want to compute the number of y s that are relatively prime to x in the range We can use inclusion-exclusion to count everything that shares at least one factor with x and subtract these from the range. First we count all multiples of p where p is some prime factor of x. But this double-counts multiples of pq, so we subtract all multiples of pq. And then we add back multiples of pqs, and subtract multiples of pqst, and so on. So the total runtime is around ![]() Where ω(x) is the number of distinct prime factors of x. One piece of number-theoretic intuition is that ω(x) grows extremely slowly (maxx ≤ 1000000{ω(x)} = 7), and most elements in the range only have ≤ 3 distinct prime factors. So this is fast enough in practice. (You can just run the maximal case to make sure.) |
|
0
Auto comment: topic has been updated by choice (previous revision, new revision, compare). |
|
+3
I used to write binary search like this: |
|
+8
One cute way of solving C without using the "shape" array is to define a spiral of size 1 as simply a single square. The recurrence then follows quite naturally for larger spirals. |
| Name |
|---|


