Submission #14849571


Source Code Expand

Copy
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;
#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

#define MAX 307
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void fact() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; ++i){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    fact();
    ll N;
    cin >> N;
    vector<ld> F(101,0);
    F[1]=0.0;
    for(ll i=2;i<=100;++i){
        ld same=3;
        ld sum=0;
        if(N%3==0)same+=comb(N,N/3)*comb(2*N/3,N/3);
        //三種
        for(ll j=0;j<=i;++j){
            for(ll k=0;k<=i-j;++k){
                ll l=i-j-k;
                if(j==i||k==i||l==i)continue;
                if(l==j&&j==k)continue;
                ll count=comb(i,j)*comb(i-j,k);
                ll Min=min({j,k,l});
                sum+=(ld)count*(F[Min]+(ld)1.0);
            }
        }
        F[i]=((ld)sum+(ld)same)/(powl((ld)3.0,(ld)N)-(ld)same);
    }
    cout << fixed << setprecision(20);
    prt(F[N]);
    debug(F);

    return 0;
}

Submission Info

Submission Time
Task C - ゲーマーじゃんけん
User kazumaokawa
Language C++ (GCC 9.2.1)
Score 0
Code Size 3343 Byte
Status
Exec Time 11 ms
Memory 3892 KB

Compile Error

./Main.cpp: In instantiation of ‘void prt(std::vector<_Tp>) [with T = long double]’:
./Main.cpp:86:5:   required from here
./Main.cpp:27:52: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<long double>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   27 | inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
./Main.cpp:27:82: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<long double>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   27 | inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
      |                                                                                 ~^~~~~~~~~~~

Judge Result

