P.S. 我沒用到質數XD"" 我直接除到根號這樣XDDDDDDD
[C](0.012)
This file contains 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> | |
#include<math.h> | |
#define ERROR 0.000000001 | |
int main() | |
{ | |
int N; | |
while( scanf( "%d", &N ) != EOF && N != 0 ) | |
{ | |
int i; | |
int prime_count[105] = {0}; | |
for( i = N ; i >= 2 ; i-- ) | |
{ | |
int temp = i; | |
int j; | |
int sqrt_i = (int)( sqrt( (double)temp ) + ERROR ); | |
for( j = 2 ; j <= sqrt_i ; j++ ) | |
while( !(temp % j) ) | |
{ | |
prime_count[j]++; | |
temp /= j; | |
} | |
if( temp > 1 ) | |
prime_count[temp]++; | |
} | |
printf( "%3d! =", N ); | |
int count = 0; | |
for( i = 2 ; i <= N ; i++ ) | |
{ | |
if( prime_count[i] ) | |
{ | |
if( !(count % 15) && count != 0 ) | |
printf( "\n " ); | |
count++; | |
printf( "%3d", prime_count[i] ); | |
} | |
} | |
printf( "\n" ); | |
} | |
return 0; | |
} |
2 意見:
站長您好,想請問一下,程式碼是不是貼錯了?
右下角寫Uva516.c
這題應該是Uva 160
我發現到了!!
感謝回應!!
已更正:)
張貼留言