結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー KKT89
提出日時 2021-02-19 22:22:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 919 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 191,964 KB
最終ジャッジ日時 2025-01-19 00:33:03
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other AC * 2 WA * 1 RE * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

constexpr ll mod=1e9+7;

ll mod_pow(ll x,ll n){
	x%=mod;
	ll res=1;
	while(n>0){
		if(n&1LL)res=res*x%mod;
		x=x*x%mod; n>>=1LL;
	}
	return res;
}

void solve(int h,int w,int k){
	if(h==1){
		if(w==1){
			if(k<=9) printf("9\n");
			else printf("-1\n");
			return;
		}
		if(k<=18 and w%3==2){
			for(int i=0;i<w;i++){
				if(i%3==0)printf("%d",min(k,9));
				else if(i%3==1)printf("%d",k-min(k,9));
				else printf("0");
			}
			printf("\n");
			return;
		}
		printf("-1\n");
		return;
	}
	if(w==1){
		if(k<=18 and h%3==2){
			for(int i=0;i<h;i++){
				if(i%3==0)printf("%d\n",min(k,9));
				else if(i%3==1)printf("%d\n",k-min(k,9));
				else printf("0\n");
			}
			return;
		}
		return;
	}
	assert(0);
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h,w,k; cin >> w >> h >> k;
	solve(h,w,k);
}
0