Cod sursa(job #2701309)
Utilizator | Data | 30 ianuarie 2021 13:38:39 | |
---|---|---|---|
Problema | Diamant | Scor | 90 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("diamant.in");
ofstream g("diamant.out");
int n,m,dp[100005],l;
long long sum,s;
int main()
{
f>>n>>m>>s;
if(s<0)
s=-s;
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
sum=sum+i*j;
s=sum-s;
dp[0]=1;
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
for(int l=s;l>=i*j;--l)
{
dp[l]+=dp[l-i*j];
if(l>=2*i*j)
dp[l]+=dp[l-2*i*j];
dp[l]=dp[l]%10000;
}
g<<dp[s];
}