#include<iostream>
#include<cstdio>
using namespace std;
int x,y;
int tot=1;
int a,b,c,p,q,r,s;
int exgcd(int a,int b,int & x,int & y)
{
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    int r=exgcd(b,a%b,x,y);
    int tmp;
    tmp=x;
    x=y;
    y=tmp-a/b*y;
    return r;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld%lld%lld%lld%lld%lld",&a,&b,&c,&p,&q,&r,&s);
        exgcd(a,b,x,y);
        x=x*c;
        y=y*c;
        while(x>=p&&x<=q&&y>=r&&y<=s)
        {
            tot++;
            x=x+b;
            y=y+b;
        }
        printf("%d",tot);
    }
    
    return 0;
}

相关文章:

  • 2021-12-23
  • 2022-01-23
  • 2022-03-04
  • 2021-07-01
  • 2021-11-22
  • 2021-10-25
  • 2022-12-23
  • 2021-06-02
猜你喜欢
  • 2021-12-03
  • 2021-06-10
  • 2021-11-21
  • 2022-01-10
相关资源
相似解决方案