結果

問題 No.2038 Strange Arrange
ユーザー tnakao0123tnakao0123
提出日時 2022-08-17 01:12:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 42,572 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 18:43:14
合計ジャッジ時間 1,645 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2038.cc:  No.2038 Strange Arrange - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 500;

/* typedef */

/* global variables */

int as[MAX_N + 1];

/* subroutines */

void check(int n) {
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (as[i] == as[j] && i + j <= n && as[i] >= as[i + j]) {
	puts("NG"); return;
      }
  puts("OK");
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 1, bi = 1; i <= 9 && bi <= n; i++, bi <<= 1)
    for (int j = 1; j * bi <= n; j += 2) as[j * bi] = i;

  for (int i = 1; i <= n; i++) putchar('0' + as[i]);
  putchar('\n');

  //check(n);
  return 0;
}
0