LANG: C++
Compiling...
Compile: OK
Executing...
Test 1: TEST OK [0.000 secs, 5136 KB]
Test 2: TEST OK [0.000 secs, 5136 KB]
Test 3: TEST OK [0.000 secs, 5136 KB]
Test 4: TEST OK [0.000 secs, 5136 KB]
Test 5: TEST OK [0.000 secs, 5136 KB]
Test 6: TEST OK [0.027 secs, 5136 KB]
Test 7: TEST OK [0.000 secs, 5136 KB]
Test 8: TEST OK [0.000 secs, 5136 KB]
Test 9: TEST OK [0.000 secs, 5136 KB]
Test 10: TEST OK [0.000 secs, 5136 KB]
Test 11: TEST OK [0.000 secs, 5136 KB]
Test 12: TEST OK [0.000 secs, 5136 KB]
Test 13: TEST OK [0.000 secs, 5136 KB]
All tests OK.
1
/*
2 PROG: money
3 ID: jiafeim1
4 LANG: C++
5 */
6
7 #include < algorithm >
8 #include < iostream >
9 #include < fstream >
10
11 using namespace std;
12
13 int m_num;
14 long target;
15
16 int money[ 28 ];
17
18 long long amount[ 10003 ][ 27 ] = { 0 };
19 int main()
20 {
21 std::ifstream fin( " money.in " );
22 std::ofstream fout( " money.out " );
23
24 fin >> m_num >> target;
25
26 for ( int i = 0 ;i != m_num; ++ i)
27 {
28 fin >> money[i];
29 }
30
31 for ( long i = 1 ;i <= target; ++ i)
32 {
33 for ( int j = 0 ;j != m_num; ++ j)
34 {
35
36 if (i < money[j]) continue ;
37 if (i == money[j])
38 {
39 amount[i][j] += 1 ;
40 }
41 for ( int z = 0 ;z <= j; ++ z)
42 {
43 if (amount[i - money[j]][z] != 0 )
44 amount[i][j] += amount[i - money[j]][z];
45 }
46 }
47 }
48 long long temp = 0 ;
49 for ( int i = 0 ;i != m_num; ++ i)
50 {
51 temp += amount[target][i];
52 }
53 fout << temp << endl;
54 fin.close();
55 fout.close();
56
57 }
2 PROG: money
3 ID: jiafeim1
4 LANG: C++
5 */
6
7 #include < algorithm >
8 #include < iostream >
9 #include < fstream >
10
11 using namespace std;
12
13 int m_num;
14 long target;
15
16 int money[ 28 ];
17
18 long long amount[ 10003 ][ 27 ] = { 0 };
19 int main()
20 {
21 std::ifstream fin( " money.in " );
22 std::ofstream fout( " money.out " );
23
24 fin >> m_num >> target;
25
26 for ( int i = 0 ;i != m_num; ++ i)
27 {
28 fin >> money[i];
29 }
30
31 for ( long i = 1 ;i <= target; ++ i)
32 {
33 for ( int j = 0 ;j != m_num; ++ j)
34 {
35
36 if (i < money[j]) continue ;
37 if (i == money[j])
38 {
39 amount[i][j] += 1 ;
40 }
41 for ( int z = 0 ;z <= j; ++ z)
42 {
43 if (amount[i - money[j]][z] != 0 )
44 amount[i][j] += amount[i - money[j]][z];
45 }
46 }
47 }
48 long long temp = 0 ;
49 for ( int i = 0 ;i != m_num; ++ i)
50 {
51 temp += amount[target][i];
52 }
53 fout << temp << endl;
54 fin.close();
55 fout.close();
56
57 }