結果
問題 |
No.1992 Tendon Walk
|
ユーザー |
![]() |
提出日時 | 2022-07-02 18:09:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 223 ms |
コンパイル使用メモリ | 40,060 KB |
最終ジャッジ日時 | 2025-01-30 04:02:38 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d", &x); | ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 1992.cc: No.1992 Tendon Walk - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int K = 7; const int ds[K] = { 2, 2, -1, -1, 2, -1, -1 }; /* typedef */ /* global variables */ /* subroutines */ /* main */ int main() { int x; scanf("%d", &x); int p = 0, l = 0; for (int i = 0;; i++) { int di = ds[i % K]; p += di; l += abs(di); if (p == x) break; } printf("%d\n", l); return 0; }