Cod sursa(job #1775650)
| Utilizator | Data | 10 octombrie 2016 16:47:47 | |
|---|---|---|---|
| Problema | Diamant | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.72 kb |
#include <fstream>
using namespace std;
ifstream f("diamant.in");
ofstream g("diamant.out");
long long d[2000][2000],gg,w[100005],n,m,k,yx;
int main()
{
int i,j;
f>>n>>m>>gg;
if (gg<0)gg=gg*(-1);
if (gg>44100)
{
return 0;
}
for (i=1;i<=n;i++)
{
for (j=1;j<=m;j++)
{
w[++k]=i*j;
}
}
d[0][0]=1;
yx=gg;
for (i=1;i<=k;i++)
{
for (j=0;j<=yx;j++)
{
if (w[i]<=j)
{
d[i][j]=max(d[i-1][j],d[i-1][j-w[i]]+1);
}
else
{
d[i][j]=d[i-1][j];
}
}
}
g<<d[k][yx]%10000;
return 0;
}
