🏡 index : github.com/captn3m0/codechef.git

---
{"category_name":"easy","problem_code":"DIVEO","problem_name":"Division ","problemComponents":{"constraints":"- $1 \\leq T \\leq 2\\cdot10^3$\n- $2 \\leq N \\leq 10^9$\n- $-10^3\\leq A, B \\leq 10^3$\n","constraintsState":true,"subtasks":"","subtasksState":false,"inputFormat":"- First line will contain $T$, number of testcases. Then the testcases follow.\n- Each testcase contains of a single line of input containing three integers $N, A, B$.\n","inputFormatState":true,"outputFormat":"For each testcase, output in a single line the maximum points Chef can get.\n","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"4\n10 2 3\n15 5 -2\n12 2 3\n8 -1 0\n\n","output":"5\n-2\n7\n-1\n","explanation":"**Test case $1$**: First Chef divides $N = 10$ by $2$ and gets $2$ points and then divides by $5$ and thus gets $3$ points. Hence Chef gets a total of $2 + 3 = 5$ points.\n\n**Test case $2$**: Chef divides $N$ by $15$. Hence he gets $-2$ points.\n\n","isDeleted":false}}},"video_editorial_url":"https://youtu.be/2m6PHHda7S4","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":0.5,"source_sizelimit":50000,"problem_author":"soumyadeep_21","problem_tester":"","date_added":"5-10-2021","tags":{"0":"simple","1":"soumyadeep_21","2":"start15"},"problem_difficulty_level":"Unavailable","best_tag":"","editorial_url":"https://discuss.codechef.com/problems/DIVEO","time":{"view_start_date":1634060704,"submit_start_date":1634060704,"visible_start_date":1634060704,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=DIVEO","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
Chef has an integer $N$. He repeats the following operation until $N$ becomes $1$.

 - Chef chooses an integer $X$ such that $X \gt 1$ and $X$ is a divisor of $N$ and then divides $N$ by $X$ (the new value of $N$ becomes $N/X$). If $X$ is even, Chef gets $A$ points otherwise he gets $B$ points

Can you find the maximum points Chef can get if he performs the operations optimally?

<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>