版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiang_6/article/details/89683174
题意:
给定多项式系数次数,求导数
解:
读入数组,注意格式,零多项式就是0,最后判断一下
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] a = new int[1007];
int id = 1;
while(in.hasNext()) {
a[id++] = in.nextInt();
}
int n = id-1;
//System.out.println(n + "---");
boolean f = false;
for(int i = 2; i <= n; i += 2) {
int t1 = a[i-1]*a[i];
int t2 = a[i]-1;
if(t1 == 0) {
continue;
}
else {
if(f) {
System.out.print(" " + t1 + " " + t2);
}
else {
f = true;
System.out.print(t1 + " " + t2);
}
}
}
if(!f) System.out.println("0 0");
}
}