結果

問題 No.398 ハーフパイプ(2)
ユーザー 6v86v8
提出日時 2016-07-16 00:09:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 2,079 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 91,284 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 22:04:22
合計ジャッジ時間 1,733 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 46 ms
4,376 KB
testcase_03 AC 46 ms
4,380 KB
testcase_04 AC 46 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 23 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 11 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 25 ms
4,380 KB
testcase_13 AC 24 ms
4,376 KB
testcase_14 AC 28 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 23 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sstream> //string stream 便利!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // 可変長配列
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // 昇順sortに使う greaterが入ってる。 sortの三番目の引数。
#include <map> //map
#include<set> //set
#include<queue> //キュー
#include<list> //list
#include<cmath>
#include<cassert>
#include <numeric>
#include<tuple>
#include<iomanip>

typedef long long ll;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

using namespace std;
void omajinai() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

long com(int n, int k ){
    long ans  =1;
    for(int i = 1; i<=n;i++) ans*=i;
    for(int i = 1; i<=k;i++) ans/=i;
    for(int i = 1; i<=n-k;i++) ans/=i;
    return ans;
}

map<char,char> m;
long calc(int i, int j, int k , int l , int m , int n){
    vector<int> t({i,j,k,l,m,n});
    vector<int> x;
    int now = i; int nowcount = 1;
    for(int ii = 1; ii<6;ii++){
        if(now == t[ii]) nowcount++; else{ x.push_back(nowcount); nowcount = 1; now = t[ii];}
    }
    x.push_back(nowcount);
    long ans = 1;
    int nn = 6;
    for(int tt: x){
        ans *= com(nn,tt); nn-=tt;
    }
    return ans;
}

long count(int i, int j, int k ,  int l ){
    long count = 0;
    count += calc(i,i,j,k,l,l);
    int left = i;
    int right = 100 - l;
    if(left!=0) count += calc(i-1,i,j,k,l,l) * left;
    if(right == 0) return count;
    count+= calc(i,i,j,k,l,l+1) * right;
    if(left == 0) return count;
    count += calc(i-1,i,j,k,l,l+1) * left * right;
    return count;
}

int main(){
    double x; cin>>x;
    int t = x*4;
    ll ans = 0;
    for(int i = max(0,t-300); i<=t/4;i++){
        t-=i;
        for(int j = max(i,t-200); j<= t/3;j++){
            t-=j;
            for(int k = max(j,t-100); k<=t/2;k++){
                t-=k;
                int u = t;
                if(k<=u) ans+=count(i,j,k,t);
                t+=k;
            }
            t+=j;
        }
        t+=i;
    }
    cout<<ans<<endl;
}
0