From 7c9dae7c36ba0f515e0398b324341e496b9442f9 Mon Sep 17 00:00:00 2001 From: KiritoTRw <3021577574@qq.com> Date: Sun, 1 May 2016 14:30:47 +0800 Subject: [PATCH] Create 1639.cpp --- QUSTOJ/1639.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 QUSTOJ/1639.cpp diff --git a/QUSTOJ/1639.cpp b/QUSTOJ/1639.cpp new file mode 100644 index 0000000..4265270 --- /dev/null +++ b/QUSTOJ/1639.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +using namespace std; +int is_prime[10005]; + +int answer[10005]; + +char cmdline[10240]; +char buff[16]; + +int strlenx(const char* inc) +{ + int i=0; + while(inc[i]!='\0') + i++; + return i; +} +int main() +{ + //Form a list + int i,j,k; + is_prime[2]=1; + for(i=3; i<10000; i++) + { + for(j=2; j0; times--) + { + scanf("%d",&inc); + memset(answer,0,sizeof(int)*10005); + //Now we still have to deal it... + int k_copy; + for(k=2; k<=inc; k++) + { + k_copy=k; + int current_prime=2; + while(k_copy>1) + { + if(k_copy%current_prime==0) + { + answer[current_prime]++; + k_copy=k_copy/current_prime; + continue; + } + //Find next prime + for(current_prime=current_prime+1; current_prime<10000; current_prime++) + { + if(is_prime[current_prime]) break; + } + } + } + memset(cmdline,0,10240); + for(i=1; i<10000; i++) + { + if(answer[i]) + { + sprintf(buff,"%d ",answer[i]); + strcat(cmdline,buff); + } + } + cmdline[strlenx(cmdline)-1]='\0'; + printf("%s\n",cmdline); + } + return 0; +} +