結果
問題 |
No.3264 岩井数
|
ユーザー |
![]() |
提出日時 | 2025-09-06 14:45:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,248 bytes |
コンパイル時間 | 6,387 ms |
コンパイル使用メモリ | 333,960 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-06 14:46:49 |
合計ジャッジ時間 | 32,214 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 TLE * 10 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; tuple<i64, i64, int> func(i64 x) { i64 res = 0; auto y = x; while (y > 0) { res *= 10; res += y % 10; y /= 10; } int len = to_string(x).size(); i64 f = 1; for (int i = 0; i < len; i++) { f *= 10; } return {res, f, len}; } tuple<i64, int, int> g(i64 v, i64 m) { auto [u, f, len] = func(v); i64 g = f % m; for (int i = len; i < 1000; i ++) { i64 x = (u * g + v) * 10 + 9; if (i + len >= 12 && x % m == 0) { return {u, i, len}; } g = (g * 10) % m; } return {-1, -1, -1}; } int main() { FAST_IO i64 N; cin >> N; for (int v = 1; v <= 100000; v++) { if (v % 10 == 0) continue; auto [u, i, len] = g(v, N); if (u != -1) { string s = ""; s += to_string(u); for (int j = 0; j < i - len; j++) { s += "0"; } s += to_string(v); s += "9"; cout << s << endl; break; } } }