Fox and Number Game
水了一个优先队列的题目
#include <iostream>
#include <queue>
using namespace std;
int main()
{
priority_queue<int>q;
int n, m, i;
while(cin>>n)
{
for( i = 0; i < n; i++)
{
cin>>m;
q.push(m);
}
while(q.size() >= 2)
{
int x = q.top();
q.pop();
int y = q.top();
if(x > y)
{
int z = x - y;
q.push(z);
}
}
int sum = q.top() * n;
while(!q.empty())
{
q.pop();
}
cout<<sum<<endl;
}
return 0;
}