1 条题解

  • 0
    @ 2024-12-24 9:49:41

    Java :

    import java.util.*;
    
    public class Main{
        public static void main(String args[]){
            Scanner cin=new Scanner(System.in);
            int T=cin.nextInt();
            int a,b,r;
            while(T-->0){
                a=cin.nextInt();
                b=cin.nextInt();
                r=cin.nextInt();
                a+=b;
                if(a==0){
                    System.out.println(0);
                }
                else{
                    Stack<Integer>stack=new Stack<Integer>();
                    while(a!=0){
                        stack.push(a%r);
                        a/=r;
                    }
                    while(!stack.empty()){
                        System.out.print(stack.peek());
                        stack.pop();
                    }
                    System.out.println();
                }
           }
        }
    }
    
    • 1

    信息

    ID
    1000
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者