結果

問題 No.1463 Hungry Kanten
ユーザー abc3abc3
提出日時 2021-04-02 23:23:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,758 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 209,008 KB
実行使用メモリ 19,788 KB
最終ジャッジ日時 2023-08-25 15:05:43
合計ジャッジ時間 3,830 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 7 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 228 ms
19,788 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 22 ms
5,196 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 116 ms
11,716 KB
testcase_20 AC 162 ms
13,348 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    #include <iostream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<int,int>;
    const int INF=1001001001;
    const int mod=1e9+7;
    std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

    int main(){
      int n,k;
      cin>>n>>k;
      vector<ll>a(n);
      rep(i,n){cin>>a[i];}
      set<__int128>st;
      rep(mask,1<<n){
        if(__builtin_popcount(mask)<k){continue;}
        string s="0",s2="1";
        __int128 l=parse(s),r=parse(s2);
        rep(i,n){
          if((mask>>i)&1){
            string t=to_string(a[i]);
            l+=parse(t);
            r*=parse(t);
          }
        }
        st.insert(l);
        st.insert(r);
      }
      cout<<st.size()<<endl;
      return 0;
    }
0