QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372079#5141. Identical ParitySiilhouetteWA 12ms3660kbC++141.3kb2024-03-30 21:06:362024-03-30 21:06:37

Judging History

你现在查看的是最新测评结果

  • [2024-03-30 21:06:37]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:3660kb
  • [2024-03-30 21:06:36]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=2e5+10;

inline ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0)return x=1,y=0,a;
    ll d=exgcd(b,a%b,y,x);
    y-=a/b*x;
    return d;
}

inline bool sol(ll a,ll b,ll m,ll R1,ll R2) //cal ax+by=m (0<=x<=R1)(0<=y<=R2)
{
    ll x,y;
    ll d=exgcd(a,b,x,y);
    if(m%d)return 0;
    a/=d;
    b/=d;
    m/=d;
    ll xx=(ll)x*(m%b)%b;
    if(xx<0)  xx=xx+b;
    ll yy=(ll)(m-a*xx)/b;
    if(yy<0||xx>R1)
        return 0;
    else
    {
        if(0<=xx&&xx<=R1&&0<=yy&&yy<=R2)return 1;
        else
        {
            ll l1=-xx*a,r1=(R1-xx)*a;
            ll l2=-(R2-yy)*b,r2=yy*b;
            ll l=max(l1,l2),r=min(r1,r2);
            ll ab=a*b;
            if(l>r)return 0;
            else if(r/ab>0&&r/ab*ab>=l)return 1;
            else return 0;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);   cin.tie(nullptr),cout.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll a=n/k+1,b=n/k,m=(n+1)/2,x,y;
        puts(sol(a,b,m,n%k,n-(n%k))?"YES":"NO");
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3596kb

input:

3
3 1
4 2
5 3

output:

NO
YES
YES

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

score: -100
Wrong Answer
time: 12ms
memory: 3660kb

input:

100000
1 1
2 1
2 2
3 1
3 2
3 3
4 1
4 2
4 3
4 4
5 1
5 2
5 3
5 4
5 5
6 1
6 2
6 3
6 4
6 5
6 6
7 1
7 2
7 3
7 4
7 5
7 6
7 7
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 8
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 9
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
10 10
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10
11 11
12 1
...

output:

YES
NO
YES
NO
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
Y...

result:

wrong answer expected NO, found YES [31st token]