結果
問題 | No.8045 怪文書 |
ユーザー |
![]() |
提出日時 | 2019-04-01 21:39:03 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 858 bytes |
コンパイル時間 | 144 ms |
コンパイル使用メモリ | 30,208 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 21:49:23 |
合計ジャッジ時間 | 969 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<inttypes.h> typedef int32_t i32; typedef int64_t i64; void run (void) { i32 n, m; scanf ("%" SCNi32 "%" SCNi32, &n, &m); i32 *a = (i32 *) calloc (n, sizeof (i32)); for (i32 i = 0; i < n; ++i) { scanf ("%" SCNi32, a + i); } i32 l = 0; while (l < n) { if (a[l] % 2 == 0) { l++; continue; } i64 sum = a[l]; i32 r = l + 1; while (r < n && a[r] % 2 == 1) { sum += a[r++]; } if (r - l >= m) { printf ("%" PRIi64 "\n", sum); } l = r; } } void solve (void) { i32 n, m; scanf ("%" SCNi32 "%" SCNi32, &n, &m); if (n >= m) { puts("0"); return; } i32 ans = 1; while (n > 0) { ans = (i64) ans * n-- % m; } printf ("%" PRIi32 "\n", ans); } int main (void) { solve(); //run (); return 0; }