当前位置: 代码迷 >> 综合 >> HDOJ 1877 又一版 A+B
  详细解决方案

HDOJ 1877 又一版 A+B

热度:81   发布时间:2023-10-21 19:02:24.0

HDACM 1877

直接暴力解,同时需注意0+0这个特例

import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);while(sc.hasNext()){int m = sc.nextInt();if (m==0) {break;}long a = sc.nextLong();long b = sc.nextLong();a += b;String num = "";while(a>0){num = a%m+num;a /= m;}if ("".equals(num)) {System.out.println(0);continue;}System.out.println(num);}sc.close();}
}