分段函数

Luogu
IDLGB2047
Time1000ms
Memory128MB
DifficultyP1
分支结构
编写程序,计算下列分段函数 $y=f(x)$ 的值。 当 $0 \le x<5$ 时,$y=-x+2.5$。 当 $5 \le x<10$ 时,$y=2-1.5(x-3)(x-3)$。 当 $10 \le x<20$ 时,$y=x/2-1.5$。 ## Input 一个浮点数 $x$。 ## Output 输出 $x$ 对应的分段函数值:$f(x)$。结果保留到小数点后三位。 [samples] ## Note 对于 100% 的数据 $0 \le x<20$
Samples
Input #1
1.0
Output #1
1.500
API Response (JSON)
{
  "problem": {
    "name": "分段函数",
    "description": {
      "content": "编写程序,计算下列分段函数 $y=f(x)$ 的值。 当 $0 \\le x<5$ 时,$y=-x+2.5$。 当 $5 \\le x<10$ 时,$y=2-1.5(x-3)(x-3)$。 当 $10 \\le x<20$ 时,$y=x/2-1.5$。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 131072
    },
    "difficulty": {
      "LuoguStyle": "P1"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGB2047"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "编写程序,计算下列分段函数 $y=f(x)$ 的值。\n\n当 $0 \\le x<5$ 时,$y=-x+2.5$。\n\n当 $5 \\le x<10$ 时,$y=2-1.5(x-3)(x-3)$。\n\n当 $10 \\le x<20$ 时,$y=x/2-1.5$。\n\n## Input\n\n一个浮点数 $x$。\n\n## Output\n\n输出 $x$ 对应的分段函数值:$f(x)$。结果保留到小数点后三位。\n\n[s...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments