scanf中%d后面不要\n,否则需要按下2次回车。如果要考虑效率(毕竟要10的6次方),应该用动态规划
https://blog.csdn.net/AndyZZhang/article/details/88082012