???

ljy2022 2022-09-15 22:39:08 15

不是把第n个斐波那契数列的数分解质因数吗?为什么样例2输入8分解质因数还是8???

{{ vote && vote.total.up }}

共 3 条回复

yehongchen

#include using namespace std; long int f[51], mod = 2147483648, m; int n, i, flag = 0; int main() { f[1] = 1; f[2] = 1; cin >> n; for (i = 3; i <= n; i++) f[i] = f[i - 1] + f[i - 2]; m = f[n] % mod; cout << m << "="; i = 2; while (m > 1) { if (m % i == 0) { if (flag == 0) { flag = 1; cout << i; m = m / i; } else cout << "*" << i, m = m / i; } else i++; } return 0; } 那有错啊!!!

jianyuechen

我也

jianyuechen