結果

問題 No.2870 Dice Making
コンテスト
ユーザー ななり
提出日時 2024-09-09 22:58:49
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 0 ms / 2,000 ms
+ 764µs
コード長 695 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 68 ms
コンパイル使用メモリ 38,528 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-23 13:02:18
合計ジャッジ時間 2,643 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

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

uint8_t c, ostr[200], *optr = ostr;

int main() {
  uint8_t istr[10], *iptr = istr, n = 0, k = 0;
  fread(istr, 1, 10, stdin);
  while ((c = *iptr++) >= '0') n = n * 10 + (c - '0');
  while ((c = *iptr++) >= '0') k = k * 10 + (c - '0');

  if (n % k == 0) {
    int8_t t = n / k, r = n - t;

    while (--t >= 0) {
      memcpy(optr, "1 ", 2);
      optr += 2;
    }

    while (--r >= 0) {
      memcpy(optr, "2 ", 2);
      optr += 2;
    }
  }
  else {
    memcpy(optr, "-1", 2);
    optr += 2;
  }

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