垃圾BZOJ毁我青春骗我钱财颓我精神

懵逼的 题目

BZOJ

扯淡的 题解

我们发现如果只有一个奇数位置的话我们直接把区间分成两半然后看奇数到底在哪个子区间就行了

沙茶的 代码

注意题面描述和样例不符…QIN而不是Qin…浪费我生命…

/**************************************************************
    Problem: 1271
    User: Cansult
    Language: C++
    Result: Accepted
    Time:612 ms
    Memory:3636 kb
****************************************************************/

#include <iostream>
#include <cstdio>
#include <algorithm>
#define MAXN (200000 + 5)
#define LL long long
using namespace std;
struct teach
{
    int s, e, d;
}a[MAXN];
int n;
bool pd(LL wz)
{
    LL tot = 0;
    for (int i = 1; i <= n; i++)
        if (a[i].s <= wz)
            tot += (min((LL)a[i].e, wz) - a[i].s) / a[i].d + 1;
    return (tot & 1);
}
void solve()
{
    LL le = 0, ri = 0x7ffffffffll, ans, tot = 0;
    while (le < ri)
    {
        LL mi = (le + ri) >> 1;
        if (pd(mi))
            ans = ri = mi;
        else
            le = mi + 1;
    }
    for (int i = 1; i <= n; i++)
        if (a[i].s <= ans &&ans <= a[i].e && (ans - a[i].s) % a[i].d == 0)
            ++tot;
    printf("%lld %lld\n", ans, tot);
}
int main()
{
    int t;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d", &n);
        for (int i = 1; i <= n; i++)
            scanf("%d%d%d", &a[i].s, &a[i].e, &a[i].d);
        LL tot = 0; 
        for (int i = 1; i <= n; i++)
            tot += (a[i].e - a[i].s) / a[i].d + 1;
        if (tot & 1)
            solve();
        else
            puts("Poor QIN Teng:(");
    }
    return 0;
}

By Cansult