zoukankan      html  css  js  c++  java
  • 【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
    ");
        return 0;
    }

      

  • 相关阅读:
    IDEA去除代码重负导致的波浪黄线
    java代码里出现中文乱码怎么解决
    准备接入个人支付接口?看完这几款支付产品再做决定!
    个人网站选择支付宝api
    PayPay猪 文档中心
    如何让input的值根据select改变
    Visual Studio运行VC++
    腾讯视频转mp4
    重要网址
    ANSYS笔记本
  • 原文地址:https://www.cnblogs.com/flipped/p/5183378.html
Copyright © 2011-2022 走看看