結果
問題 | No.736 約比 |
ユーザー |
![]() |
提出日時 | 2018-10-08 19:52:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,000 bytes |
コンパイル時間 | 865 ms |
コンパイル使用メモリ | 98,600 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 15:37:55 |
合計ジャッジ時間 | 2,641 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 65 |
ソースコード
#include <stdio.h> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <functional> #include <map> #include <iomanip> #include <math.h> #include <stack> #include <queue> #include <bitset> #include <cstdlib> #include <tuple> #include <cctype> #include <ctype.h> #include <set> #include <sstream> using namespace std; long long func(long long a, long long b) { //cout << "a->" << a << " " << "b->" << b << endl; if (b > a)swap(a, b); if (a%b == 0) { return b; } else { return func(b, a%b); } //return 0; } int main(){ int i, j, k; int a, b, n; vector<long long>list; cin >> n; for (i = 0; i < n; i++) { long long num; cin >> num; list.push_back(num); } long long num = func(list[0], list[1]); if (n >= 3) { for (i = 2; i < n; i++) { num = func(list[i], num); } } for (i = 0; i < n; i++) { cout << list[i] / num; if (i != n - 1) { cout << ":"; } } cout << endl; getchar(); getchar(); return 0; }