結果

問題 No.3535 $E\times - Otogibanashi$
コンテスト
ユーザー みつ
提出日時 2026-05-08 22:31:06
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,201 ms / 2,000 ms
コード長 2,380 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,400 ms
コンパイル使用メモリ 346,172 KB
実行使用メモリ 101,888 KB
最終ジャッジ日時 2026-05-08 22:31:24
合計ジャッジ時間 16,738 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define rall(v)v.rbegin(),v.rend()

using ll = long long;
using ull = unsigned long long;
#define iINF 2000000000
#define llINF 9000000000000000000ll
const int MOD9 = 998244353;
const int MOD1 = 1000000000 + 7;
const vector<int> dx = {0,1,0,-1} , dy = {1,0,-1,0};

//chmin , chmax
template<typename T>
bool chmin(T &a , T b){
    if(a > b){a = b ; return 1;}
    return 0;
}
template<typename T>
bool chmax(T &a , T b){
    if(a < b){a = b ; return 1;}
    return 0;
}

//io
template<typename T , typename F>
std::istream& operator>>(std::istream& is , pair<T,F> &p){
    is >> p.first >> p.second;
    return is;
}
template<typename T , typename F>
std::ostream& operator<<(std::ostream& os , const pair<T,F> &p){
    os << " [" << p.first << " : " << p.second << "] ";
    return os;
}

//vio
template<typename T>
void printv(vector<T> &v){
    rep(i,(int)v.size()){
        cout<<v[i];
        if(i+1 != (int)v.size()) cout<<" ";
    }
    cout<<endl;
}
template<typename T>
void printvv(vector<vector<T>> &vv){rep(i,(int)vv.size()) printv(vv[i]);}

template<typename T>
void printve(vector<T> &v){
    rep(i,(int)v.size()){
        cerr<<v[i];
        if(i+1 != (int)v.size()) cerr<<" ";
    }
    cerr<<endl;
}
template<typename T>
void printvve(vector<vector<T>> &vv){rep(i,(int)vv.size()) printve(vv[i]);}

template<typename T>
void vin(vector<T> &v){for(auto &vi : v) cin>>vi;}
template<typename T>
void vvin(vector<vector<T>> &vv){for(auto &vvi : vv) vin(vvi);}



int main(){cin.tie(0);ios::sync_with_stdio(0);
    ll n , p;
    cin >> n >> p;
    vector<int> otogi;
    for(int i=1;i<10;i++) for(int j=0;j<10;j++) for(int k=0;k<10;k++){
        // iijkkj
        int t = 110000 * i + 1001 * j + 110 * k;
        otogi.push_back(t);
    }
    ll ans = 0;
    set<ll> used;
    using P = pair<ll , ll>;
    priority_queue<P , vector<P> , greater<P>> pq;
    for(auto oi : otogi) pq.push(make_pair(oi , oi));
    while(!pq.empty()){
        ll sum , unit;
        tie(sum , unit) = pq.top();pq.pop();
        if(sum > n) continue;
        if(!used.count(sum)){
            used.insert(sum);
            ans -= sum;
            ans %= p;
        }
        pq.push(make_pair(sum + unit , unit));
    }
    ans += p;
    ans %= p;
    cout << ans << endl;
}
0