4 条题解

  • 2
    @ 2018-12-28 17:26:34

    打表出奇迹

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cctype>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<vector>
    #include<map>
    #define INF 1<<30
    #define LL long long
    #define ULL unsigned long long
    using namespace std;
    
    int p[]={0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,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0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0};
    int n;
    void f(int x)
    {
        for(int i=2;i<=x;i++)
        {
            if(p[i]==1&&x%i==0)
            {
                cout<<i;
                if(x/i!=1)
                {
                    cout<<"*";
                    f(x/i);
                }
                return;
            }
        }
    }
    int main()
    {
        cin>>n;
        cout<<n<<"=";
        f(n);
        return 0;
    }
    
    
  • 0
    @ 2024-08-15 20:38:57
    #include <iostream>
    using namespace std;
    
    // 递归函数:分解质因数并打印
    void factorize(int n, int divisor) {
        // 如果 n 已经变成1,说明分解完成
        if (n == 1) {
            return;
        }
    
        // 如果 n 能被当前的 divisor 整除
        if (n % divisor == 0) {
            // 打印这个质因数
            cout << divisor;
            // 继续分解剩下的部分
            if (n / divisor != 1) {
                cout << "*";
            }
            factorize(n / divisor, divisor);
        } else {
            // 如果不能被当前的 divisor 整除,检查下一个数
            factorize(n, divisor + 1);
        }
    }
    
    int main() {
        int number;
        cout << "请输入一个合数: ";
        cin >> number;
    
        cout << number << "=";
        factorize(number, 2); // 从2开始分解
        cout << endl;
    
        return 0;
    }
    
    
    
  • 0
    @ 2020-12-02 21:51:11
    def dg(t,n,k):
        if t == True:
            if n % k == 0 and n / k != 1:
                print (k,end="*")
                n = n / k
                dg(t,n,k)
            elif n % k != 0 :
                k += 1
                dg(t,n,k)
            else:
                print(k,end="")
                t = False
    
    n = int(input())
    t = True
    print(n,end="=")
    dg(t,n,2)
    
  • 0
    @ 2020-08-18 13:54:26

    感觉好像有点问题,不过判出来是对的
    import math
    def fj(x):
    f=False
    for i in range(2,int(math.sqrt(x)//1)+1):
    if x%i==0:
    f=True
    break
    if f==False:

    print(int(x),end='')

    else:
    print(i,end='*')
    fj(x/i)

    x=int(input())
    print(str(x)+'=',end='')
    fj(x)

  • 1

信息

难度
6
分类
(无)
标签
(无)
递交数
218
已通过
58
通过率
27%
被复制
1
上传者