Submission #25280895
Source Code Expand
N,P = gets.to_i,998244353
R = Integer.sqrt N
x = N
p (1.upto(R+1).map{|k|
k2,kk = k+k,k*k
x = (1..x+1).bsearch{|x| N<k2*x-kk }-1
}.each_cons(2).with_index(1).sum{|(k1,k2),i|
(k1-k2)*i%P
}+R*(R+1)/2)%P
Submission Info
| Submission Time | |
|---|---|
| Task | B - Squares |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 500 |
| Code Size | 215 Byte |
| Status | AC |
| Exec Time | 1238 ms |
| Memory | 22228 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
| All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-001.txt | AC | 57 ms | 14180 KiB |
| 00-sample-002.txt | AC | 56 ms | 14200 KiB |
| 00-sample-003.txt | AC | 170 ms | 15260 KiB |
| 01-001.txt | AC | 57 ms | 14272 KiB |
| 01-002.txt | AC | 57 ms | 14180 KiB |
| 01-003.txt | AC | 680 ms | 18644 KiB |
| 01-004.txt | AC | 612 ms | 18356 KiB |
| 01-005.txt | AC | 951 ms | 20152 KiB |
| 01-006.txt | AC | 1126 ms | 21480 KiB |
| 01-007.txt | AC | 503 ms | 17380 KiB |
| 01-008.txt | AC | 1065 ms | 21192 KiB |
| 01-009.txt | AC | 1003 ms | 20740 KiB |
| 01-010.txt | AC | 695 ms | 18632 KiB |
| 01-011.txt | AC | 605 ms | 18096 KiB |
| 01-012.txt | AC | 894 ms | 19932 KiB |
| 01-013.txt | AC | 1238 ms | 22228 KiB |