Pagini recente » Cod sursa (job #863838) | Cod sursa (job #3193431) | Cod sursa (job #1937953) | Cod sursa (job #293507) | Cod sursa (job #48014)
Cod sursa(job #48014)
#include <stdio.h>
long int a[44110] , b[44110] ;
long int abs(long int a)
{
if(a >= 0) return a ;
return a * (-1) ;
}
int main()
{
FILE *in , *out ;
in = fopen("diamant.in" , "rt") ;
out = fopen("diamant.out" , "wt") ;
long int n , m , x , count , nr = 1 , val , i;
fscanf(in , "%ld %ld %ld" , &n , &m , &x) ;
if(x < 0) x *= - 1 ;
a[0] = 1 ;
a[1] = 1 ;
count = 1 ;
while(0 < 5)
{
val = (count / m + 1) * (count % m + 1) ;
nr += val ;
for(i = 1 ; i <= nr ; i++)
{
b[i] = a[i] ;
if(i + val <= nr) b[i] += a[i + val] ;
if(i - val >= -nr) b[i] += a[abs(i - val)] ;
b[i] %= 10000 ;
}
if(count >= n * m - 1) break ;
count ++ ;
val = (count / n + 1) * (count % m + 1) ;
nr += val ;
for(i = 1 ; i <= nr ; i++)
{
a[i] = b[i] ;
if(i + val <= nr) a[i] += b[i + val] ;
if(i - val >= -nr) a[i] += b[abs(i - val)] ;
a[i] %= 10000 ;
}
if(count >= n * m - 1) break ;
count ++ ;
}
if(x <= 44100)
{
if(n * m % 2 == 0) fprintf(out , "%ld" , b[x]) ;
else fprintf(out , "%ld" , a[x]) ;
}
else fprintf(out , "0") ;
fclose(in) ;
fclose(out) ;
return 0 ;
}