Submission #53376415
Source Code Expand
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 998244353;
const int MAX_LEN = 11; // 1e9までの数の最大桁数
// 長さが l の整数に対して 10^l を計算し、MOD を取る
vector<long long> power_of_ten(MAX_LEN);
void precompute_powers() {
power_of_ten[0] = 1;
for (int i = 1; i < MAX_LEN; ++i) {
power_of_ten[i] = power_of_ten[i - 1] * 10 % MOD;
}
}
// 整数 x の桁数を返す
int digit_length(long long x) {
if (x == 0) return 1;
int length = 0;
while (x) {
x /= 10;
length++;
}
return length;
}
int main() {
int N;
cin >> N;
vector<long long> A(N);
vector<int> len(N);
vector<vector<long long>> sum(MAX_LEN, vector<long long>(N + 1, 0));
precompute_powers();
for (int i = 0; i < N; ++i) {
cin >> A[i];
len[i] = digit_length(A[i]);
}
// 各桁数の値の合計を求める
for (int i = 0; i < N; ++i) {
for (int l = 1; l < MAX_LEN; ++l) {
sum[l][i + 1] = (sum[l][i] + (A[i] * power_of_ten[l] % MOD)) % MOD;
}
}
long long result = 0;
// 各ペアの f(A_i, A_j) の合計を計算
for (int i = 0; i < N; ++i) {
for (int j = i + 1; j < N; ++j) {
long long fij = (A[i] * power_of_ten[len[j]] % MOD + A[j]) % MOD;
result = (result + fij) % MOD;
}
}
cout << result << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Another Sigma Problem |
| User | noyan |
| Language | C++ 23 (gcc 12.2) |
| Score | 0 |
| Code Size | 1366 Byte |
| Status | TLE |
| Exec Time | 2208 ms |
| Memory | 24412 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 1 ms | 3656 KiB |
| 00_sample_02.txt | AC | 1 ms | 3468 KiB |
| 01_test_01.txt | TLE | 2208 ms | 24192 KiB |
| 01_test_02.txt | TLE | 2208 ms | 24272 KiB |
| 01_test_03.txt | TLE | 2208 ms | 24272 KiB |
| 01_test_04.txt | TLE | 2208 ms | 24180 KiB |
| 01_test_05.txt | TLE | 2208 ms | 24228 KiB |
| 01_test_06.txt | TLE | 2208 ms | 24336 KiB |
| 01_test_07.txt | TLE | 2208 ms | 24232 KiB |
| 01_test_08.txt | TLE | 2208 ms | 24256 KiB |
| 01_test_09.txt | TLE | 2208 ms | 24276 KiB |
| 01_test_10.txt | TLE | 2208 ms | 24252 KiB |
| 01_test_11.txt | TLE | 2208 ms | 24324 KiB |
| 01_test_12.txt | TLE | 2208 ms | 24284 KiB |
| 01_test_13.txt | TLE | 2208 ms | 17580 KiB |
| 01_test_14.txt | TLE | 2208 ms | 12116 KiB |
| 01_test_15.txt | TLE | 2208 ms | 10740 KiB |
| 01_test_16.txt | TLE | 2208 ms | 11868 KiB |
| 01_test_17.txt | AC | 1 ms | 3492 KiB |
| 01_test_18.txt | TLE | 2208 ms | 24324 KiB |
| 01_test_19.txt | TLE | 2208 ms | 24412 KiB |
| 01_test_20.txt | TLE | 2208 ms | 24220 KiB |