题目解析
每个位置输出乘法口诀上的一个数字的一位 从 开始的 n 位
解题思路
暴力枚举
代码
import java.io.*;
import java.math.*;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
int a[] = new int[100000 + 10];
a[1] = sc.nextInt();
a[2] = sc.nextInt();
int n = sc.nextInt();
int pos = 3;
for (int i = 3; i <= n; i++)
{
int shu = a[i - 1] * a[i - 2];
if (shu < 10)
a[pos++] = shu;
else
// 因为两个个位数相乘最大也就是 两位数 即 : 9 * 9 = 81
{
a[pos++] = shu / 10;
a[pos++] = shu % 10;
}
}
for (int i = 1; i <= n; i++)
{
if (i != 1)
out.print(" ");
out.print(a[i]);
}
out.println();
out.flush();
out.close();
}
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
}