結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー butsurizukibutsurizuki
提出日時 2021-02-19 21:40:45
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 14 ms / 3,153 ms
コード長 702 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 29,508 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-15 00:23:42
合計ジャッジ時間 25,014 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<stdio.h>
int min(int a,int b){if(a<b){return a;}return b;}

int main(){
  int h,w,x;
  scanf("%d%d%d",&w,&h,&x);
  int fl=0;
  if(h%3==0){fl|=3;}
  if(h%3==1){fl|=12;}
  if(w%3==0){fl|=5;}
  if(w%3==1){fl|=10;}
  int a=0,b=0,c=0,d=0;
  if((fl&1)==0){a=min(9,x);x-=a;}
  if((fl&2)==0){b=min(9,x);x-=b;}
  if((fl&4)==0){c=min(9,x);x-=c;}
  if((fl&8)==0){d=min(9,x);x-=d;}
  if(x>0){puts("-1");return 0;}
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i%3==0&&j%3==0){printf("%d",a);}
      else if(i%3==0&&j%3==1){printf("%d",b);}
      else if(i%3==1&&j%3==0){printf("%d",c);}
      else if(i%3==1&&j%3==1){printf("%d",d);}
      else{printf("0");}
    }puts("");
  }
  return 0;
}
0