QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#464014 | #8167. Yet Another Simple Math Problem | LittleXi | WA | 6ms | 10648kb | Python3 | 926b | 2024-07-05 17:19:17 | 2024-07-05 17:19:17 |
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
ymi+=1
if(ymi*ymi+ymi>n):
ymi-=1
ans +=ymi
print(ans)
详细
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 10648kb
input:
3 6 1 101
output:
4 1 83
result:
wrong answer 2nd words differ - expected: '0', found: '1'