CF389A Fox and Number Game

    • 103通过
    • 150提交
  • 题目来源 CodeForces 389A
  • 评测方式 RemoteJudge
  • 标签
  • 难度 省选/NOI-
  • 时空限制 1000ms / 256MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    给定n(2≤n≤100)个数,求这n个数的最大公约数乘n

    题目描述

    Fox Ciel is playing a game with numbers now.

    Ciel has $ n $ positive integers: $ x_{1} $ , $ x_{2} $ , ..., $ x_{n} $ . She can do the following operation as many times as needed: select two different indexes $ i $ and $ j $ such that $ x_{i} $ > $ x_{j} $ hold, and then apply assignment $ x_{i} $ = $ x_{i} $ - $ x_{j} $ . The goal is to make the sum of all numbers as small as possible.

    Please help Ciel to find this minimal sum.

    输入输出格式

    输入格式:

    The first line contains an integer $ n $ ( $ 2<=n<=100 $ ). Then the second line contains $ n $ integers: $ x_{1} $ , $ x_{2} $ , ..., $ x_{n} $ ( $ 1<=x_{i}<=100 $ ).

    输出格式:

    Output a single integer — the required minimal sum.

    输入输出样例

    输入样例#1: 复制
    2
    1 2
    
    输出样例#1: 复制
    2
    
    输入样例#2: 复制
    3
    2 4 6
    
    输出样例#2: 复制
    6
    
    输入样例#3: 复制
    2
    12 18
    
    输出样例#3: 复制
    12
    
    输入样例#4: 复制
    5
    45 12 27 30 18
    
    输出样例#4: 复制
    15
    

    说明

    In the first example the optimal way is to do the assignment: $ x_{2} $ = $ x_{2} $ - $ x_{1} $ .

    In the second example the optimal sequence of operations is: $ x_{3} $ = $ x_{3} $ - $ x_{2} $ , $ x_{2} $ = $ x_{2} $ - $ x_{1} $ .

    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。