Set Name Score / Max Score Test Cases
All 0 / 100 input-002.txt, input-003.txt, input-004.txt, input-005.txt, input-006.txt, input-007.txt, input-008.txt, input-009.txt, input-010.txt, input-011.txt, input-012.txt, input-013.txt, input-014.txt, input-015.txt, input-016.txt, input-017.txt, input-018.txt, input-019.txt, input-020.txt, input-021.txt, input-022.txt, input-023.txt, input-024.txt, input-025.txt, input-026.txt, input-027.txt, input-028.txt, input-029.txt, input-030.txt, input-031.txt, input-032.txt, input-033.txt, input-034.txt, input-035.txt, input-036.txt, input-037.txt, input-038.txt, input-039.txt, input-040.txt, input-041.txt, input-042.txt, input-043.txt, input-044.txt, input-045.txt, input-046.txt, input-047.txt, input-048.txt, input-049.txt, input-050.txt, input-051.txt, input-052.txt, input-053.txt, input-054.txt, input-055.txt, input-056.txt, input-057.txt, input-058.txt, input-059.txt, input-060.txt, input-061.txt, input-062.txt, input-063.txt, input-064.txt, input-065.txt, input-066.txt, input-067.txt, input-068.txt, input-069.txt, input-070.txt, input-071.txt, input-072.txt, input-073.txt, input-074.txt, input-075.txt, input-076.txt, input-077.txt, input-078.txt, input-079.txt, input-080.txt, input-081.txt, input-082.txt, input-083.txt, input-084.txt, input-085.txt, input-086.txt, input-087.txt, input-088.txt, input-089.txt, input-090.txt, input-091.txt, input-092.txt, input-093.txt, input-094.txt, input-095.txt, input-096.txt, input-097.txt, input-098.txt, input-099.txt, input-100.txt
Case Name Status Exec Time Memory
input-002.txt 10 ms 3824 KB
input-003.txt 8 ms 3892 KB
input-004.txt 7 ms 3828 KB
input-005.txt 6 ms 3752 KB
input-006.txt 5 ms 3660 KB
input-007.txt 6 ms 3804 KB
input-008.txt 7 ms 3756 KB
input-009.txt 6 ms 3808 KB
input-010.txt 5 ms 3656 KB
input-011.txt 5 ms 3736 KB
input-012.txt 3 ms 3788 KB
input-013.txt 7 ms 3776 KB
input-014.txt 6 ms 3756 KB
input-015.txt 4 ms 3824 KB
input-016.txt 5 ms 3888 KB
input-017.txt 5 ms 3888 KB
input-018.txt 8 ms 3716 KB
input-019.txt 6 ms 3752 KB
input-020.txt 5 ms 3808 KB
input-021.txt 5 ms 3732 KB
input-022.txt 5 ms 3808 KB
input-023.txt 5 ms 3820 KB
input-024.txt 5 ms 3720 KB
input-025.txt 5 ms 3812 KB
input-026.txt 5 ms 3824 KB
input-027.txt 9 ms 3748 KB
input-028.txt 5 ms 3804 KB
input-029.txt 7 ms 3812 KB
input-030.txt 5 ms 3804 KB
input-031.txt 4 ms 3740 KB
input-032.txt 6 ms 3756 KB
input-033.txt 6 ms 3660 KB
input-034.txt 5 ms 3812 KB
input-035.txt 8 ms 3776 KB
input-036.txt 5 ms 3732 KB
input-037.txt 6 ms 3892 KB
input-038.txt 6 ms 3824 KB
input-039.txt 7 ms 3732 KB
input-040.txt 5 ms 3656 KB
input-041.txt 9 ms 3752 KB
input-042.txt 5 ms 3720 KB
input-043.txt 5 ms 3744 KB
input-044.txt 5 ms 3808 KB
input-045.txt 7 ms 3752 KB
input-046.txt 5 ms 3788 KB
input-047.txt 6 ms 3744 KB
input-048.txt 6 ms 3824 KB
input-049.txt 7 ms 3716 KB
input-050.txt 5 ms 3784 KB
input-051.txt 8 ms 3820 KB
input-052.txt 6 ms 3656 KB
input-053.txt 7 ms 3752 KB
input-054.txt 5 ms 3660 KB
input-055.txt 6 ms 3788 KB
input-056.txt 9 ms 3660 KB
input-057.txt 6 ms 3732 KB
input-058.txt 3 ms 3808 KB
input-059.txt 6 ms 3756 KB
input-060.txt 5 ms 3784 KB
input-061.txt 5 ms 3740 KB
input-062.txt 8 ms 3752 KB
input-063.txt 9 ms 3748 KB
input-064.txt 6 ms 3744 KB
input-065.txt 8 ms 3756 KB
input-066.txt 5 ms 3804 KB
input-067.txt 6 ms 3732 KB
input-068.txt 6 ms 3668 KB
input-069.txt 3 ms 3812 KB
input-070.txt 10 ms 3744 KB
input-071.txt 7 ms 3824 KB
input-072.txt 6 ms 3716 KB
input-073.txt 6 ms 3824 KB
input-074.txt 6 ms 3752 KB
input-075.txt 5 ms 3740 KB
input-076.txt 6 ms 3888 KB
input-077.txt 6 ms 3824 KB
input-078.txt 7 ms 3804 KB
input-079.txt 5 ms 3812 KB
input-080.txt 7 ms 3752 KB
input-081.txt 11 ms 3772 KB
input-082.txt 5 ms 3656 KB
input-083.txt 6 ms 3808 KB
input-084.txt 6 ms 3776 KB
input-085.txt 6 ms 3776 KB
input-086.txt 5 ms 3756 KB
input-087.txt 4 ms 3820 KB
input-088.txt 10 ms 3824 KB
input-089.txt 7 ms 3752 KB
input-090.txt 5 ms 3820 KB
input-091.txt 8 ms 3740 KB
input-092.txt 5 ms 3784 KB
input-093.txt 8 ms 3820 KB
input-094.txt 6 ms 3740 KB
input-095.txt 5 ms 3820 KB
input-096.txt 7 ms 3888 KB
input-097.txt 5 ms 3824 KB
input-098.txt 5 ms 3748 KB
input-099.txt 5 ms 3752 KB
input-100.txt 8 ms 3892 KB