[关闭]
@inkysakura 2017-05-02T13:57:58.000000Z 字数 401 阅读 1279

lightoj1027

CODE


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int ncase=0;
int main()
{
        int t;
        cin >>t;
        while(t--)
        {
                int nNe=0;
                int ntor=0;
                int dtor;
                int n;
                cin >> n;
                for(int i=0;i<n;i++)
                {
                        int tp;
                        cin >>tp;
                        if(tp<0)nNe++;
                        ntor+=abs(tp);
                }
                dtor=(n-nNe);
                int tp=__gcd(dtor,ntor);
                dtor/=tp;
                ntor/=tp;
                cout <<"Case "<<++ncase<<": ";
                if(dtor==0)
                        cout << "inf"<<endl;
                else
                        cout <<ntor<<"/"<<dtor<<endl;
        }
        return 0;
}
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注