{"problem":{"name":"[ICPC 2020 Nanjing R] Fireworks","description":{"content":"Kotori is practicing making fireworks for the upcoming hanabi taikai$^1$. It takes her $n$ minutes to make a single firework, and as she is not really proficient in making fireworks, each firework onl","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":{"LuoguStyle":"P4"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP9627"},"statements":[{"statement_type":"Markdown","content":"Kotori is practicing making fireworks for the upcoming hanabi taikai$^1$. It takes her $n$ minutes to make a single firework, and as she is not really proficient in making fireworks, each firework only has a probability of $p \\times 10^{-4}$ to be perfect.\n\nAfter she finishes making a firework, she can just start making the next firework, or take $m$ minutes to light all the remaining fireworks finished before. If there is at least one perfect firework among the lit ones, she will be happy and go to rest. Otherwise, she will continue practicing. Can you tell her the minimum expected practicing time before she goes to rest if she takes the optimal strategy?\n\nNotice that no matter how many fireworks remain, it always takes $m$ minutes to light them all.\n\n$^1$ Hanabi taikai: Romaji of the Japanese word ``花火大會``, which means the firework... err... party?\n\n## Input\n\nThere are multiple test cases. The first line of the input contains an integer $T$ ($1 \\le T \\le 10^4$) indicating the number of test cases. For each test case:\n\nThe first and only line contains three integers $n$, $m$ and $p$ ($1 \\le n, m \\le 10^9$, $1 \\le p \\le 10^4$).\n\n## Output\n\nFor each test case, output one line containing one number indicating the minimum expected practicing time.\n\nYour answer will be considered correct if and only if the absolute or relative error does not exceed $10^{-4}$.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"LGP9627","tags":["2020","Special Judge","O2优化","ICPC","南京"],"sample_group":[["3\n1 1 5000\n1 1 1\n1 2 10000","4.0000000000\n10141.5852891136\n3.0000000000"]],"created_at":"2026-03-03 11:09:25"}}