-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f31bab
commit f60bb51
Showing
30 changed files
with
2,817 additions
and
17 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
ifstream fin("ECoins_UVA10306.in"); | ||
ofstream fout("ECoins_UVA10306.out"); | ||
|
||
struct coin | ||
{ | ||
int x; | ||
int y; | ||
}; | ||
|
||
int main() | ||
{ | ||
int testCase; fin >> testCase; | ||
for (int t = 1; t <= testCase; ++t) | ||
{ | ||
int m, s; fin >> m >> s; | ||
|
||
vector<coin> a(m); | ||
for (int i = 0; i <= m - 1; ++i) | ||
{ | ||
fin >> a[i].x >> a[i].y; | ||
} | ||
|
||
vector<vector<int>> dp(s + 1, vector<int>(s + 1, INT_MAX)); | ||
|
||
int ans = INT_MAX; | ||
dp[0][0] = 0; | ||
|
||
for (int i = 0; i <= s; ++i) | ||
{ | ||
for (int j = 0; j <= s; ++j) | ||
{ | ||
for (int k = 0; k <= m - 1; ++k) | ||
{ | ||
if (i - a[k].x < 0 || j - a[k].y < 0) | ||
{ | ||
continue; | ||
} | ||
|
||
if (dp[i - a[k].x][j - a[k].y] < INT_MAX) | ||
{ | ||
dp[i][j] = min(dp[i][j], dp[i - a[k].x][j - a[k].y] + 1); | ||
} | ||
|
||
if (i * i + j * j == s * s && dp[i][j] < INT_MAX) | ||
{ | ||
ans = min(ans, dp[i][j]); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (ans == INT_MAX) | ||
{ | ||
fout << "not possible\n"; | ||
} | ||
else | ||
{ | ||
fout << ans << '\n'; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
9 | ||
2 5 | ||
0 2 | ||
2 0 | ||
|
||
3 20 | ||
0 2 | ||
2 0 | ||
2 1 | ||
3 5 | ||
3 0 | ||
0 4 | ||
5 5 | ||
3 5 | ||
3 0 | ||
0 4 | ||
1 1 | ||
4 13 | ||
0 1 | ||
0 5 | ||
0 2 | ||
0 3 | ||
4 11 | ||
1 0 | ||
2 0 | ||
3 0 | ||
10 0 | ||
|
||
10 13 | ||
1 0 | ||
2 2 | ||
2 0 | ||
3 3 | ||
6 12 | ||
3 11 | ||
7 13 | ||
14 14 | ||
0 5 | ||
0 4 | ||
|
||
2 300 | ||
3 0 | ||
300 1 | ||
|
||
40 300 | ||
1 0 | ||
2 2 | ||
2 0 | ||
3 3 | ||
6 12 | ||
3 11 | ||
7 13 | ||
14 14 | ||
0 5 | ||
0 4 | ||
1 0 | ||
2 2 | ||
2 0 | ||
3 3 | ||
6 12 | ||
3 11 | ||
7 13 | ||
14 14 | ||
0 5 | ||
0 4 | ||
1 0 | ||
2 2 | ||
2 0 | ||
3 3 | ||
6 12 | ||
3 11 | ||
7 13 | ||
14 14 | ||
0 5 | ||
0 4 | ||
1 0 | ||
2 2 | ||
2 0 | ||
3 3 | ||
6 12 | ||
3 11 | ||
7 13 | ||
14 14 | ||
0 5 | ||
0 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
not possible | ||
10 | ||
2 | ||
2 | ||
3 | ||
2 | ||
3 | ||
100 | ||
18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
|
||
struct coin | ||
{ | ||
int x; | ||
int y; | ||
}; | ||
|
||
int main() | ||
{ | ||
ios_base::sync_with_stdio(false); | ||
std::cin.tie(NULL); | ||
int testCase; cin >> testCase; | ||
for (int t = 1; t <= testCase; ++t) | ||
{ | ||
int m, s; cin >> m >> s; | ||
|
||
vector<coin> a(m); | ||
for (int i = 0; i <= m - 1; ++i) | ||
{ | ||
cin >> a[i].x >> a[i].y; | ||
} | ||
|
||
vector<vector<int>> dp(s + 1, vector<int>(s + 1, INT_MAX)); | ||
|
||
int ans = INT_MAX; | ||
dp[0][0] = 0; | ||
|
||
for (int i = 0; i <= s; ++i) | ||
{ | ||
for (int j = 0; j <= s; ++j) | ||
{ | ||
for (int k = 0; k <= m - 1; ++k) | ||
{ | ||
if (i - a[k].x < 0 || j - a[k].y < 0) | ||
{ | ||
continue; | ||
} | ||
|
||
if (dp[i - a[k].x][j - a[k].y] < INT_MAX) | ||
{ | ||
dp[i][j] = min(dp[i][j], dp[i - a[k].x][j - a[k].y] + 1); | ||
} | ||
|
||
if (i * i + j * j == s * s && dp[i][j] < INT_MAX) | ||
{ | ||
ans = min(ans, dp[i][j]); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (ans == INT_MAX) | ||
{ | ||
cout << "not possible\n"; | ||
} | ||
else | ||
{ | ||
cout << ans << '\n'; | ||
} | ||
} | ||
|
||
cout.flush(); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
ifstream fin("barCodes_UVA10721.in"); | ||
ofstream fout("barCodes_UVA10721.out"); | ||
|
||
int main() | ||
{ | ||
while (true) | ||
{ | ||
long long n = 0, k = 0, m = 0; fin >> n >> k >> m; | ||
if (n + k + m == 0) break; | ||
|
||
vector<vector<long long>> dp(k + 1, vector<long long>(n + 1, 0)); | ||
|
||
dp[0][0] = 1; | ||
for (int i = 1; i <= k; ++i) | ||
{ | ||
for (int j = 1; j <= n; ++j) | ||
{ | ||
for (int t = 1; t <= j; ++t) | ||
{ | ||
if (t > m) break; | ||
dp[i][j] += dp[i - 1][j - t]; | ||
} | ||
} | ||
} | ||
|
||
fout << dp[k][n] << '\n'; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.