結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
![]() |
提出日時 | 2021-01-26 12:31:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,344 bytes |
コンパイル時間 | 2,205 ms |
コンパイル使用メモリ | 199,468 KB |
最終ジャッジ日時 | 2025-01-18 08:22:19 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 WA * 61 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct uns_t {} uns; template <typename Element, typename Head, typename ...Args> auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template <typename Element, typename Head, typename ...Args> auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } int main() { constexpr int64_t base = 1000000001; int64_t n; cin >> n; map<int, bool> used; auto btoi = [](int bits) { int ans = 0; while (bits) { ans *= 10; ans += bits & 1; bits >>= 1; } return ans; }; int ans = 0; for (int i = 1; i < (1 << 9); ++i) { auto unit = btoi(i); if (used[unit]) continue; used[unit] = true; bool found = false; auto s = to_string(unit); auto beg1 = begin(s); auto beg2 = end(s) - 1; while (begin(s) != beg2 && end(s) != beg1) { if (*beg1 != *beg2) { found = true; } ++beg1; --beg2; } if (found) continue; for (int j = 1; j <= 9; ++j) { ans += base * j * unit <= n; } } cout << ans << endl; }