Function

TimeLimit:1500MS  MemoryLimit:262144KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Let's define the sum of all digits in $x$ as $g(x)$. For example, $g(123) = 1 + 2 + 3 = 6$. Give you a function:
$$
f(x) = Ax^2g(x) + Bx^2 + Cxg^2(x) + Dxg(x)
$$
Find the minimum value of $f(x)$, where $x$ is an integer and $1 \leq x \leq N$.
Input
This problem contains multiple test cases.

The first line of the input contains an integer $T (1 \leq T \leq 10^4)$, representing the number of test cases.

Each of the next $T$ lines contains five integers $A, B, C, D, N (0 \leq |A| \leq 10^3, 0 \leq |B|, |C|, |D| \leq 10^6, 1 \leq N \leq 10^6)$ indicating a test case.
Output
For each test case output an integer, denoting the answer.
SampleInput
2
1 2 3 4 100
4 3 2 1 100
SampleOutput
10
10
Submit
题目统计信息详细
总AC数3
通过人数3
尝试人数3
总提交量7
AC率42.86%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: