-
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
de2461c
commit 6ee73b0
Showing
5 changed files
with
20,070 additions
and
1 deletion.
There are no files selected for viewing
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,33 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
ifstream fin("squares_UVA11407.in"); | ||
ofstream fout("squares_UVA11407.out"); | ||
|
||
const int N = 10000; | ||
|
||
int main() | ||
{ | ||
vector<vector<int>> dp(101, vector<int>(N + 1, N)); dp[0][0] = 0; | ||
for (int i = 1; i <= 100; ++i) | ||
{ | ||
for (int j = 0; j <= N; ++j) | ||
{ | ||
for (int c = 0; c * i * i <= j; ++c) | ||
{ | ||
dp[i][j] = min(dp[i][j], dp[i - 1][j - c * i * i] + c); | ||
} | ||
} | ||
} | ||
|
||
int tcc; fin >> tcc; | ||
for (int t = 1; t <= tcc; ++t) | ||
{ | ||
int x; fin >> x; | ||
|
||
fout << dp[100][x] << '\n'; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.