Pagini recente » Cod sursa (job #345525) | Cod sursa (job #301763) | Cod sursa (job #1564644) | Cod sursa (job #1493215) | Cod sursa (job #420555)
Cod sursa(job #420555)
#include <iostream>
#include <fstream>
using namespace std;
#define MOD 10000
int N, M, X;
int A[2*45001], B[2*45001];
int main() {
fstream f1, f2;
int i, j, p, q, Smax=0;
f1.open("diamant.in", ios::in);
f2.open("diamant.out", ios::out);
f1>>N>>M>>X;
for(i=1; i<=N; i++) {
for(j=1; j<=M; j++) {
Smax+=i*j;
}
}
if(X>Smax || X<-Smax) {
f2<<0<<endl;
}
else {
B[Smax]=1;
for(i=1; i<=N; i++) {
for(j=1; j<=M; j++) {
for(p=-Smax; p<=Smax; p++) {
A[Smax+p]=(B[Smax+i*j+p]+B[Smax+p]+B[Smax-i*j+p])%MOD;
}
for(p=-Smax; p<=Smax; p++) {
B[Smax+p]=A[Smax+p];
}
}
}
f2<<B[Smax+X]<<endl;
}
f1.close(); f2.close();
return 0;
}