题解 | #序列和#
序列和
http://www.nowcoder.com/practice/46eb436eb6564a62b9f972160e1699c9
public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int N=scanner.nextInt(); int L=scanner.nextInt(); for(;L<=100;L++){ double a1=(2*N+L-L*L)/(2.0*L); int a11= (int) a1; if(a1>=0 && Math.abs(a1-a11)<0.0001){ for(int i=0;i<L;i++) { int res=a11+i; System.out.print(res+" "); } return; } } System.out.print("No"); } }