結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー kotatsugame
提出日時 2021-02-24 23:59:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 3,153 ms
コード長 400 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 65,720 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 00:52:53
合計ジャッジ時間 26,616 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int H,W,X;
int A[3][3];
main()
{
	cin>>W>>H>>X;
	for(int i=0;i<3;i++)for(int j=0;j<3;j++)
	{
		if(H%3==0?i!=1:H%3==1?i!=0:i==2)continue;
		if(W%3==0?j!=1:W%3==1?j!=0:j==2)continue;
		if(X>9)A[i][j]=9;
		else A[i][j]=X;
		X-=A[i][j];
	}
	if(X)cout<<-1<<endl;
	else
	{
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)cout<<A[i%3][j%3];
			cout<<endl;
		}
	}
}
0