【杭电ACM】1.2.6 decimal system
【杭电ACM】1.2.6 decimal system
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=2&problemid=18先前用C++手写麻烦死了。JAVA几个函数20行代码就解决了。
//author:pz import java.util.Scanner; public class Main{ public static void main(String args[]){ Scanner scan = new Scanner(System.in); while(scan.hasNext()){ int n = scan.nextInt(); int sum = 0; for(int i = 0; i < n; i ++){ String s = scan.next(); String[] sArray=s.split("[()]"); int system = Integer.parseInt(sArray[1]); int x = Integer.parseInt(sArray[0], system); sum += x; } System.out.println(sum); } } }