結果
| 問題 | No.3242 Count 8 Included Numbers (Hard) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-19 19:00:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,277 bytes |
| 記録 | |
| コンパイル時間 | 1,475 ms |
| コンパイル使用メモリ | 157,704 KB |
| 実行使用メモリ | 76,904 KB |
| 最終ジャッジ日時 | 2025-12-19 19:00:29 |
| 合計ジャッジ時間 | 11,911 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 1 WA * 3 RE * 16 |
ソースコード
#include <string>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <iomanip>
#include <ctime>
#include <valarray>
#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
const int mod = 998244353;
LL dp[N][2];
LL solve(string& str, int pos, int flag = 0, bool limit = true, bool lead = true)
{
if (pos == -1)
{
return flag;
}
if (!limit && !lead && dp[pos][flag] != -1) return dp[pos][flag];
int up = limit ? str[pos] - '0' : 9;
LL ret = 0;
for (int i = 0; i <= up; i++)
{
ret += solve(str, pos - 1, flag || i == 8, limit && i == str[pos] - '0', lead && i == 0);
}
ret %= mod;
if (!limit && !lead)
dp[pos][flag] = ret;
return ret;
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
MEM(dp, -1);
string str;
cin >> str;
cout << solve(str, str.length() - 1) << endl;
return 0;
}