Posted on 2008-11-05 15:59
Hero 阅读(104)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 // 1068 C++ Accepted 0.015 121 KB URAL
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6
7 typedef __int64 llong ;
8
9 int inn ;
10 llong out ;
11
12 int main()
13 {
14 while( scanf( "%d", &inn ) !=EOF )
15 {
16 int temp = abs( inn ) ;
17 out = temp*(1+temp)/2 ;
18
19 if( 0 == inn )
20 {
21 printf( "1\n" ) ;
22 }
23 else if( inn > 0 )
24 {
25 //out += 1 ;
26 printf( "%I64d\n", out ) ;
27 }
28 else
29 {
30 out -= 1 ;
31 out = out * -1 ;
32 printf( "%I64d\n", out ) ;
33 }
34 }
35
36 return 0 ;
37 }