hiho week 98 register

Ended

Participants:433

Verdict:Accepted
Score:100 / 100
Submitted:2016-05-17 17:37:17

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int id[24][4] =
{
    {0, 1, 2, 3}, {0, 1, 3, 2}, {0, 2, 1, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}, {0, 3, 2, 1},
    {1, 0, 2, 3}, {1, 0, 3 ,2}, {1, 2, 0, 3}, {1, 2, 3, 0}, {1, 3, 0, 2}, {1, 3, 2, 0},
    {2, 0, 1, 3}, {2, 0, 3 ,1}, {2, 1, 0, 3}, {2, 1, 3, 0}, {2, 3, 0, 1}, {2, 3, 1, 0},
    {3, 0, 1, 2}, {3, 0, 2, 1}, {3, 1, 0, 2}, {3, 1, 2, 0}, {3, 2, 0, 1}, {3, 2, 1, 0}
};
bool is(double s)
{
    return abs(24 - s) < 0.00001;
}
bool calc1_3(double s1, double s2)
{
    return is(s1 + s2) || is(s1 - s2) || is(s1 * s2) || is(s1 / s2); 
}
bool calc1_2(double s1, double c, double d)
{
    return calc1_3(s1, c + d) ||
    calc1_3(s1, c - d) ||
    calc1_3(s1, c * d) ||
    calc1_3(s1, c / d) ;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX