結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー FplusFplusFFplusFplusF
提出日時 2024-04-05 16:57:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,379 bytes
コンパイル時間 10,098 ms
コンパイル使用メモリ 427,400 KB
実行使用メモリ 19,040 KB
最終ジャッジ日時 2024-04-05 16:58:02
合計ジャッジ時間 15,435 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 545 ms
6,548 KB
testcase_03 AC 103 ms
6,548 KB
testcase_04 AC 4 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 6 ms
6,548 KB
testcase_08 AC 22 ms
6,548 KB
testcase_09 AC 178 ms
6,548 KB
testcase_10 AC 145 ms
6,548 KB
testcase_11 AC 79 ms
6,548 KB
testcase_12 AC 92 ms
6,548 KB
testcase_13 AC 19 ms
6,548 KB
testcase_14 AC 181 ms
6,548 KB
testcase_15 AC 18 ms
6,548 KB
testcase_16 AC 5 ms
6,548 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    const ll mod=998244353;
    ll n;
    cin >> n;
    vector<string> a(n);
    rep(i,n) cin >> a[i];
    if(n<=10){
        sort(all(a));
        string s;
        boost::multiprecision::cpp_int mn(string(200,'9'));
        do{
            string now;
            for(auto i:a) now+=i;
            reverse(all(now));
            boost::multiprecision::cpp_int x=0,r=1;
            for(auto i:now){
                x+=(i-'0')*r;
                r*=10;
            }
            if(chmin(mn,x)) s=now;
            
        }while(next_permutation(all(a)));
        ll ans=0,r=1;
        for(auto i:s){
            ans+=(i-'0')*r%mod;
            ans%=mod;
            r*=10;
            r%=mod;
        }
        cout << ans << '\n';
        return 0;
    }else{
        assert(0);
    }
}
0