Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
【map水之】map只存 正式的解,负数通过正数处理得之#include <iostream> #include <stdio.h> #include <string.h> #include <map> using namespace std; #define ll long long const ll TOP=1ll<<33; const ll N=1<<17; map<ll,int> tr; bool on[N]; void pre() { for(ll i=2;i<N;i++) if(!on[i]) { ll k=i*i; int cnt=2; while(k<TOP&&tr[k]==0) { if(k<N) on[k]=1; tr[k]=cnt++,k*=i; } } } int main() { // freopen("in.txt","r",stdin); pre(); ll n; while(scanf("%lld",&n),n) { bool sp=0; if(n<0) { n=-n; sp=1; } int ans=tr[n]; if(sp) { if(ans==0||(ans&1)) printf("%d\n",ans?ans:1); else { int mark=1; for(int i=2;i<=ans;i++) if(ans%i==0&&((ans/i)&1)) { // printf("%d %d\n",ans,i); mark=ans/i; break; } printf("%d\n",mark); } }else printf("%d\n",ans?ans:1); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator