ACM一道题目 一直WA已崩溃大神求教
GivenanintegerY,youneedtofindtheminimalintegerKsothatthereexistsaXsatisfyingX−Y...
Given an integer Y, you need to find the minimal integer K so that there exists a X satisfying X−Y=Z(Z≥0) and the number of different digit between X and Z is K under decimal system.
For example: Y=1, you can find a X=100 so that Z=99 and K is 3 due to 1≠0 and 0≠9. But for minimization, we should let X=1 so that Z=0 and K can just be 1.
Input
Only one integer Y(0≤Y≤10^18).
Output
The minimal K.
Sample input and output
Sample Input Sample Output
1 1
191 2 展开
For example: Y=1, you can find a X=100 so that Z=99 and K is 3 due to 1≠0 and 0≠9. But for minimization, we should let X=1 so that Z=0 and K can just be 1.
Input
Only one integer Y(0≤Y≤10^18).
Output
The minimal K.
Sample input and output
Sample Input Sample Output
1 1
191 2 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询