Skip to content

Instantly share code, notes, and snippets.

@TheoKlein
Last active February 27, 2016 03:33
Show Gist options
  • Select an option

  • Save TheoKlein/24e12a348e158cf3627e to your computer and use it in GitHub Desktop.

Select an option

Save TheoKlein/24e12a348e158cf3627e to your computer and use it in GitHub Desktop.
ZeroJudge_a010_C
#include <stdio.h>
int main (){
int in;
while(scanf("%d",&in)!=EOF){
int i;
int count = 0;
for ( i = 2 ; i * i <=in ; i ++){
while(in % i == 0){
count++;
in = in / i;
}
if (count > 1 && in > 1)
printf("%d^%d * ",i,count);
else if (count == 1 && in >1)
printf("%d * ",i);
else if (count > 1 && in == 1)
printf("%d^%d\n",i,count);
else if(count == 1 && in == 1)
printf("%d\n",i);
count = 0;
}
if (in > 1)
printf("%d\n",in);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment