結果
問題 | No.933 おまわりさんこいつです |
ユーザー |
|
提出日時 | 2025-03-01 20:43:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 755 bytes |
コンパイル時間 | 3,764 ms |
コンパイル使用メモリ | 334,160 KB |
実行使用メモリ | 8,232 KB |
最終ジャッジ日時 | 2025-03-01 20:43:31 |
合計ジャッジ時間 | 10,070 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 TLE * 1 -- * 1 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <boost/multiprecision/cpp_int.hpp> using namespace std; using namespace boost::multiprecision; // 各桁の和を求める関数(ループ回数削減のために高速化) inline int digit_sum(const string &x) { int res = 0; for (char c : x) { res += c - '0'; } return res; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; cpp_int y = 1; for (int i = 0; i < n; ++i) { long long k; cin >> k; y *= k; } string y_str = y.str(); while (y_str.length() > 1) { y_str = to_string(digit_sum(y_str)); } cout << y_str << '\n'; return 0; }