因式分解(数学)(未完成 还需完善)
# include <map> # include <stack> # include <queue> # include <math.h> # include <stdio.h> # include <string.h> # include <iostream> # include <algorithm> using namespace std; int a[100000010]; int b[100000010]; void run() { int t, num, q, n; scanf("%d", &n); t = sqrt(n); num = 0; for(int i = 2; i <= t; i++) { if(n % i == 0) { num++; a[num] = i; } } q = num; if(t*t == n) num--; for(int i = q; i >= 1; i--) { num++; a[num] = n/a[i]; } num++; a[num] = n; b[1] = 1; for(int i = 2; i <= num; i++) { b[i] = 1; for(int j = i-1; j >= 1; j--) { if(a[i]%a[j] == 0) b[i] += b[j]; } } printf("%d", b[num]); } int main(void) { run(); return 0; }
# include <map> # include <stack> # include <queue> # include <math.h> # include <stdio.h> # include <string.h> # include <iostream> # include <algorithm> using namespace std; int t = 0; int p; int s[100000010]; void f(int m, int n) { int i,j; i = m; j = n; if(i < j) { if(j % i == 0) { t = t+1; s[t] = i; for(int k = 1; k <= t; k++) { printf("%d*", s[k]); } printf("%d=%d\n", j/i, p); f(2, n/i); t = t-1; f(i+1, j); } else { f(i+1, j); } } } void run() { while(~scanf("%d", &p)) { printf("%d=%d\n", p, p); f(2, p); } } int main(void) { run(); return 0; }