{"problem":{"name":"A. Pizza, Pizza, Pizza!!!","description":{"content":"Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems. Today is Sh","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":131072},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF979A"},"statements":[{"statement_type":"Markdown","content":"Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.\n\nToday is Shiro's birthday. She really loves pizza so she wants to invite her friends to the pizza restaurant near her house to celebrate her birthday, including her best friends Katie and Kuro.\n\nShe has ordered a very big round pizza, in order to serve her many friends. Exactly $n$ of Shiro's friends are here. That's why she has to divide the pizza into $n + 1$ slices (Shiro also needs to eat). She wants the slices to be exactly the same size and shape. If not, some of her friends will get mad and go home early, and the party will be over.\n\nShiro is now hungry. She wants to cut the pizza with _minimum_ of straight cuts. A cut is a straight segment, it might have ends inside or outside the pizza. But she is too lazy to pick up the calculator.\n\nAs usual, she will ask Katie and Kuro for help. But they haven't come yet. Could you help Shiro with this problem?\n\n## Input\n\nA single line contains one non-negative integer $n$ ($0 \\le n \\leq 10^{18}$) — the number of Shiro's friends. The circular pizza has to be sliced into $n + 1$ pieces.\n\n## Output\n\nA single integer — the number of straight cuts Shiro needs.\n\n[samples]\n\n## Note\n\nTo cut the round pizza into quarters one has to make two cuts through the center with angle $90^{\\circ}$ between them.\n\nTo cut the round pizza into five equal parts one has to make five cuts.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Katie、Kuro 和 Shiro 是最好的朋友。她们从幼儿园起就认识了。因此她们经常彼此分享一切，并一起解决一些非常困难的问题。\n\n今天是 Shiro 的生日。她非常爱吃披萨，所以她想邀请她的朋友们去她家附近的披萨店庆祝生日，包括她最好的朋友 Katie 和 Kuro。\n\n她点了一个非常大的圆形披萨，以便招待众多朋友。恰好有 $n$ 位 Shiro 的朋友到场。因此她必须将披萨切成 $n + 1$ 片（Shiro 也需要吃）。她希望这些片的大小和形状完全相同。否则，一些朋友会生气并提前回家，派对就结束了。\n\nShiro 现在饿了。她希望用最少的直线切割来切披萨。一条切割是一条直线段，其端点可以在披萨内部或外部。但她太懒了，不想拿计算器。\n\n和往常一样，她会向 Katie 和 Kuro 寻求帮助。但她们还没来。你能帮 Shiro 解决这个问题吗？\n\n输入一行包含一个非负整数 $n$（$0 lt.eq n lt.eq 10^(18)$）——Shiro 的朋友数量。圆形披萨需要被切成 $n + 1$ 片。\n\n输出一个整数——Shiro 需要的直线切割次数。\n\n要将圆形披萨切成四等份，需要两条穿过中心的切割线，且它们之间的夹角为 $90^compose$。\n\n要将圆形披萨切成五个相等的部分，需要五条切割线。\n\n## Input\n\n输入一行包含一个非负整数 $n$（$0 lt.eq n lt.eq 10^(18)$）——Shiro 的朋友数量。圆形披萨需要被切成 $n + 1$ 片。\n\n## Output\n\n输出一个整数——Shiro 需要的直线切割次数。\n\n[samples]\n\n## Note\n\n要将圆形披萨切成四等份，需要两条穿过中心的切割线，且它们之间的夹角为 $90^compose$。要将圆形披萨切成五个相等的部分，需要五条切割线。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z}_{\\geq 0} $ be the number of Shiro’s friends.  \nLet $ p = n + 1 $ be the number of equal-sized circular slices required.\n\n**Constraints**  \n$ 0 \\leq n \\leq 10^{18} $, so $ 1 \\leq p \\leq 10^{18} + 1 $.\n\n**Objective**  \nFind the minimum number of straight cuts required to divide a circular pizza into $ p $ equal-area sectors.\n\n- If $ p = 1 $, then 0 cuts are needed.  \n- If $ p \\geq 2 $:  \n  - If $ p $ is even, each cut can produce two opposite slices, so $ \\frac{p}{2} $ cuts suffice (all passing through the center).  \n  - If $ p $ is odd, each cut produces only one new slice, so $ p $ cuts are required (each at angle $ \\frac{2\\pi}{p} $ apart, through the center).\n\nThus, the minimum number of cuts is:  \n$$\n\\begin{cases}\n0 & \\text{if } p = 1, \\\\\n\\frac{p}{2} & \\text{if } p \\text{ is even and } p \\geq 2, \\\\\np & \\text{if } p \\text{ is odd and } p \\geq 3.\n\\end{cases}\n$$\n\nEquivalently, since $ p = n + 1 $:  \n$$\n\\text{Answer} =\n\\begin{cases}\n0 & \\text{if } n = 0, \\\\\n\\frac{n+1}{2} & \\text{if } n+1 \\text{ is even}, \\\\\nn+1 & \\text{if } n+1 \\text{ is odd}.\n\\end{cases}\n$$\n\nOr more compactly:  \n$$\n\\boxed{\n\\begin{cases}\n0 & \\text{if } n = 0, \\\\\n\\left\\lceil \\frac{n+1}{2} \\right\\rceil & \\text{if } n+1 \\text{ is even}, \\\\\nn+1 & \\text{if } n+1 \\text{ is odd}.\n\\end{cases}\n}\n$$\n\nBut since $ \\left\\lceil \\frac{p}{2} \\right\\rceil = \\frac{p}{2} $ if $ p $ even, and $ p $ if $ p $ odd, we can write:\n\n$$\n\\boxed{\n\\begin{cases}\n0 & \\text{if } n = 0, \\\\\n\\frac{n+1}{2} & \\text{if } n \\text{ is odd}, \\\\\nn+1 & \\text{if } n \\text{ is even and } n > 0.\n\\end{cases}\n}\n$$\n\nWait — correction:  \nIf $ p = n+1 $ is even → $ n $ is odd → cuts = $ p/2 = (n+1)/2 $  \nIf $ p = n+1 $ is odd → $ n $ is even → cuts = $ p = n+1 $\n\nSo final answer:\n\n$$\n\\boxed{\n\\begin{cases}\n0 & \\text{if } n = 0, \\\\\n\\frac{n+1}{2} & \\text{if } n \\text{ is odd}, \\\\\nn+1 & \\text{if } n \\text{ is even and } n > 0.\n\\end{cases}\n}\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF979A","tags":["math"],"sample_group":[["3","2"],["4","5"]],"created_at":"2026-03-03 11:00:39"}}