牛客-金币

https://www.nowcoder.com/acm/contest/170/A

var
    l,r,tot,pre,i:qword;
function max(a,b:int64):int64;
begin
    if a>b then exit(a) else exit(b);
end;
function o(a:int64):int64;
begin
    if a<0 then exit(0) else exit(a);
end;
begin
    readln(l,r);
    tot:=0;i:=1;pre:=0;
    while i*i+pre<=r do
    begin
      tot:=tot+o(pre+i*i-max(l-1,pre))*i;
      pre:=pre+i*i;
      inc(i);
    end;
    tot:=tot+(r-pre)*i;
    writeln(tot);
end.
全部评论

相关推荐

有担当的灰太狼又在摸鱼:零帧起手查看图片
点赞 评论 收藏
分享
05-12 22:16
已编辑
北京邮电大学 研发工程师
牛客302360988号:0offer+1 滴滴都不给我面 佬没投鹅吗,鹅应该很喜欢北邮吧
投递美团等公司10个岗位
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务