QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#464008 | #8167. Yet Another Simple Math Problem | LittleXi | TL | 1451ms | 10712kb | Python3 | 878b | 2024-07-05 17:16:34 | 2024-07-05 17:16:34 |
Judging History
answer
import math
def sqrt(x):
l,r = 1,x
ans = 0
while r>=l:
m = (l+r)//2
if(m*m>x):
r= m-1
else:
l = m+1
ans = m
return ans
def find(n):
l,r = 0,10**18
while l+1!=r:
m = (l+r)//2
if m+m*m<=n:
l = m
else:
r = m
return l
def find0(n):
l,r = 0,10000000000
while l+1!=r:
m = (l+r)//2
if m+m*m-1<=n:
l = m
else:
r = m
return l
def cau(x):
return x*(x+1)*(2*x+1)//6
t = int(input())
while t:
t-=1
n = int(input())
ans = 0
ymi = find0(n)
ymx = int(sqrt(n))
ans += (ymi-1)*ymi//2
ans += n*ymx -cau(ymx)
ans -= n*ymi - cau(ymi)
# print(ans,ymi,ymx)
ans *=2
ans +=find(n)
print(ans)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 10644kb
input:
3 6 1 101
output:
4 0 83
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 1405ms
memory: 10712kb
input:
100000 73697 33010 17110 47753 12905 6499 31281 81851 77880 81156 73047 17517 37475 77689 74726 65569 63357 6041 61519 88597 1857 65620 55973 56676 28171 88517 65432 20685 41538 92074 39812 86863 83657 14646 76700 47385 10860 39669 52855 22282 53629 751 99085 6000 22003 31593 99242 61157 17982 91695...
output:
73412 32761 16900 47524 12769 6400 30976 81335 77362 80656 72655 17347 37249 77284 74378 65091 63001 5929 61039 88209 1780 65193 55696 56233 27889 88209 65025 20449 41209 91734 39601 86436 83216 14410 76176 47089 10697 39340 52441 22066 53361 720 98596 5918 21807 31329 98630 60812 17741 91204 6889 4...
result:
ok 100000 tokens
Test #3:
score: 0
Accepted
time: 1410ms
memory: 10712kb
input:
100000 160180 187088 148262 131783 150002 191047 129104 182104 184772 178235 186435 138698 127656 123653 177758 100482 125119 167843 124055 103132 152479 104642 194899 132355 123847 193194 194873 178916 175841 117262 129672 150143 127638 194555 138335 172329 140523 110097 162171 109223 181161 175245...
output:
159561 186624 147530 131072 149462 190252 128610 181476 184041 177543 185761 138269 127150 123201 177241 99856 124609 167281 123503 102582 152079 104310 194436 131769 123201 192721 194384 178084 175284 116877 129025 149744 127114 193748 137641 171604 139876 109561 161604 108887 180625 174724 174724 ...
result:
ok 100000 tokens
Test #4:
score: 0
Accepted
time: 1451ms
memory: 10640kb
input:
100000 238477 256863 242340 219760 228952 207769 262740 218587 206771 293488 260702 275398 285009 280986 276277 288379 206627 233898 269368 289359 297756 296868 207800 228187 234948 285577 283037 262580 249030 256755 293865 276867 208279 275761 239079 268814 257050 254116 230023 222294 232350 268703...
output:
237835 256036 241633 219024 228465 207025 262144 218089 206116 292681 260100 274576 284089 280013 275625 287316 206116 233289 268338 288369 297025 295936 207025 227529 234256 284931 281987 261993 248062 256036 292883 276007 207711 274848 238144 268269 256038 253209 229441 221806 231413 268047 210681...
result:
ok 100000 tokens
Test #5:
score: -100
Time Limit Exceeded
input:
100000 999999997999951124 999999998000044057 999999997999964982 999999997999968201 999999997999963700 999999997999996275 999999997999971870 999999997999963885 999999997999977051 999999997999952461 999999997999994767 999999998000039863 999999998000026619 999999997999958630 999999997999950140 99999999...
output:
999999996000000004 999999996000088116 999999996000000004 999999996000000004 999999996000000004 999999996000000004 999999996000000004 999999996000000004 999999996000000004 999999996000000004 999999996000000004 999999996000079728 999999996000053240 999999996000000004 999999996000000004 999999996000028...