Last active
February 27, 2016 03:33
-
-
Save TheoKlein/24e12a348e158cf3627e to your computer and use it in GitHub Desktop.
ZeroJudge_a010_C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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