2017 where to go to the exam (i)

Source: Internet
Author: User
Topic Description:
Use the English letter A-Z to represent the value 0-25, forming a numerical representation of the 26 binary. You need to write a method that converts the string of the 26 binary value, in A-Z, to the corresponding 10 binary value.
Input
There are multiple sets of input data, one row for each group, and multiple characters between A-Z.


Output
The number of 10 in the corresponding representation.




Sample input
Ba
Bcd
Gibbon
Goodboy


Sample output
26
731
74962693

2026285376


Package test;
Import Java.util.Scanner;
Class trans{

String target = null;
Long result = 0;

public static long Chengfang (int i) {
Long result = 1;
if (i = = 0)
return result;
result = 1;
for (int j = 0; J < i; J + +) {
Result *= 26;
}
return result;
}


Public trans (String target) {
This.target = target;
}

public void Cal () {
Char c[] = Target.tochararray ();
int j = 0;
for (int i = c.length-1 i >= 0; i--) {
int curr = c[i]-' a ';
result = Curr * Chengfang (j);
j + +;
}
SYSTEM.OUT.PRINTLN (result);
}
}
public class Qunawang {
public static void Main (string[] args) {
TODO auto-generated method stubs
Scanner sin = new Scanner (system.in);
String s = null;
while (Sin.hasnext ()) {
s = Sin.next ();
if (s!= null)
New trans (s). Cal ();
}
}
}


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.