Codeforces Gym 100610 problem A. Alien Communication Masterclass Construction

Source: Internet
Author: User
Tags integer numbers

Problem A. Alien Communication Masterclass

Time Limit:1 Sec

Memory limit:256 MB

Topic Connection http://codeforces.com/gym/100610
Description

Andrea is a famous science fiction writer, who runs masterclasses for her beloved readers. The most popular one are the Alien Communication Masterclass (ACM), where she teaches how to behave if you encounter Alien Life forms or at least alien artifacts. One of the lectures concerns retrieving useful information based on aliens ' writings. Andrea teaches that based in alien mathematical formulas, one could derive the base of the numeral system used by the Alie NS, which in turn might give some knowledge about aliens ' organisms. (For example, we use numeral system with base, due to the fact, we have a ten fingers on our upper extremities). Suppose for simplicity so aliens use the same digits as we do, and they understand and denote addition, subtraction, mul Tiplication, parentheses and equality the same as we do. For she lecture, Andrea wants an example of a mathematical equality this holds in numeral systems with bases A1, a2, · , an, but doesn ' t-hold in numeral systems with Bases B1, b2, , BM. Provide her with one such formula.

Input

The first line of the input file contains the integer numbers, N and M (1≤n, m≤8). The second line contains n numbers, A1, a2, , an. The third line contains m numbers, B1, b2, Bm. All AI and bi is distinct and lie between 2 and, inclusive.

Output

Output any syntactically correct mathematical equality this holds in numeral systems with bases A1, a2, , an, but doesn ' t-hold in numeral systems with bases B1, b2, Bm. The equality can contain only digits 0 through 9, addition (' + '), subtraction and unary negation ('-'), multiplication (' * '), parentheses (' (' and ') ') and equality sign (' = '). There must is exactly one equality sign in the output. Any whitespace characters in the output file is ignored. The number of Non-whitespace characters in the output file must is not exceed 10 000.

Sample Input

1 2 2) 3 9

Sample Output

(10-1) * (10-1) + 1 = 10

HINT

Test instructions

Requires you to output an equation that satisfies the N-type, but does not satisfy any M-type-binary

Exercises

Direct output (10-a1*1) * (10-a2*1) *......* (10-an*1) =0 just fine.

The condition can only be satisfied in N-type binary

Code:

//Qscqesze#include <cstdio>#include<cmath>#include<cstring>#include<ctime>#include<iostream>#include<algorithm>#include<Set>#include<bitset>#include<vector>#include<sstream>#include<queue>#include<typeinfo>#include<fstream>#include<map>#include<stack>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineMAXN 110000#defineMoD 1001#defineEPS 1e-9#definePi 3.1415926intNum;//const int INF=0X7FFFFFFF; //§ß§é§à§é¨f§³Constll inf=999999999; inline ll read () {ll x=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//*************************************************************************************//( k-a1) (K-A2) (K-A3) *.....* (K-an)inta[ One];intb[ One];intMain () {Freopen ("acm.in","R", stdin); Freopen ("Acm.out","W", stdout); intN=read (), m=read ();  for(intI=0; i<n;i++) Cin>>A[i];  for(intI=0; i<m;i++) Cin>>B[i];  for(intI=0; i<n;i++) {cout<<"(10-";  for(intj=1; j<=a[i];j++)        {            if(j!=A[i]) cout<<"1-"; Elsecout<<"1"; }        if(i!=n-1) cout<<")*"; Elsecout<<")"; } cout<<"=0";}

Codeforces Gym 100610 problem A. Alien Communication Masterclass Construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.