LANG: C++
Compiling...
Compile: OK
Executing...
Test 1: TEST OK [0.000 secs, 3148 KB]
Test 2: TEST OK [0.000 secs, 3148 KB]
Test 3: TEST OK [0.000 secs, 3148 KB]
Test 4: TEST OK [0.000 secs, 3148 KB]
Test 5: TEST OK [0.000 secs, 3148 KB]
Test 6: TEST OK [0.000 secs, 3148 KB]
Test 7: TEST OK [0.000 secs, 3148 KB]
All tests OK.
1
/*
2 PROG: subset
3 ID: jiafeim1
4 LANG: C++
5 */
6
7
8 #include < iostream >
9 #include < fstream >
10
11 using namespace std;
12
13 int n;
14 int total = 0 ;
15 int now_res = 0 ;
16 int upper;
17 unsigned long res[ 42 ][ 800 ] = { 0 };
18
19 int main()
20 {
21 std::ifstream fin( " subset.in " );
22 std::ofstream fout( " subset.out " );
23
24 fin >> n;
25 upper = (n + 1 ) * n / 2 ;
26
27 res[ 0 ][ 0 ] = 1 ;
28 if (upper % 2 == 0 )
29 {
30 upper /= 2 ;
31 for ( int i = 1 ;i <= n; ++ i)
32 for ( int sum = upper;sum >= 0 ; -- sum)
33 {
34 if (sum >= i && res[i - 1 ][sum - i] != 0 )
35 res[i][sum] = res[i - 1 ][sum - i];
36 if (res[i - 1 ][sum] != 0 )
37 res[i][sum] += res[i - 1 ][sum];
38 }
39 fout << res[n][upper] / 2 << endl;
40 }
41 else
42 {
43 fout << 0 << endl;
44 }
45 fin.close();
46 fout.close();
47
48 }
2 PROG: subset
3 ID: jiafeim1
4 LANG: C++
5 */
6
7
8 #include < iostream >
9 #include < fstream >
10
11 using namespace std;
12
13 int n;
14 int total = 0 ;
15 int now_res = 0 ;
16 int upper;
17 unsigned long res[ 42 ][ 800 ] = { 0 };
18
19 int main()
20 {
21 std::ifstream fin( " subset.in " );
22 std::ofstream fout( " subset.out " );
23
24 fin >> n;
25 upper = (n + 1 ) * n / 2 ;
26
27 res[ 0 ][ 0 ] = 1 ;
28 if (upper % 2 == 0 )
29 {
30 upper /= 2 ;
31 for ( int i = 1 ;i <= n; ++ i)
32 for ( int sum = upper;sum >= 0 ; -- sum)
33 {
34 if (sum >= i && res[i - 1 ][sum - i] != 0 )
35 res[i][sum] = res[i - 1 ][sum - i];
36 if (res[i - 1 ][sum] != 0 )
37 res[i][sum] += res[i - 1 ][sum];
38 }
39 fout << res[n][upper] / 2 << endl;
40 }
41 else
42 {
43 fout << 0 << endl;
44 }
45 fin.close();
46 fout.close();
47
48 }