ac1157.pas

来自「某牛人写的acm.tongji.edu.cn上大部分ac的代码,仅供学习研究,请」· PAS 代码 · 共 23 行

PAS
23
字号
program tju1157;
var
  t,u,n,l:longint;
  s:int64;
function last(n:longint):longint;
  begin
    if odd(n) then
      last:=(n+1) shr 1
    else
      last:=n shr 1+last(n shr 1);
  end;
begin
  read(t);
  for u:=1 to t do begin
    read(n);
    if odd(n) then
      s:=int64(n)*(n-1) shr 1
    else
      s:=int64(n)*(n+1)-int64(n shr 1)*(n shr 1+1)*2+1-last(n);
    writeln(s);
  end;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?