java:
又是听懂课不会写
照着大佬代码写一遍的一天
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String a = scan.nextLine();
int b = scan.nextInt();
List<Integer> A = new ArrayList<>();
for(int i = a.length() - 1; i >= 0; i--) A.add(a.charAt(i) - '0');
List<Integer> C = sub(A, b);
for(int i = C.size() - 1; i >= 0; i--) System.out.print(C.get(i));
}
public static List<Integer> sub(List<Integer> A, int b){
int t = 0;
for(int i = 0; i < A.size(); i++){
t += A.get(i) * b;
A.set(i, t % 10);
t = t / 10;
}
if(t != 0) A.add(t);
while(A.size() > 1 && A.get(A.size() - 1) == 0) A.remove(A.size() - 1);
return A;
}
}