結果

問題 No.2038 Strange Arrange
ユーザー 👑 ygussanyygussany
提出日時 2022-08-12 21:58:03
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 30,228 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 23:13:27
合計ジャッジ時間 657 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:11:30: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
   11 |                 if (j == 10) exit(0);
      |                              ^~~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | 
main.c:11:30: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   11 |                 if (j == 10) exit(0);
      |                              ^~~~
main.c:11:30: note: include '<stdlib.h>' or provide a declaration of 'exit'

ソースコード

diff #

#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	
	int i, j, k, ans[503], flag[503][10] = {};
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= 9; j++) if (flag[i][j] == 0) break;
		if (j == 10) exit(0);
		ans[i] = j;
		flag[i+1][j] = 1;
		for (j = 1; j < i && i + j <= N; j++) {
			if (ans[j] == ans[i]) for (k = 1; k <= ans[i]; k++) flag[i+j][k] = 1;
		}
	}
	for (i = 1; i <= N; i++) printf("%d", ans[i]);
	printf("\n");
	fflush(stdout);
	return 0;
}
0