結果
問題 | No.2734 Addition and Multiplication in yukicoder (Hard) |
ユーザー |
|
提出日時 | 2024-04-19 22:31:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 118 ms / 5,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 2,329 ms |
コンパイル使用メモリ | 199,496 KB |
最終ジャッジ日時 | 2025-02-21 04:42:00 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%lld", &x); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>typedef long long LL;typedef __int128 LLL;const int N = 10;const int MOD = 998244353;int n;int main() {scanf("%d", &n);std::vector<std::pair<LL, LLL>> a(n);for(auto &[x, y]: a) {scanf("%lld", &x);LL t = x;y = 1;while(t) {t /= 10;y *= 10;}}std::sort(a.begin(), a.end(), [] (const auto &s, const auto &t) {auto &&[x, y] = s;auto &&[p, q] = t;return x * q + p < y * p + x;});int ans = 0;for(auto &&[x, y]: a)ans = (ans * y + x) % MOD;printf("%d\n", ans);return 0;}