当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
Any integer number can be written as a sequence of digits in a specific system of base. For example, 5 in decimal based system can be written as 101 in binary based system. By writting down every number from 1 to N in system of base K one by one, we obtain a long sequence of digits. Your task is to calculate the alternating sum of digits, i.e. the difference between the sum of digits with odd index in the sequence and the sum of ones with even index.
For example, the sequence is 11011100101 and the alternating sum is 1 (the result of +1-1+0-1+1-1+0-0+1-0+1) given K = 2 and N = 101.
2 101
1
时间上限 | 内存上限 |
1000 | 131072 |