Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Alternating Sum of Digits
Description 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 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 Input K (1 < K ≤ 10) and N ( ≤ 10^{20}, in the system of base K)Output The alternating sum. You should print it in decimal based system. Sample Input 2 101 Sample Output 1 Hint It is safe to use 64-bit signed integral arithmetic. Source POJ Founder Monthly Contest – 2008.03.16, ShiningMoon |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator