找回密码
 注册
关于网站域名变更的通知
查看: 423|回复: 1
打印 上一主题 下一主题

Balance

[复制链接]
  • TA的每日心情

    2019-11-19 15:32
  • 签到天数: 1 天

    [LV.1]初来乍到

    跳转到指定楼层
    1#
    发表于 2019-7-1 16:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

    EDA365欢迎您登录!

    您需要 登录 才可以下载或查看,没有帐号?注册

    x

    Description

    Gigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance.
    ' U. w% x1 l6 w6 hIt orders two ARMs of negligible weight and each arm's length is 15. Some hooks are attached to these arms and Gigel wants to hang up some weights from his collection of G weights (1 <= G <= 20) knowing that these weights have distinct values in the range 1..25. Gigel may droop any weight of any hook but he is forced to use all the weights. # C' ^# {/ O7 Z0 c; `
    Finally, Gigel managed to balance the device using the experience he gained at the National Olympiad in Informatics. Now he would like to know in how many ways the device can be balanced.

    Knowing the repartition of the hooks and the set of the weights write a program that calculates the number of possibilities to balance the device. * w1 D6 ?; ]3 m0 C9 {( D
    It is guaranteed that will exist at least one solution for each test case at the evaluation. 0 L1 R+ l8 L2 [( K
    Input

    The input has the following structure: 0 |( F3 J) H3 Z. F) f  S5 d
    • the first line contains the number C (2 <= C <= 20) and the number G (2 <= G <= 20);
    , i- }0 r# B: A6 Y• the next line contains C integer numbers (these numbers are also distinct and sorted in ascending order) in the range -15..15 representing the repartition of the hooks; each number represents the position relative to the center of the balance on the X axis (when no weights are attached the device is balanced and lined up to the X axis; the absolute value of the distances represents the distance between the hook and the balance center and the sign of the numbers determines the arm of the balance to which the hook is attached: '-' for the left arm and '+' for the right arm); ! X# c: _% `+ j9 I
    • on the next line there are G natural, distinct and sorted in ascending order numbers in the range 1..25 representing the weights' values. 5 y5 B1 S, Y$ z, W
    Output

    The output contains the number M representing the number of possibilities to poise the balance.  r2 Y9 G* T, i9 q* c# e2 U
    Sample Input

    2 4
    5 T9 x( \$ o8 t/ o1 o-2 3
    $ f  U: L& @9 j3 4 5 89 a2 z/ b: @' a$ \
    Sample Output

    2

    8 m5 @% \3 g1 k* F) W5 ^

    该用户从未签到

    2#
    发表于 2019-7-1 18:22 | 只看该作者
    学习一下 英语,哈哈哈
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-11-25 00:45 , Processed in 0.156250 second(s), 23 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表