結果

問題 No.398 ハーフパイプ(2)
ユーザー どららどらら
提出日時 2016-07-16 00:31:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 2,646 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 85,940 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 22:05:51
合計ジャッジ時間 1,946 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int X = 0;
  rep(i,s.length()){
    if(s[i] != '.'){
      X = X*10 + (s[i]-'0');
    }
  }

  ll ret = 0;
  rep(a,101){
    REP(b,a,101){
      REP(c,b,101){
        REP(d,c,101){
          if((a+b+c+d)*100/4 == X){
            int mn = 100, mx = 0;
            mn = min(mn, a);
            mn = min(mn, b);
            mn = min(mn, c);
            mn = min(mn, d);
            mx = max(mx, a);
            mx = max(mx, b);
            mx = max(mx, c);
            mx = max(mx, d);

            {
              map<int,int> memo;
              memo[a]++;
              memo[b]++;
              memo[c]++;
              memo[d]++;
              ll w = 1;
              FOR(it,memo){
                REP(i,1,it->second+1) w *= i;
              }
              ll p = (mn-1 -0+1) * (ll)(100-(mx+1)+1);
              ret += (720/w) * p;
            }
            {
              map<int,int> memo;
              memo[mn]++;
              memo[a]++;
              memo[b]++;
              memo[c]++;
              memo[d]++;
              ll w = 1;
              FOR(it,memo){
                REP(i,1,it->second+1) w *= i;
              }
              ll p = (100-(mx+1)+1);
              ret += (720/w) * p;
            }              
            {
              map<int,int> memo;
              memo[a]++;
              memo[b]++;
              memo[c]++;
              memo[d]++;
              memo[mx]++;
              ll w = 1;
              FOR(it,memo){
                REP(i,1,it->second+1) w *= i;
              }
              ll p = (mn-1 -0+1);
              ret += (720/w) * p;
            }              
            {
              map<int,int> memo;
              memo[mn]++;
              memo[a]++;
              memo[b]++;
              memo[c]++;
              memo[d]++;
              memo[mx]++;
              ll w = 1;
              FOR(it,memo){
                REP(i,1,it->second+1) w *= i;
              }
              ret += (720/w);
            }              
          }
        }
      }
    }
  }
  cout << ret << endl;
  return 0;
}

0