Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
gzshawnliang committed Aug 8, 2019
1 parent de2461c commit 6ee73b0
Show file tree
Hide file tree
Showing 5 changed files with 20,070 additions and 1 deletion.
2 changes: 1 addition & 1 deletion myCpps/!-OJcreater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using namespace std;

//***************************************
const string CPPfile = "maps"; //*
const string CPPfile = "squares_UVA11407"; //*
//***************************************

ifstream fin(CPPfile + ".cpp");
Expand Down
33 changes: 33 additions & 0 deletions myCpps/squares_UVA11407.cpp
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;
}
Loading

0 comments on commit 6ee73b0

Please sign in to comment.