結果

問題 No.398 ハーフパイプ(2)
ユーザー btkbtk
提出日時 2016-07-15 23:19:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 883 bytes
コンパイル時間 2,458 ms
コンパイル使用メモリ 175,160 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 22:02:49
合計ジャッジ時間 3,310 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
string ans[]={"00","25","50","75"};
string calc(int sum){
    return to_string(sum/4)+"."+ans[sum%4];
}
typedef long long LL;
const LL all=2*3*4*5*6;
int k[]={1,1,2,6,24,120,720};
LL f(vector<int> num){
    LL res=all;
    map<int,int> cnt;
    for(auto&it:num)cnt[it]++;
    for(auto &it:cnt)res/=k[it.second];
    return res;
}
int main(){
    LL res=0;
    string X;cin>>X;
    int sum=0;
    for(;calc(sum)!=X&&sum<=400;sum++);
    if(sum==401){
	cout<<0<<endl;
    }
    else{
	for(int a=0;a<=100;a++)
	    for(int b=a;b<=100;b++)
		for(int c=b;c<=sum-a-b-c;c++) {
		    int d=sum-a-b-c;
		    if(d>100)continue;
		    if(a>0&&d<100)res+=f({0,a,b,c,d,100})*a*(100-d);
		    if(a>0)res+=f({0,a,b,c,d,d})*a;
		    if(d<100)res+=f({a,a,b,c,d,100})*(100-d);
		    res+=f({a,a,b,c,d,d});
		}
    }
	
    cout<<res<<endl;
    return 0;
}
0