import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(); BigInteger a = scanner.nextBigInteger(); BigInteger b = scanner.nextBigInteger(); System.out.println(a.add(b).toString(m)); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long m = scan.nextLong(); if (m == 0) return; long A = scan.nextLong(), B = scan.nextLong(); long C = A + B; if (C == 0) { System.out.print(0); return; } String res = ""; while (C > 0) { res = (C % m) + res; C /= m; } System.out.print(res); } }