【Gym 100610A】Alien Communication Masterclass

Andrea is a famous science fiction writer, who runs masterclasses for her beloved readers. The most popular one is 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 on alien mathematical formulas, one could derive the base of the numeral system used by the aliens, which in turn might give some knowledge about aliens’ organisms. (For example, we use numeral system with base 10, due to the fact that we have ten fingers on our upper extremities).

Suppose for simplicity that aliens use the same digits as we do, and they understand and denote addition, subtraction, multiplication, parentheses and equality the same way as we do.

For her lecture, Andrea wants an example of a mathematical equality that 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 two 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 are distinct and lie between 2 and 10, inclusive.

Output

Output any syntactically correct mathematical equality that 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 be exactly one equality sign in the output. Any whitespace characters in the output file will be ignored. The number of non-whitespace characters in the output file must not exceed 10 000.

Examples

  


acm.in

acm.out

1 2    

2

3 9

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

2 2     

9 10

2 3

2 + 2 = 4

  

题意:给出a个数和b个数,求一个满足a1,a2,...进制不满足b1,b2,...进制的式子

分析:(a1-1-1-1-....)*(a2-1-1-...)...(an-1-1-...)=0即可满足条件,这题难就难在想的到不到这种式子了。

#include<stdio.h>
int n,m,a[9],b;
int main(){
   freopen("acm.in","r",stdin);
   freopen("acm.out","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<m;i++)
        scanf("%d",&b);
    for(int i=0;i<n;i++){
        printf("(10");
        for(int j=0;j<a[i];j++)
            printf("-1");
        printf(")");
        if(i<n-1) printf("*");
    }
    printf("=0\n");
    return 0;
}

  

时间: 2024-10-12 15:29:51

【Gym 100610A】Alien Communication Masterclass的相关文章

Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造

Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Andrea is a famous science fiction writer, who runs masterclasses for her beloved readers. The most popular one is the

【Gym 100015B】Ball Painting

题 There are 2N white balls on a table in two rows, making a nice 2-by-N rectangle. Jon has a big paint bucketfull of black paint. (Don’t ask why.) He wants to paint all the balls black, but he would like to have somemath fun while doing it. (Again, d

【Gym 100947C】Rotate It !!

分两类,奇数和偶数的,用隔项前缀和算一下. #include <algorithm> #include <iostream> #define N 10005 using namespace std; long long a,t,n,s[N],ans; int main(){ cin>>t; while(t--){ cin>>n>>s[1]; for(int i=2;i<=n;i++){ cin>>a; s[i]=a+s[i-2]

【Gym 100712B】Rock-Paper-Scissors

题 题意 对给定的对手的出拳顺序,如果只能按几个R,然后几个P,再几个S的顺序出拳(几个也可以是0个),那么求赢的方法有多少种. 分析 我原来想枚举P开始的位置和S开始的位置然后算得分,但是超时了o(╯□╰)o..因为时间复杂度T(n^3)最大规模是500,而这里n≤1000. 用前缀和思想,s[i][0到2]储存前i个里有几个R.S.P,然后再枚举P.S开始位置为i.j: 0到i-1是R的时候,对方是S,我得分,可以得到s[i-1][1]分,对方是P,我失分,失去s[i-1][2]分,同理最后

【Gym 100015A】Another Rock-Paper-Scissors Problem

题 题意 Sonny出石头剪刀布的猜拳策略是 先出R,然后每连续两段都是打败前一段的出拳, 现在问你第n回合打败他要出什么. 分析 他的策略 R P S PSR  SRP PSRSRPRPS SRPRPSPSR … … 打败他的策略是 P S R SRP  RPS SRPRPSPSR RPRPSRSRP … … 一套策略 1 1 1 3 3 9 9  … … 第几轮 1 2 3 4-6  7-9  10-18 19-27 … … 如果n是介于3的某个次方的(1,2]倍,那就是n要打败 n减去这个

【Gym 100733D】Little thief Shi

题 Shi realized that he was almost out of money, even renting Shitalian lands. Shi was walking on a street, while thinking of a way to recover his fortune. In his way, he passed by a jewelry store. The owner of the store was a Shitalian man suspected

【Gym 100971K】Palindromization

Mihahim has a string s. He wants to delete exactly one character from it so that the resulting string would be a palindrome. Determine if he can do it, and if he can, what character should be deleted. Input The input contains a string s of length (2 

【Gym - 100923A】Por Costel and Azerah(思维水题)

Por Costel and Azerah Descriptions 给你n个数 问你,有多少个子序列 的和是偶数 Example Input 233 10 124 2 Output 33 题目链接 https://vjudge.net/problem/Gym-100923A 恶心死了   freopen("azerah.in","r",stdin); freopen("azerah.out","w",stdout); 必须加

【DFS】【拓扑排序】【动态规划】Gym - 100642A - Babs&#39; Box Boutique

给你10个箱子,有长宽高,每个箱子你可以决定哪个面朝上摆.把它们摞在一起,边必须平行,上面的不能突出来,问你最多摆几个箱子. 3^10枚举箱子用哪个面.然后按长为第一关键字,宽为第二关键字,从大到小排序. 如果前面的宽大于等于后面的宽,就连接一条边. 形成一张DAG,拓扑排序后跑最长路即可. #include<cstdio> #include<cstring> #include<queue> #include<algorithm> using namespa