模拟
代码
#include <cmath> #include <cstdio> #include <iostream> #define N 50 #define M 1000001 #define LL long long int n, m; LL f[N], a[M], p[M]; bool b; inline int read() { int x = 0, f = 1; char ch = getchar(); for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1; for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0'; return x * f; } int main() { int i; n = read(); f[1] = 1; for(i = 2; i <= n; i++) f[i] = (f[i - 1] + f[i - 2]) % (1 << 31); if(f[n] == 1) { printf("%lld=%lld", f[n], f[n]); return 0; } m = sqrt(f[n]); printf("%lld=", f[n]); for(i = 2; i <= m; i++) while(!(f[n] % i)) { if(!b) printf("%d", i), b = 1; else printf("*%d", i); f[n] /= i; } if(b && f[n] > 1) printf("*%lld", f[n]); else if(!b && f[n] > 1) printf("%lld", f[n]); return 0; }