HDOJ 2100 Lovekey
来源:互联网 发布:太平洋战争知乎 编辑:程序博客网 时间:2024/06/15 12:12
HDACM2100
此题别被题目忽悠去把输入的二十六进制数转换成十进制然后去计算,然后把十进制转换成二十六进制。如果非要转换那就得调用大数的方法去做。
import java.util.Scanner;public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { String a = sc.next(); String b = sc.next(); char[] A = a.toCharArray(); char[] B = b.toCharArray(); char[] C = twentySixAdd(A, B); boolean boo = true; for (char d : C) { if (boo&&d=='A'||d=='\0') { continue; } System.out.print(d); boo = false; } System.out.println(); } } public static char[] twentySixAdd(char[] a,char[] b){ char[] c = new char[(a.length>b.length?a.length:b.length)+1]; char m = 0; for (int i = c.length-1; i>0; i--) { if (c[i]=='\0') { c[i] = 'A'; } if (i>c.length-(a.length<b.length?a.length:b.length)-1) { char s = (char)(c[i]+a[i-(c.length-a.length)]+b[i-(c.length-b.length)]-'A'-'A'); if (s>'Z') { c[i] = (char) (s-'Z'-1+'A'); c[i-1] = 'B'; }else{ c[i] = s; } }else { if (a.length>b.length) { char s = (char) (c[i]+a[i-(c.length-a.length)]-'A'); if (s>'Z') { c[i] = (char) (s-'Z'-1+'A'); c[i-1] = 'B'; }else{ c[i] = s; } }else { char s = (char) (c[i]+b[i-(c.length-b.length)]-'A'); if (s>'Z') { c[i] = (char) (s-'Z'-1+'A'); c[i-1] = 'B'; }else{ c[i] = s; } } } } return c; }}
阅读全文
0 0
- HDOJ 2100 Lovekey
- HDOJ 2100 Lovekey
- 【大数问题】 HDOJ 2100 Lovekey
- 大数问题之 Lovekey hdoj 2100
- hdoj 2100 Lovekey 【另类A+B】
- ACM--26进制加法--HDOJ 2100--Lovekey--大数--字符串处理
- HDU 2100 Lovekey
- HDU 2100 Lovekey
- hdu acm 2100 Lovekey
- HDU 2100 LoveKey
- HDU 2100 Lovekey
- hdu 2100 Lovekey
- HDU--2100 -- Lovekey
- Hdu---Lovekey---2100
- hdu-2100-Lovekey
- hdu 2100 Lovekey
- HDU 2100 Lovekey
- hdu-2100-Lovekey
- 微信企业号开发:企业支付openid的获取 appid and openid not match
- 第三方类库-Core核心库-Google Guava-1
- 白话解析:一致性hash算法 consistent hashing
- 浅谈 Mybatis中的 ${ } 和 #{ }的区别
- 编译mt6735 Android modem 模块
- HDOJ 2100 Lovekey
- 性能测试指标的理解--cpu和load
- DataGridView动态添加新行的两种方法
- php7游戏端以post发送json数据给php
- 杂志征稿 教育杂志征稿
- 字符流
- Activity的显示过程
- PREPARE STATEMENT
- 线程同步