結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー KKT89KKT89
提出日時 2021-02-19 22:22:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 919 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 197,796 KB
実行使用メモリ 4,484 KB
最終ジャッジ日時 2023-10-15 02:54:52
合計ジャッジ時間 27,959 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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