{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003eYour company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.\u003c/p\u003e\n\u003cp\u003eSkipping the repair is necessary because of the climate. The climate in your region is periodical: there are $$$g$$$ days when the weather is good and if you lay new asphalt these days it becomes high-quality pavement; after that, the weather during the next $$$b$$$ days is bad, and if you lay new asphalt these days it becomes low-quality pavement; again $$$g$$$ good days, $$$b$$$ bad days and so on.\u003c/p\u003e\n\u003cp\u003eYou can be sure that you start repairing at the start of a good season, in other words, days $$$1, 2, \\dots, g$$$ are good.\u003c/p\u003e\n\u003cp\u003eYou don\u0027t really care about the quality of the highway, you just want to make sure that \u003cspan class\u003d\"tex-font-style-bf\"\u003eat least half of the highway\u003c/span\u003e will have high-quality pavement. For example, if the $$$n \u003d 5$$$ then at least $$$3$$$ units of the highway should have high quality; if $$$n \u003d 4$$$ then at least $$$2$$$ units should have high quality.\u003c/p\u003e\n\u003cp\u003eWhat is the minimum number of days is needed to finish the repair of \u003cspan class\u003d\"tex-font-style-bf\"\u003ethe whole highway\u003c/span\u003e?\u003c/p\u003e\n\n\n给你 t 组样例,每组给你一个要修的路的路段个数n、好天数g天、坏天数b天(一开始从g天好天开始,然后b天坏天,gbgb… …)。\n\n注意:当天你可以选择修(一天只能修一个路段)与不修,而好天修路得到高质量路段,相反坏天修路得到列质量路段。\n而你的任务就是计算要确保修完整条路后至少有一半路段h是高质量的(如果n\u003d7,则一半为4)所需要的天数为多少。"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single integer T (1≤T≤10^4) — the number of test cases.\n\nNext T lines contain test cases — one per line. Each line contains three integers n, g and b (1≤n,g,b≤10^9) — the length of the highway and the number of good and bad days respectively."}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint T integers — one per test case. For each test case, print the minimum number of days required to repair \u003cspan class\u003d\"tex-font-style-bf\"\u003ethe whole highway if at least half of it should have high quality\u003c/span\u003e.\u003c/p\u003e"}},{"title":"Example","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3\n5 1 1\n8 10 10\n1000000 1 1000000\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e5\n8\n499999500000\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, you can just lay new asphalt each day, since days 1, 3, 5 are good.\u003c/p\u003e\n\u003cp\u003eIn the second test case, you can also lay new asphalt each day, since days 1-8 are good.\u003c/p\u003e"}}]}