Posted on 2009-03-23 17:50
Hero 阅读(85)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //1162 Accepted 390 156 607 C++
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6
7 int inn ;
8
9 int data[10010] ;
10
11 int main()
12 {
13 for( int i=1; i<10000; i++ )
14 {
15 int sum = 1 ;
16 int en = i / 2 + 1 ;
17 for( int sn=2; sn<=en; sn++ )
18 {
19 if( 0 == i % sn ) sum += sn ;
20 }
21
22 data[i] = sum ;
23 }
24
25 while( scanf( "%d", &inn ) != EOF )
26 {
27 printf( "%d:", inn ) ;
28 char *blank = " " ; int cnt = 0 ;
29 for( int i=2; i<=inn; i++ )
30 {
31 if( data[i] == i )
32 {
33 cnt++ ;
34 printf( "%s%d", blank, i ) ;
35 }
36 }
37 if( cnt == 0 ) printf( "%sNULL", blank ) ;
38 printf( "\n" ) ;
39 }
40
41 return 0 ;
42 }