-
#include <stdio.h>
-
int N,M,K;
-
int result;
-
void initialize(void)
-
{
-
scanf("%d %d %d", &N,&M,&K);
-
result=0;
-
}
-
-
void rotate_combination(int step, int upn, int upm, int totalmin)
-
{
-
int tmp;
-
if(step>10)
-
return;
-
if(result==1)
-
return;
-
if(totalmin==K)
-
{
-
result=1;
-
return;
-
}
-
-
if(upn > 0 && totalmin+upn <= K)
-
{
-
tmp = (upm-upn>0)?upm-upn:0;
-
rotate_combination(step+1, N, tmp, totalmin+upn);
-
rotate_combination(step+1, 0, M-tmp, totalmin+upn);
-
rotate_combination(step+1, N, M-tmp, totalmin+upn);
-
}
-
if(upm > 0 && totalmin+upm <= K)
-
{
-
tmp = (upn-upm>0)?upn-upm:0;
-
rotate_combination(step+1, N-tmp, 0, totalmin+upm);
-
rotate_combination(step+1, tmp, M, totalmin+upm);
-
rotate_combination(step+1, N-tmp, M, totalmin+upm);
-
}
-
}
-
-
int main()
-
{
-
int test_case,T;
-
freopen("20170524in.txt","r",stdin);
-
scanf("%d",&T);
-
for(test_case=1;test_case<=T;test_case++)
-
{
-
initialize();
-
rotate_combination(0,N,0,0);
-
rotate_combination(0,0,M,0);
-
rotate_combination(0,N,M,0);
-
printf("#%d %d\n", test_case,result);
-
}
-
fclose(stdin);
-
return 0;
-
}
/* input
5
3 5 7
12 13 118
8 3 9
1 103 18
4 3 41
*/
/* output
1
0
1
1
0
*/