⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ac1119.pas

📁 同济大学 Online在线题库 AC源代码合集 程序设计竞赛必看资料
💻 PAS
字号:
program tju1119;
var
  n,i:word;
begin
  repeat
    read(n);
    if (n=2) or (n=3) or (n=5) then
      writeln('Yes')
    else begin
      writeln('No');
      if odd(n) then write('2 1 1 1') else write('2 3 3 3');
      for i:=5 to n do
        write(' 3');
      writeln;
    end;
  until seekeof;
end.
{
The hard thing of this prob is to prove Fan(5)>=0 always holds.
Proof:
  Denote the five numbers by a,b,c,d,e, sorted by increasing order.
  Let A=(a-b)(a-c)(a-d)(a-e), and the similar for B,C,D,E.
  Obviously A,C,E>=0, B,D<=0.
  Compare |A| and |B|:
    Because |a-b|=|b-a|,|a-c|>=|b-c|,|a-d|>=|b-d|,|a-e|>=|b-e|
    Therefore |A|>=|B|.
    So A+B>=0.
  Similarly we can obtain that D+E>=0.
  Also because C>=0, therefore A+B+C+D+E>=0, i.e. Fan(5)>=0 always holds.
}

⌨️ 快捷键说明

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