How can I use 10 lab rats to find out which toxic medicine is in 1000 medicine bottles?

Source: Internet
Author: User

 

00 0th bottles

1 1

0 2

1 3

0 4

1 5

0 6

1 7

Public class Base {/*** convert the number to any base * @ param num * @ param base * @ return */public String baseString (int num, int Base) {if (base> 16) {throw new RuntimeException ("the number of hexadecimal bytes exceeds the range, base <= 16");} StringBuffer str = new StringBuffer (""); string digths = "0123456789 ABCDEF"; Stack <Character> s = new Stack <Character> (); while (num! = 0) {s. push (digths. charAt (num % base); num/= base;} while (! S. isEmpty () {str. append (s. pop ();} return str. toString ();} /*** any hexadecimal conversion in hexadecimal format * @ param num * @ param srcBase * @ param destBase * @ return */public String baseNum (String num, int srcBase, int destBase) {if (srcBase = destBase) {return num;} String digths = "0123456789 ABCDEF"; char [] chars = num. toCharArray (); int len = chars. length; if (destBase! = 10) {// The destination system is not converted to the decimal num = baseNum (num, srcBase, 10);} else {int n = 0; for (int I = len-1; I> = 0; I --) {n + = digths. indexOf (chars [I]) * Math. pow (srcBase, len-I-1);} return n + "";} return baseString (Integer. valueOf (num), destBase );}}

Reprinted please indicate the source: http://blog.csdn.net/u012027907
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.