結果
| 問題 |
No.2734 Addition and Multiplication in yukicoder (Hard)
|
| コンテスト | |
| ユーザー |
AngrySadEight
|
| 提出日時 | 2024-03-18 23:54:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,059 bytes |
| コンパイル時間 | 1,203 ms |
| コンパイル使用メモリ | 84,716 KB |
| 最終ジャッジ日時 | 2025-02-20 07:22:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 20 |
ソースコード
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
bool comp(string a, string b) { return a + b < b + a; }
ll mod = 998244353;
int main() {
ll N;
cin >> N;
vector<ll> A(N);
for (ll i = 0; i < N; i++) {
cin >> A[i];
}
vector<double> pow_d(19);
pow_d[0] = 1;
for (ll i = 0; i < 18; i++){
pow_d[i + 1] = pow_d[i] * 10;
}
vector<ll> pow_10(19);
pow_10[0] = 1;
for (ll i = 0; i < 18; i++) {
pow_10[i + 1] = (pow_10[i] * 10LL) % mod;
}
vector<pair<double, ll>> vec(N);
for (ll i = 0; i < N; i++){
ll len = to_string(A[i]).size();
vec[i].first = (double)(A[i]) / (pow_10[len] - 1);
vec[i].second = A[i];
}
sort(vec.begin(), vec.end());
ll ans = 0;
for (ll i = 0; i < N; i++) {
ll as_val = vec[i].second;
ll len = to_string(as_val).size();
ans = (ans * pow_10[len]) % mod;
ans = (ans + as_val % mod) % mod;
}
cout << ans << endl;
}
AngrySadEight