結果
問題 | No.2734 Addition and Multiplication in yukicoder (Hard) |
ユーザー |
![]() |
提出日時 | 2024-04-30 18:31:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 598 ms / 5,000 ms |
コード長 | 804 bytes |
コンパイル時間 | 763 ms |
コンパイル使用メモリ | 69,404 KB |
最終ジャッジ日時 | 2025-02-21 09:54:43 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:36:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 39 | scanf("%s", s); | ~~~~~^~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 2734.cc: No.2734 Addition and Multiplication in yukicoder (Hard) - yukicoder */ #include<cstdio> #include<string> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 200000; const int MAX_L = 20; const int MOD = 998244353; /* typedef */ typedef long long ll; /* global variables */ string as[MAX_N]; /* subroutines */ bool cmpstr(const string &a, const string &b) { return (a + b) < (b + a); } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { char s[MAX_L + 4]; scanf("%s", s); as[i] = string(s); } sort(as, as + n, cmpstr); int sum = 0; for (int i = 0; i < n; i++) for (auto c: as[i]) sum = ((ll)sum * 10 + (c - '0')) % MOD; printf("%d\n", sum); return 0; }