Java|PTA乙级|1010 一元多项式求导 (25分)|解析
设计函数求一元多项式的导数。(注:x**n(n为整数)的一阶导数为nxn−1。)
//测试点2的坑。若是直接输入0,0,则要返回0,0;而其他情况下,number,0的情况则什么也不输出
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int cnt = 0;
while(sc.hasNext()){
int n = sc.nextInt();
int m = sc.nextInt();
if(m != 0){
if(cnt == 0)
System.out.print(n*m+" "+(m-1));
else if(cnt != 0)
System.out.print(" "+n*m+" "+(m-1));
cnt++;
}
}
//测试点2的坑。若是直接输入0,0,则要返回0,0;而其他情况下,number,0的情况则什么也不输出
if(cnt == 0){
System.out.print("0 0");
}
}
}