Hdu 4768 Flyer Changchun cyber competition 1010

Source: Internet
Author: User

#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int maxn=2e4+9;const double inf=1e10;int n;struct D{    long long a,b,c;}data[maxn];long long cal(long long tmp){    long long ans=0;    for(int i=1;i<=n;i++)    {        long long mmin=min(tmp,data[i].b);        if(mmin>=data[i].a)        {            ans+=(mmin-data[i].a)/data[i].c+1;        }    }    return ans;}bool chk(long long tmp){    long long ans=cal(tmp);    return ans%2;}int main(){    while(scanf("%d",&n)!=EOF)    {        for(int i=1;i<=n;i++)        scanf("%lld %lld %lld",&data[i].a,&data[i].b,&data[i].c);        long long l=1,r=inf,mid;        while(l<r)        {            mid=l+r>>1;            if(chk(mid)) r=mid;            else l=mid+1;        }        if(l==inf)        printf("DC Qiang is unhappy.\n");        else        {            printf("%d ",l);            long long ans=cal(l)-cal(l-1);            cout<<ans<<endl;        }    }    return 0;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.