Div.1太虐心了,也许,这就是我飞跃的开始。
就做了个A题,学会了vector的ans.push_back(i),ans.size(),ans.clear():
View Code
#include <iostream> #include <stdio.h> #include <vector> using namespace std; vector<long long>ans; int main(){ long long q; while(cin >> q){ ans.clear(); for(long long i=2;i*i<=q;i++){ while(q%i==0){ ans.push_back(i); q/=i; } } if(q>1) ans.push_back(q); if(ans.size()<2){ cout << "1" <<endl; cout << "0" <<endl; } else if(ans.size()==2){ cout << "2" <<endl; } else{ cout << "1" <<endl; cout << ans[0]*ans[1] <<endl; } } return 0; }
发现快速求质因子模板一份:
for(long long i=2;i*i<=q;i++){ while(q%i==0){ ans.push_back(i); q/=i; } } if(q>1) ans.push_back(q);