package com.code; import java.util.Arrays; public class Test04_1 { public static int solution(int[] A) { int size = A.length; if(size==1){ // handle one element array if(A[0]==1){ return 2; }else{ return 1; } } Arrays.sort(A); // sort by JDK if(A[0]>…
最小新整数 Descriptions: 给定一个十进制正整数n(0 < n < 1000000000),每个数位上数字均不为0.n的位数为m.现在从m位中删除k位(0<k < m),求生成的新整数最小为多少?例如: n = 9128456, k = 2, 则生成的新整数最小为12456 Input 第一行t, 表示有t组数据: 接下来t行,每一行表示一组测试数据,每组测试数据包含两个数字n, k. Output t行,每行一个数字,表示从n中删除k位后得到的最小整数. Sample…
Java中最小的整数为什么是-2147483648 假如只有两位来表示数字,第一位是符号位: 00:0 01:1 11:-1,这个是负数,而且是补码,取反为00,加1成为01,就是-1 10:-2,这个是负数,而且是补码,取反为01,加1成为10,就是-2: 所以,两位的数字范围是:-2^1 到 2^1-1 学习了:http://bbs.csdn.net/topics/390259086…
描述 给定一个十进制正整数n(0 < n < 1000000000),每个数位上数字均不为0.n的位数为m. 现在从m位中删除k位(0<k < m),求生成的新整数最小为多少? 例如: n = 9128456, k = 2, 则生成的新整数最小为12456 输入 第一行t, 表示有t组数据: 接下来t行,每一行表示一组测试数据,每组测试数据包含两个数字n, k. 输出 t行,每行一个数字,表示从n中删除k位后得到的最小整数. 样例输入 2 9128456 2 1444 3 样例输出…
排列a包含N分子,其元素属于[0,N]之间,且不存在反复的元素.请你找出数组中缺失的元素(由于[0,N]之间有N+1个元素.而数组仅仅能存储N个元素.所以必定缺少一个元素).当中对数组的操作满足下列的条件:不能在常数时间内读取数组中的元素,可是可以读取数组中元素的某一个bit值.可以在常数时间内交换数组的两个元素的位置.请设计一种算法使其可以在线性时间内找出数组中缺失的元素. (N=2^k) An array a[] contains all of the integers from 0 to…
We define the smallest positive real number as the number which is explicitly greater than zero and yet less than all other positive real numbers except itself. The smallest positive real number, if exists, implies the existence of the second greater…
lesson 4: counting elements 1. FrogRiverOne 2. PermCheck 3. MissingInteger 4. MaxCounters lesson 4: counting elements exercise Problem: You are given an integer m (1 <= m <= 1,000,000) and two non-empty, zero-indexed arrays A and B of n integers, a0…
Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1847    Accepted Submission(s): 629 Problem Description Alexandra has a little brother. He is new to programming. One…
Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1658    Accepted Submission(s): 565 Problem Description Alexandra has a little brother. He is new to programming. One…
题目:传送门 题目描述 Your task is to find the minimal positive integer number Q so that the product of digits of Q is exactly equal to N. 输入 The first line of input contains T, number of test cases. The following T lines each contain a single integer number N…