BZOJ2038

记得开long long

#include
#include
#include
#include
#include
#define ll long long
using namespace std;
const int N = 1e5+10;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
struct node
{
    int l,r,id;
}arr[N];
int c[N],block,color[N];
ll sum,q[N],p[N];
bool operator<(const node a,const node b)
{
    return((a.l-1)/block+1==(b.l-1)/block+1)?a.rql)
            change(c[--l],1);
        while(lqr)
            change(c[r--],-1);
        if(l==r)
        {
            q[arr[i].id] = 0 ,p[arr[i].id] = 1;
            continue;
        }
        int lon = arr[i].r - arr[i].l +1;
        q[arr[i].id] = sum-lon;
        p[arr[i].id] = (ll)lon*(lon-1);
        ll k = gcd(q[arr[i].id],p[arr[i].id]);
        q[arr[i].id]/=k;
        p[arr[i].id]/=k;
    }
    for(int i=1;i<=m;i++)
        printf("%lld/%lld\n",q[i],p[i]);
    return 0;
}

 

你可能感兴趣的:(acm)