牛客-金币

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.
全部评论

相关推荐

运营3年修炼中接简历辅导:你的科研项目经历里,只写了你的动作,没有写你的思考和成果,不要只写使用什么进行了什么,这等于罗列你的任务,简历是为了突出你的优秀,你在什么样的任务背景下,克服了什么样的困难,针对性地做了哪些事情,最后达成了什么成果(用数据体现你的成果和效率)
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

更多
牛客网
牛客企业服务