[蓝桥杯 2016 省 AB] 四平方和

Luogu
IDLGP8635
Time3000ms
Memory256MB
DifficultyP2
2016枚举蓝桥杯省赛
四平方和定理,又称为拉格朗日定理: 每个正整数都可以表示为至多 $4$ 个正整数的平方和。 如果把 $0$ 包括进去,就正好可以表示为 $4$ 个数的平方和。 比如: $5=0^2+0^2+1^2+2^2$。 $7=1^2+1^2+1^2+2^2$。 对于一个给定的正整数,可能存在多种平方和的表示法。 要求你对 $4$ 个数排序使得 $0 \le a \le b \le c \le d$。 并对所有的可能表示法按 $a,b,c,d$ 为联合主键升序排列,最后输出第一个表示法。 ## Input 程序输入为一个正整数 $N(N<5\times10^6)$。 ## Output 要求输出 $4$ 个非负整数,按从小到大排序,中间用空格分开。 [samples] ## Note 时限 3 秒, 256M。蓝桥杯 2016 年第七届省赛 蓝桥杯 2016 年省赛 A 组 H 题(B 组 H 题)。
Samples
Input #1
5
Output #1
0 0 1 2
Input #2
12
Output #2
0 2 2 2
Input #3
773535
Output #3
1 1 267 838
API Response (JSON)
{
  "problem": {
    "name": "[蓝桥杯 2016 省 AB] 四平方和",
    "description": {
      "content": "四平方和定理,又称为拉格朗日定理: 每个正整数都可以表示为至多 $4$ 个正整数的平方和。 如果把 $0$ 包括进去,就正好可以表示为 $4$ 个数的平方和。 比如: $5=0^2+0^2+1^2+2^2$。 $7=1^2+1^2+1^2+2^2$。 对于一个给定的正整数,可能存在多种平方和的表示法。 要求你对 $4$ 个数排序使得 $0 \\le a \\le b \\le c \\le ",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": {
      "LuoguStyle": "P2"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP8635"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "四平方和定理,又称为拉格朗日定理:\n\n每个正整数都可以表示为至多 $4$ 个正整数的平方和。\n\n如果把 $0$ 包括进去,就正好可以表示为 $4$ 个数的平方和。\n\n比如:\n\n$5=0^2+0^2+1^2+2^2$。\n\n$7=1^2+1^2+1^2+2^2$。\n\n对于一个给定的正整数,可能存在多种平方和的表示法。\n\n要求你对 $4$ 个数排序使得 $0 \\le a \\le b \\le c \\le ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments