Problem:
Score : 100 points

Problem Statement

You are given two integers a and b.
Determine if a+b=15 or a\times b=15 or neither holds.

Note that a+b=15 and a\times b=15 do not hold at the same time.

Constraints

1 \leq a,b \leq 15

All values in input are integers.

Input

Input is given from Standard Input in the following format:

a b

Output

If a+b=15, print +;
if a\times b=15, print *;
if neither holds, print x.

Sample Input 1

4 11

Sample Output 1

+

4+11=15.

Sample Input 2

3 5

Sample Output 2

*

3\times 5=15.

Sample Input 3

1 1

Sample Output 3

x

1+1=2 and 1\times 1=1, neither of which is 15.

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
#define mp make_pair
 
const int N = (int)1e6 + 5;
int n, m;
vector<pil> g[N];
ll a[N][2];
bool used[N];
 
void dfs(int v) {
//	cerr << "dfs " << v << endl;
	used[v] = 1;
	for (pil e : g[v]) {
		int u = e.first;
		if (used[u]) continue;
		a[u][0] = -a[v][0];
		a[u][1] = e.second - a[v][1];
		dfs(u);
	}
}
 
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 
	scanf("%d%d", &n, &m);
	while(m--) {
		int v, u;
		ll w;
		scanf("%d%d%lld", &v, &u, &w);
		v--;u--;
		g[v].push_back(mp(u, w));
		g[u].push_back(mp(v, w));
	}
	a[0][0] = 1;
	dfs(0);
 
	ll L = (ll)1;
	ll R = (ll)1e10;
	ll F = -1;
 
	for (int v = 0; v < n; v++) {
		//cerr << "for " << v << endl;
		if (a[v][0] == 1) {
			L = max(L, 1 - a[v][1]);
		} else {
			R = min(R, a[v][1] - 1);
		}
		for (pil e : g[v]) {
			int u = e.first;
			ll x = a[v][0] + a[u][0];
			ll y = a[v][1] + a[u][1];
			if (x == 0) {
				if (y != e.second) {
					printf("0\n");
					return 0;
				}
			} else {
				ll z = e.second - y;
				if (z % 2 != 0) {
					printf("0\n");
					return 0;
				}
				z /= x;
				if (z <= 0) {
					printf("0\n");
					return 0;
				}
				if (F == -1) F = z;
				if (F != z) {
					printf("0\n");
					return 0;
				}
			}
		}
	}
 
	if (F == -1)
		printf("%lld\n", max(0LL, R - L + 1));
	else {
		if (L <= F && F <= R)
			printf("1\n");
		else
			printf("0\n");
	}
 
	return 0;
}