christmas/christmas_vanb.java
1
2 import java.io.*;
3 import java.util.*;
4 import java.awt.geom.*;
5
6
7
8
9
10
11 public class christmas_vanb
12 {
13 public Scanner sc;
14 public PrintStream ps;
15
16
17
18
19
20
21 public void doit() throws Exception
22 {
23 sc = new Scanner( new File( "christmas.judge" ) );
24 ps = new PrintStream( new FileOutputStream( "christmas.solution" ) );
25
26
27 long gifts[] = new long[1000001];
28 gifts[1] = 1L;
29 for( int i=2; i<=1000000; i++ )
30 {
31
32
33 long ii = i;
34 gifts[i] = ii*(ii+1)/2L + gifts[i-1];
35 }
36
37 for(;;)
38 {
39 int n = sc.nextInt();
40 if( n==0 ) break;
41 ps.println( gifts[n] );
42 }
43 }
44
45
46
47
48 public static void main( String[] args ) throws Exception
49 {
50 new christmas_vanb().doit();
51 }
52 }