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 <vector>
#include <queue>
#include <cstring>
using namespace std;

typedef unsigned long long ll;

struct Rail {
  int from;
  int to;
  int yen;
  int sunuke;
  ll cost;

  bool operator<(const Rail &e) const {
    return this->cost>e.cost;
  }
};

const int N = 100001;
vector<Rail> adj_list[N];

vector<ll> dijkstra(int start, bool changed) {
  vector<ll> res(N);
  bool visited[N];
  memset(visited, 0, sizeof(visited));

  priority_queue<Rail> q;
  Rail r = { start, start, 0, 0, 0 };
  q.push(r);
  while (!q.empty()) {
    Rail e = q.top();
    q.pop();

    int now_city = e.to;
    ll cost = e.cost;
    if (visited[now_city])
      continue;
    visited[now_city] = true;
    res[now_city] = cost;

    //cout << now_city+1 << ' ' << cost << endl;

    vector<Rail> v = adj_list[now_city];
    for (int i=0; i<v.size(); i++) {
      Rail r = v[i];
      int to = r.to;
        
      r.cost = cost + (changed ? r.sunuke : r.yen);
      q.push(r);
    }
  }

  return res;
}

int main() {
  int n, m, start, to;
  cin >> n >> m >> start >> to;
  start--;
  to--;
  for (int i=0; i<m; i++) {
    int u, v, yen, sunuke;
    cin >> u >> v >> yen >> sunuke;
    u--;
    v--;

    Rail r = { u, v, yen, sunuke, 0 };
    adj_list[u].push_back(r);
    Rail r2 = { v, u, yen, sunuke, 0 };
    adj_list[v].push_back(r2);
  }
  vector<ll> yen_min_path = dijkstra(start, false);
  vector<ll> sunuke_min_path = dijkstra(to, true);

  vector<ll> res;
  ll max = 0;
  for (int i=0; i<n; i++) {
    int j = n-i-1;
    ll use_yen = yen_min_path[j];
    ll use_sunuke = sunuke_min_path[j];
    ll s = 1000000000000000 - use_yen - use_sunuke;
    if (s>max) {
      max = s;
    }
    res.push_back(max);
  }
  for (int i=0; i<n; i++) {
    cout << res[n-i-1] << endl;
  }
  return 0;
}