Submission #169315


Source Code Expand

Copy
#include <iostream>
#include <iomanip>  // setw
#include <algorithm> // sort next_permutation count __gcd reverse etc.
#include <set>
#include <list>
#include <map>
#include <memory>
#include <numeric> // accumulate
#include <functional>
#include <utility>
#include <iterator>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <fstream> // freopen
#include <cstdio> // scanf printf
#include <cstdlib> // abs exit atof atoi
#include <string> // memset
#include <cstring>
#include <cmath> // fabs
#include <cctype> // tolower toupper
#include <sstream> // stringstream
#include <bitset>

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rer(i,n) for(int i=1; i<=n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreb(i,n,b) for(int i = n; i >= b; i--)
#define resz(i,v) rep(i,sz(v))
#define let(v, x) __typeof(x) v = (x)
#define each(it,v) for(let(it, (v).begin()); it!=(v).end(); it++)
#define reach(it,v) for(let(it, (v).rbegin());i!=(v).rend();i++)
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES

using std::stringstream;
using namespace std;

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
/* --------------------------------------------------------------- */

int factorial(int n)
{
    if (n > 2) n *= factorial(n - 1);
    return n;
}

int main(int argc, char *argv[])
{
//    ios::sync_with_stdio(false);
//    cin.tie(0); // off the synchronous of cin and cout
    int n;
    cin >> n;

    vector<pair<int, bool> > num;
    rep(i, n) {
        int t;
        cin >> t;
        num.pb(mp(t, true));
    }
    double omote=0;
    do{
        rep(i, n) {
            reb(j, i+1, n) {
                if (num[j].fi % num[i].fi == 0) {
                    if (num[j].se) num[j].se = false;
                    else num[j].se = true;
                }
            }
        }
        rep(i, n) {
            if (num[i].se) omote++;
        }
    } while(next_permutation(vall(num)));



    cout << fixed << setprecision(12);
    cout << omote / (double)factorial(n) << endl;

    return 0;
}

Submission Info

Submission Time
Task C - コイン
User emacs
Language C++ (G++ 4.6.4)
Score 0
Code Size 3612 Byte
Status WA
Exec Time 2033 ms
Memory 1004 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 0 / 99 0 / 1
Status
AC × 1
WA × 2
AC × 2
WA × 18
AC × 2
WA × 20
TLE × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt
Case Name Status Exec Time Memory
sample_01.txt AC 24 ms 812 KB
sample_02.txt WA 23 ms 916 KB
sample_03.txt WA 23 ms 916 KB
subtask1_01.txt AC 22 ms 796 KB
subtask1_02.txt WA 21 ms 924 KB
subtask1_03.txt WA 21 ms 920 KB
subtask1_04.txt WA 33 ms 872 KB
subtask1_05.txt WA 33 ms 876 KB
subtask1_06.txt WA 23 ms 924 KB
subtask1_07.txt AC 29 ms 920 KB
subtask1_08.txt WA 21 ms 916 KB
subtask1_09.txt WA 22 ms 920 KB
subtask1_10.txt WA 34 ms 860 KB
subtask1_11.txt WA 23 ms 860 KB
subtask1_12.txt WA 29 ms 876 KB
subtask1_13.txt WA 21 ms 924 KB
subtask1_14.txt WA 22 ms 920 KB
subtask1_15.txt WA 27 ms 880 KB
subtask1_16.txt WA 22 ms 916 KB
subtask1_17.txt WA 23 ms 916 KB
subtask1_18.txt WA 26 ms 800 KB
subtask1_19.txt WA 30 ms 920 KB
subtask1_20.txt WA 31 ms 812 KB
subtask2_01.txt WA 1250 ms 880 KB
subtask2_02.txt WA 23 ms 920 KB
subtask2_03.txt TLE 2031 ms 876 KB
subtask2_04.txt TLE 2031 ms 1000 KB
subtask2_05.txt TLE 2031 ms 1000 KB
subtask2_06.txt TLE 2031 ms 876 KB
subtask2_07.txt TLE 2032 ms 876 KB
subtask2_08.txt TLE 2032 ms 876 KB
subtask2_09.txt TLE 2030 ms 876 KB
subtask2_10.txt TLE 2032 ms 988 KB
subtask2_11.txt TLE 2031 ms 876 KB
subtask2_12.txt TLE 2032 ms 876 KB
subtask2_13.txt TLE 2030 ms 872 KB
subtask2_14.txt TLE 2031 ms 880 KB
subtask2_15.txt TLE 2031 ms 996 KB
subtask2_16.txt TLE 2032 ms 880 KB
subtask2_17.txt TLE 2032 ms 864 KB
subtask2_18.txt TLE 2033 ms 888 KB
subtask2_19.txt TLE 2032 ms 1004 KB
subtask2_20.txt TLE 2032 ms 876 KB