zoukankan      html  css  js  c++  java
  • 因式分解(数学)(未完成 还需完善)

    因式分解

    # 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
    ", 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
    ", p, p);
            f(2, p);
        }
    }
    
    int main(void)
    {
        run();
    
        return 0;
    }
    所有因式分解的情况
  • 相关阅读:
    loj 6035 「雅礼集训 2017 Day4」洗衣服
    BZOJ 3251 树上三角形
    UwrhrQNgRh
    百度之星2018资格赛1002题解
    [CF-676B]PYRAMID OF GLASSES
    【CF-371C】Hamburgers
    洛谷P1012拼数——字符串排序
    位运算详解及应用
    NOIP 2014 Day2 T1 无线网络发射器
    写代码要注意的几点(2)
  • 原文地址:https://www.cnblogs.com/Silence-AC/p/3383089.html
Copyright © 2011-2022 走看看