結果
問題 |
No.2811 Calculation Within Sequence
|
ユーザー |
![]() |
提出日時 | 2024-07-22 17:19:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 830 bytes |
コンパイル時間 | 426 ms |
コンパイル使用メモリ | 40,568 KB |
最終ジャッジ日時 | 2025-02-23 17:52:04 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:44:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%d%d", &a, &b); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:45:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | for (int i = 0; i < a; i++) scanf("%d", ts + i); | ~~~~~^~~~~~~~~~~~~~ main.cpp:46:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | for (int i = 0; i < b; i++) scanf("%d", ss + i); | ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 2811.cc: No.2811 Calculation Within Sequence - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ /* global variables */ int ts[MAX_N], ss[MAX_N]; /* subroutines */ template <typename T> T gcd(T m, T n) { // m >= 0, n >= 0 if (m < n) swap(m, n); while (n > 0) { T r = m % n; m = n; n = r; } return m; } int gcdv(int n, int as[]) { int g = 0; for (int i = 0; i < n; i++) g = gcd(g, as[i]); return g; } /* main */ int main() { int a, b; scanf("%d%d", &a, &b); for (int i = 0; i < a; i++) scanf("%d", ts + i); for (int i = 0; i < b; i++) scanf("%d", ss + i); int tg = gcdv(a, ts); int sg = gcdv(b, ss); if (sg % tg == 0) puts("Yes"); else puts("No"); return 0; }