1 条题解

  • 0
    @ 2026-10-25 14:59:51

    思路

    按质因子递增输出,指数一与更高指数格式分开。

    参考程序(C++11)

    #include <bits/stdc++.h>
    using namespace std;
    int main(){int n;cin>>n;bool first=true;for(int d=2;d<=n;d++)if(n%d==0){int c=0;while(n%d==0){n/=d;c++;}if(!first)cout<<'*';first=false;cout<<d;if(c>1)cout<<'^'<<c;}cout<<'\n';}
    
    • 1

    信息

    ID
    1080
    时间
    1000ms
    内存
    64MiB
    难度
    进阶
    标签
    递交数
    1
    已通过
    1
    上传者