编程介的小学生 2017-09-11 23:31 采纳率: 20.5%
浏览 793
已采纳

Lucky Ticket

A bus ticket is called 'lucky', if in its number, which consists of 2n digits (the number may have leading zeros), the sum of the first n digits equals the sum of the last n digits. A passenger wants to certainly ride with a lucky ticket. He buys a ticket, checks its number, and then, if necessary, buys a few more tickets with successive numbers. How many additional tickets will the passenger have to buy, having spent the minimum sum of money?
1 <= n <= 10

Input

The input file contains a line of 2n digits, which may have several leading zeroes - the number of the first ticket.

Process to the end of file.

Output

The output file must contain a number - the amount of the additionally bought tickets.

Sample Input

025071

Sample Output

35

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-09-12 16:46
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