专栏首页饶文津的专栏【Gym 100610A】Alien Communication Masterclass

【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;
}

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • DP的优化总结

    饶文津
  • 不同时间复杂度的规模上限

    饶文津
  • 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C

    饶文津
  • 详解Python列表推导式

    列表推导式,也叫列表解析式,英文名称为list comprehension,可以使用非常简洁的方式来快速生成满足特定需求的列表,代码具有非常强的可读性。另外,P...

    Python小屋屋主
  • 不确定性鲁棒:控制屏障功能实现安全的多代理交互(CS RO)

    在现实环境中运行的机器人必须在导航和维护安全性的同时,与许多异构主体和障碍物进行交互。多智能体控制屏障功能(CBF)已经成为一种计算效率高的工具,可以保证多智能...

    时代在召唤
  • Python的循环 博客分类: Python PythonCC++C#

    b里面,x是从a中迭代出来的每一个元素,然后x.get('name')对这个元素进行操作,得到的结果放到list里面,最后循环结束,生成一个列表,则得到的b为...

    chroya
  • 使用S/4HANA里的Smart Business消费通过CDS view暴露的OData服务

    In my previous blog Build Chart and Table representation via Analytics Path Fram...

    Jerry Wang
  • 人群行为分析--Understanding Pedestrian Behaviors from Stationary Crowd Groups

    Understanding Pedestrian Behaviors from Stationary Crowd Groups CVPR2015 本文主要探...

    用户1148525
  • 在 RISC-V 芯片 GD32V 上运行 RT-Thread

    去年九月份的时候 RT-Thread 的 Andy Chen 组织定做了一块 GD32V 开发板,托 Andy 的福,我也搭车买了一块。

    HackforFun
  • ModuleNotFoundError: No module named 'frontend'

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 ...

    周小董

扫码关注云+社区

领取腾讯云代金券