优先队列+模拟-Fox and Number Game
来源:互联网 发布:mac gdb 动态调试程序 编辑:程序博客网 时间:2024/05/17 08:42
codeforces-Fox and Number Game
题目地址:http://codeforces.com/contest/389/problem/A
Time Limit: 1000ms
Fox Ciel is playing a game with numbers now.
Ciel has n positive integers: x1, x2, ..., xn. She can do the following operation as many times as needed: select two different indexes i and j such that xi > xj hold, and then apply assignment xi = xi - xj. The goal is to make the sum of all numbers as small as possible.
Please help Ciel to find this minimal sum.
Input
The first line contains an integer n (2 ≤ n ≤ 100). Then the second line contains n integers: x1, x2, ..., xn (1 ≤ xi ≤ 100).
Output
Output a single integer — the required minimal sum.
Sample Input
3
2 4 6
5
45 12 27 30 18
4
1 1 2 2
2
1 2
Sample Output
6
15
4
2
大意:每个测试用例是一个数组。找出xi和xj,(xi>xj),做运算令xi=xi-xj。可以做若干组这样的运算,使得最后的数组和最小。输出此和。
分析:用优先队列,每次找出最大的和次大的,处理后再加入此队列。注意多个相同的xi这种情况!
- 优先队列+模拟-Fox and Number Game
- Fox and Number Game(优先队列)
- Fox and Number Game
- codeforecs Fox and Number Game
- A. Fox and Number Game
- L - Fox and Number Game
- codeforces Fox and Number Game
- vj --Fox and Number Game
- CF228A题Fox and Number Game
- Codeforces 389A Fox and Number Game
- 389-A Fox and Number Game
- CF 389A:Fox and Number Game
- codeforces A. Fox and Number Game
- CodeForces 389A Fox and Number Game
- codeforces 389A Fox and Number Game
- codeforces 389A. Fox and Number Game
- Codeforces Round #228 (Div. 2) A. Fox and Number Game
- Codeforces Round #228 (Div. 2)A.Fox and Number Game
- intent服务
- 安卓学习之路_20140505_EditText、SQLite语法
- 在10g oracle里面如何修改为手工归档
- hash一下 + 归并排序计算逆序对数
- Tyvj p1371 蛇灵迷宫 (博弈 输出路径)
- 优先队列+模拟-Fox and Number Game
- hdu 1023 Train Problem II
- 浏览器的不兼容
- Visual C++中DDB与DIB位图编程全攻略
- OpenCV学习笔记(4)之鼠标事件
- 缓解疲劳的方法
- 利用Node.js与PDFKIT 生成PDF文件
- 零拷贝技术
- ZOJ-1119