提出 #67589383
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../Templates/C++/debug.h"
#else
#define debug(...) 42
#endif
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define lso(s) ((s) & -(s))
int lg(ll s) { return s ? __builtin_clzll(1) - __builtin_clzll(s) : -1; }//lg(1)=0, lg(2)=1, lg(3)=1, lg(4)=2, ...
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
const int MOD = 998244353;
const double EPS = 1e-9;
const char nl = '\n';
const int INF = 1e9;
const ll INFL = 4e18;
ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll floor(ll a, ll b) { return a / b - (a % b < 0); }
ll ceil(ll a, ll b) { return a / b + (a % b > 0); }
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
for(auto &x : vec){
in>>x;
}
return in;
}
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll gen() {
ll x = 0;
while(x == 0)
x = rng() % MOD;
return x;
}
struct mint {
ll x;
mint(ll x=0):x((x%MOD+MOD)%MOD){}
mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
mint operator+(const mint a) const {mint res(*this);return res+=a;}
mint operator-(const mint a) const {mint res(*this);return res-=a;}
mint operator*(const mint a) const {mint res(*this);return res*=a;}
mint pow(ll b) const {
mint res(1), a(*this);
while (b) {
if (b & 1) res *= a;
a *= a;
b >>= 1;
}
return res;
}
// for prime MOD
mint inv() const {return pow(MOD-2);}
mint& operator/=(const mint a) {return (*this) *= a.inv();}
mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}
void solve() {
int A; cin >> A;
ll N; cin >> N;
ll ans = 0;
auto tes = [&](string s) {
if(sz(s) == 0 || s[0] == '0') return false;
ll val = 0; for(char c : s) val = val * 10 + c - '0';
if(val > N) return false;
ll vv = val;
vi vec;
while(val) {
vec.pb(val % A);
val /= A;
}
for(int i = 0; i < sz(vec); i++) {
if(vec[i] != vec[sz(vec) - i - 1]) return false;
}
debug(s);
ans += vv;
return true;
};
auto rec = [&](auto&& rec, string s) {
if(sz(s) > 12) return;
tes(s);
for(char c = '0'; c <= '9'; c++) {
string st = string(1, c) + s + string(1, c);
rec(rec, st);
}
};
rec(rec, "");
for(char c = '0'; c <= '9'; c++) {
rec(rec, string(1, c));
}
cout << ans << nl;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin.exceptions(cin.failbit);
int T = 1;
// cin >> T;
while(T--) {
solve();
}
return 0;
}
提出情報
コンパイルエラー
Main.cpp: In lambda function:
Main.cpp:7:20: warning: statement has no effect [-Wunused-value]
7 | #define debug(...) 42
| ^~
Main.cpp:124:9: note: in expansion of macro ‘debug’
124 | debug(s);
| ^~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
350 / 350 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All |
00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00-sample-01.txt |
AC |
525 ms |
3448 KiB |
| 00-sample-02.txt |
AC |
760 ms |
3320 KiB |
| 00-sample-03.txt |
AC |
786 ms |
3436 KiB |
| 01-01.txt |
AC |
516 ms |
3472 KiB |
| 01-02.txt |
AC |
525 ms |
3456 KiB |
| 01-03.txt |
AC |
1131 ms |
3380 KiB |
| 01-04.txt |
AC |
860 ms |
3516 KiB |
| 01-05.txt |
AC |
761 ms |
3524 KiB |
| 01-06.txt |
AC |
813 ms |
3324 KiB |
| 01-07.txt |
AC |
765 ms |
3472 KiB |
| 01-08.txt |
AC |
762 ms |
3468 KiB |
| 01-09.txt |
AC |
918 ms |
3548 KiB |
| 01-10.txt |
AC |
787 ms |
3448 KiB |
| 01-11.txt |
AC |
516 ms |
3456 KiB |
| 01-12.txt |
AC |
538 ms |
3548 KiB |
| 01-13.txt |
AC |
524 ms |
3464 KiB |
| 01-14.txt |
AC |
529 ms |
3472 KiB |
| 01-15.txt |
AC |
518 ms |
3468 KiB |
| 01-16.txt |
AC |
517 ms |
3324 KiB |
| 01-17.txt |
AC |
523 ms |
3512 KiB |
| 01-18.txt |
AC |
524 ms |
3456 KiB |
| 01-19.txt |
AC |
898 ms |
3476 KiB |
| 01-20.txt |
AC |
525 ms |
3468 KiB |
| 01-21.txt |
AC |
518 ms |
3472 KiB |
| 01-22.txt |
AC |
518 ms |
3344 KiB |
| 01-23.txt |
AC |
526 ms |
3476 KiB |
| 01-24.txt |
AC |
526 ms |
3460 KiB |
| 01-25.txt |
AC |
527 ms |
3516 KiB |
| 01-26.txt |
AC |
516 ms |
3468 KiB |
| 01-27.txt |
AC |
538 ms |
3472 KiB |
| 01-28.txt |
AC |
516 ms |
3456 KiB |
| 01-29.txt |
AC |
522 ms |
3472 KiB |
| 01-30.txt |
AC |
526 ms |
3480 KiB |