- BC20270020 的部落格
分解只因数
- 2024-11-5 16:00:56 @
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,i=1;
cin>>x;
cout<<x<<"=";
while(i++<=x){
while(x%i==0){
x/=i;
cout<<i;
if(x!=1)
cout<<"*";
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,i=1;
cin>>x;
cout<<x<<"=";
while(i++<=x){
while(x%i==0){
x/=i;
cout<<i;
if(x!=1)
cout<<"*";
}
}
return 0;
}
註冊一個 HFOJ 通用賬戶,您就可以在我們提供的所有線上評測服務上提交程式碼、參與討論。