Have Fun with Numbers Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers…
The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the pr…
这一段时间一直都在刷OJ,这里建一个博客合集,用以记录和分享算法学习的进程. github传送门:https://github.com/haoyuanliu/Online_Judge/tree/master/HangDianOJ Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Inpu…
The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11978 Accepted: 3194 Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of…
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. string multiply(string& num, char ch){ '; string s; ; int x; ; i>=; i--){ x = (num[i]-') *…
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 79180 Accepted Submission(s): 24760 Problem Description The digital root of a positive integer is found by summing the digits of…
题目连接:http://www.ifrog.cc/acm/problem/1056 DESCRIPTION Two octal number integers a, b are given, and you need calculate the result a - b in octal notation.If the result is negative, you should use the negative sign instead of complement notation. INPU…
要求:输入一个数字n,按照顺序打印出从1到最大的n为十进制.比如输入3,则打印出1.2.3……一直到最大的3位数999 这个看起来好像很简单啊.巴拉巴拉,已经得出了下面的代码 /** * 注意: 错误的示范,当n的值很大的时候,将会溢出 * @param n 最大的位数 */ public static void Print1ToMaxOfNDigits_1(int n) { int number = 1; int i = 0; while(i++ < n) { number *= 10; }…
我们可以把一个很大很长的数分成多个短小的数,然后保存在一个数组中,大数之间的四则运算及其它运算都是通过数组完成.JDK就是这么实现的.JDK的BigInteger类里用一个int数组来保存数据: /** * The magnitude of this BigInteger, in <i>big-endian</i> order: the * zeroth element of this array is the most-significant int of the * magni…