結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー publflpublfl
提出日時 2021-02-19 21:32:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,147 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 31,764 KB
実行使用メモリ 4,484 KB
最終ジャッジ日時 2023-10-15 00:01:44
合計ジャッジ時間 26,280 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,356 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==1&&b==1)
	{
		if(c<=9) printf("%d",c);
		else printf("-1");
	}
	else if(a==1)
	{
		if(c<=18)
		{
			int s1 = c<9?c:9;
			int s2 = c-s1;
			for(int i=1;i<=b;i++)
			{
				if(i%3==1) printf("%d\n",s1);
				else if(i%3==2) printf("%d\n",s2);
				else printf("0\n");
			}
		}
		else printf("-1");
	}
	else if(b==1)
	{
		if(c<=18)
		{
			int s1 = c<9?c:9;
			int s2 = c-s1;
			for(int i=1;i<=a;i++)
			{
				if(i%3==1) printf("%d",s1);
				else if(i%3==2) printf("%d",s2);
				else printf("0");
			}
			printf("\n");
		}
		else printf("-1");
	}
	else
	{
		if(c<=36)
		{
			int s1 = c<9?c:9;
			int s2 = c-s1<9?c-s1:9;
			int s3 = c-s1-s2<9?c-s1-s2:9;
			int s4 = c-s1-s2-s3;
			for(int i=1;i<=b;i++)
			{
				for(int j=1;j<=a;j++)
				{
					if(i%3==0) printf("0");
					else if(j%3==0) printf("0");
					else
					{
						if(i%3==1 && j%3==1) printf("%d",s1);
						if(i%3==2 && j%3==1) printf("%d",s2);
						if(i%3==1 && j%3==2) printf("%d",s3);
						if(i%3==2 && j%3==2) printf("%d",s4);
					}
				}
				printf("\n");
			}
		}
		else printf("-1");
	}
	printf("\n");
}
0