#include #include #include #include #include #include #include #include template class base_power_class{ public: data_type data[max_idx+1]; constexpr base_power_class() : data() { data[0]=1; for(idx_type i=0; i(); static constexpr digit_type base = base_power[base_size]; static constexpr index_type decimal_size = 0; static constexpr index_type integer_size = 8; static constexpr sign_type sign_pos = false; static constexpr sign_type sign_neg = true; static constexpr int array_size = decimal_size + integer_size; using number_type = std::array; static const my_type PI; static const my_type NAPIER; number_type D; sign_type sign; // O(N) (N=precision) basic_fixed_decimal(){ D.fill(0); sign=sign_pos; } // O(N) (N=precision) basic_fixed_decimal(const std::string& S){ D.fill(0); sign=sign_pos; assert(S.size()!=0); std::size_t beginpos=0; if(S[0]=='-'){ beginpos++; sign=sign_neg; } std::size_t pointpos=S.find('.',beginpos); if(pointpos==std::string::npos) pointpos=S.size(); assert(beginpos=pointpos-beginpos); // 整数部の桁数を超過 for(int i=beginpos; idecimal_size*base_size) continue; // 精度の外をカット digit_type d = S[i]-'0'; index_type digit_idx = decimal_size*base_size+(pointpos-i); D[digit_idx/base_size] += d * base_power[digit_idx%base_size]; } } // O(N) (N=precision) basic_fixed_decimal(double val){ assert(val<2.0*std::pow((double)base,integer_size)); std::string buf; std::ostringstream sstr(buf); sstr<=0; i--){ if(l[i]!=r[i]) return l[i]=base){ overflow=1; d-=base; } dst[i]=d; } return overflow!=0; } // O(N) (N=precision) static bool subtract_unsigned(number_type& dst,const number_type& l,const number_type& r){ digit_type underflow=0; for(index_type i=0; i=base){ underflow=0; d-=base; } dst[i]=d; } return underflow!=0; } // O(N^2) (N=precision) static sign_type multiply_sign(sign_type l,sign_type r){ return (l || r) && !(l && r); // l xor r } // O(N) (N=precision) static bool add_lsb_unsigned(number_type& dst){ for(int i=0; i buf; buf.fill(0); for(int i=0; i=base/2) assert(!add_lsb_unsigned(D)); return *this; } // O(N) (N=precision) my_type operator+(const my_type& r) const { my_type buf=*this; buf+=r; return buf; } // O(N) (N=precision) my_type operator-(const my_type& r) const { my_type buf=*this; buf-=r; return buf; } // O(N^2) (N=precision) my_type operator*(const my_type& r) const { my_type buf=*this; buf*=r; return buf; } // O(N^2) (N=precision) my_type operator/(const my_type& r) const { my_type buf=*this; buf/=r; return buf; } // O(N) (N=precision) bool operator<(const my_type& r) const { if(sign==sign_pos && r.sign==sign_neg) return false; if(sign==sign_neg && r.sign==sign_pos) return true; if(sign==sign_pos) return cmp_unsigned(D,r.D); return cmp_unsigned(r.D,D); } // O(N) (N=precision) bool operator>(const my_type& r) const { return r < *this; } // O(N) (N=precision) bool operator<=(const my_type& r) const { return !(r < *this); } // O(N) (N=precision) bool operator>=(const my_type& r) const { return !(*this < r); } // O(N) (N=precision) bool operator==(const my_type& r) const { if((sign || r.sign) && !(sign && r.sign)) return false; return D == r.D; } // O(N) (N=precision) bool operator!=(const my_type& r) const { return !(*this==r); } // O(N^2 log y) (N=precision) my_type pow(unsigned long long y) const { if(y==0){ my_type res; res.set_digit(0,1); return res; } if(y==1) return *this; my_type res = pow(y/2); res *= res; if(y%2) res *= *this; return res; } // O(N) (N=precision) bool is_zero() const { for(int i=0; i>1); digit_type overflow=0; for(int i=array_size+decimal_size-1; i>=0; i--){ overflow = buf[array_size-1]; for(int j=array_size-1; j>=0; j--) buf[j+1]=buf[j]; if(i>=decimal_size) buf[0]=D[i-decimal_size]; digit_type digit=0; for(digit_type t=msb_base; t; t>>=1){ number_type t_rD; digit_type bufoverflow=digit_multyply_unsigned(t_rD,r.D,t); while((overflow>bufoverflow)?true:(overflow==bufoverflow && !cmp_unsigned(buf,t_rD))){ number_type bufbuf; overflow -= bufoverflow; if(subtract_unsigned(bufbuf,buf,t_rD)) overflow--; buf = bufbuf; digit+=t; } } if(i>=array_size) assert(digit==0); else res.D[i]=digit; } number_type lsbbuf=r.D; half_unsigned(lsbbuf); if(cmp_unsigned(lsbbuf,buf)) assert(!add_lsb_unsigned(res.D)); res.sign = multiply_sign(sign,r.sign); return *this = res; } // O(N) (N=precision) my_type abs() const { return (sign==sign_pos) ? *this : -*this; } // O(N) (N=precision) my_type floor() const { my_type res=*this; bool hit_digit=false; for(int i=0; i basic_fixed_decimal::base_power; std::ostream& operator<<(std::ostream& ostr,const basic_fixed_decimal& a){ return ostr<>(std::istream& istr,basic_fixed_decimal& a){ std::string buf; istr>>buf; if(!istr.good()) return istr; a = basic_fixed_decimal(buf); return istr; } using fixdec=basic_fixed_decimal; #include using namespace std; using ll=long long; using ull=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N,K; fixdec X[18]; set S; int popcount(int x){ int res=0; rep(d,18) res+=(x>>d)&1; return res; } int main(){ cin>>N>>K; rep(i,N) cin>>X[i]; rep(i,1<=K){ fixdec a("0"); rep(d,N) if((i>>d)&1) a+=X[d]; S.insert(a); } rep(i,1<=K){ fixdec a("1"); rep(d,N) if((i>>d)&1) a*=X[d]; S.insert(a); } cout<