結果

問題 No.3625 Find Superfibonacci Number
コンテスト
ユーザー tnakao0123
提出日時 2026-08-17 16:35:32
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 984 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 199 ms
コンパイル使用メモリ 52,812 KB
実行使用メモリ 9,408 KB
最終ジャッジ日時 2026-08-17 16:35:34
合計ジャッジ時間 1,865 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3625.cc:  No.3625 Find Superfibonacci Number - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 1000000;

/* typedef */

/* global variables */

int ds[MAX_N];

/* subroutines */

void printds(int l, int ds[]) {
  for (int i = l - 1; i >= 0; i--) putchar('0' + ds[i]);
  putchar('\n');
}

/* main */

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

  while (tn--) {
    int k;
    scanf("%d", &k);

    int l = 0;
    for (int r = k; r > 0;) {
      int d = min(9, r);
      ds[l++] = d;
      r -= d;
    }
    //printds(l, ds);

    if (l == 1) {
      ds[2] = k / 2 + 1, ds[1] = 0, ds[0] = k - ds[2];
      l = 3;
    }
    else if (ds[l - 1] == 9) {
      ds[l + 1] = 1, ds[l] = 9, ds[l - 1] = 0, ds[l - 2] = 8;
      l += 2;
    }
    else {
      int d = ds[l - 1] + 9;
      ds[l] = d / 2 + 1, ds[l - 1] = 0, ds[l - 2] = d - ds[l];
      l++;
    }

    printds(l, ds);
  }

  return 0;
}

0