結果

問題 No.2773 Wake up Record 1
ユーザー ななりななり
提出日時 2024-09-10 00:02:24
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,333 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 31,232 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-10 00:02:25
合計ジャッジ時間 1,384 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:9:15: warning: built-in function 'exp' declared as non-function [-Wbuiltin-declaration-mismatch]
    9 | const int32_t exp[] = { 100000, 10000, 1000, 100, 10, 1 };
      |               ^~~

ソースコード

diff #

#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC optimize "Ofast"

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const int32_t exp[] = { 100000, 10000, 1000, 100, 10, 1 };
uint8_t c, ostr[1000000], *optr = ostr;
int64_t n = 0;

int main() {
  fseek(stdin, 0, 2);
  int64_t istrlen = ftell(stdin);
  uint8_t *istr = (uint8_t*)malloc(istrlen), *iptr = istr;
  fseek(stdin, 0, 0);
  fread(istr, 1, istrlen, stdin);
  while ((c = *iptr++) >= '0') n = n * 10 + (c - '0');

  for (int64_t i = 2; i <= n; ) {
    if (*(int16_t*)iptr == 0x6F78) {
      iptr += 2;

      if (i == 100000) {
        memcpy(optr, "100000", 6);
        optr += 6;
      }
      if (i > 9999) {
        for (uint8_t j = 0; j < 5; ++j) *optr++ = i % exp[j] / exp[j + 1] + '0';
      }
      else if (i > 999) {
        for (uint8_t j = 1; j < 5; ++j) *optr++ = i % exp[j] / exp[j + 1] + '0';
      }
      else if (i > 99) {
        for (uint8_t j = 2; j < 5; ++j) *optr++ = i % exp[j] / exp[j + 1] + '0';
      }
      else if (i > 9) {
        for (uint8_t j = 3; j < 5; ++j) *optr++ = i % exp[j] / exp[j + 1] + '0';
      }
      else {
        *optr++ = i + '0';
      }

      *optr++ = ' ';
      i += 2;
    }
    else {
      ++i;
      ++iptr;
    }
  }

  fwrite(ostr, 1, optr - ostr, stdout);
  return 0;
}
0