QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#464014#8167. Yet Another Simple Math ProblemLittleXiWA 6ms10648kbPython3926b2024-07-05 17:19:172024-07-05 17:19:17

Judging History

你现在查看的是最新测评结果

  • [2024-07-05 17:19:17]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:10648kb
  • [2024-07-05 17:19:17]
  • 提交

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'