結果
問題 | No.2119 一般化百五減算 |
ユーザー |
![]() |
提出日時 | 2022-11-04 21:53:11 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 837 bytes |
コンパイル時間 | 130 ms |
コンパイル使用メモリ | 30,080 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 19:37:41 |
合計ジャッジ時間 | 1,147 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <stdio.h> int main () { int n = 0; int m = 0; int b[100000] = {}; int c[100000] = {}; int res = 0; int prev[100001] = {}; int ap[100001] = {}; int cnt = 0; int is_ok = 1; int ans = 0; res = scanf("%d", &n); res = scanf("%d", &m); for (int i = 0; i < m; i++) { res = scanf("%d", b+i); res = scanf("%d", c+i); if (c[i] < 0) { c[i] += (1+(-c[i])/b[i])*b[i]; } if (prev[b[i]] > 0) { int idx = prev[b[i]]-1; if (c[i]%b[i] == c[idx]%b[idx]) { is_ok = 0; } } else { for (int j = c[i]%b[i]; j <= n; j += b[i]) { ap[j]++; } cnt++; } prev[b[i]] = i+1; } while (ans <= n) { if (ap[ans] >= cnt) { printf("%d\n", ans); return 0; } ans++; } printf("NaN\n"); return 0; }