結果

問題 No.398 ハーフパイプ(2)
ユーザー どらら
提出日時 2016-07-16 00:31:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 2,646 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 91,292 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 14:36:46
合計ジャッジ時間 1,734 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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