#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int T,x,y,ans,g,l1,r1,l2,r2;
int init()
{
int x=;char s=getchar();bool f=;
while(s<''||s>''){if(s=='-')f=;s=getchar();}
while(s>=''&&s<=''){x=x*+s-'';s=getchar();}
if(f)return -x;return x;
}
void E_gcd(int a,int b)
{
if(b==)
{
x=;y=;g=a;
}
else
{
E_gcd(b,a%b);
int tmp=x;
x=y;
y=tmp-a/b*y;
}
}
int main()
{
int a,b,c,i,j;
T=init();
while(T--)
{
ans=;
a=init();b=init();c=init();
c=-c;
l1=init();r1=init();l2=init();r2=init();
if(a==&&b==)
{
if(c!=||l1>r1||l2>r1)
{
printf("0\n");
continue;
}
long long an,li,ri;
li=r1-l1+;ri=r2-l2+;
an=li*ri;
cout<<an<<endl;
continue;
}
if(a==)
{
y=c/b;
if(y<l2||y>r2||c%b!=)
printf("0\n");
else
printf("1\n");
continue;
}
if(b==)
{
x=c/a;
if(x<l1||x>r1||c%a!=)
printf("0\n");
else
printf("1\n");
continue;
}
E_gcd(a,b);
if(c%g!=)
{
printf("0\n");
continue;
}
int s=c/g;
x*=s;y*=s;
int ai=a/g;
int bi=b/g;
if(x<l1)
{
while(x<l1)
{
x+=bi;y-=ai;
}
for(i=x;i<=r1;i+=bi,y-=ai)
if(y>=l2&&y<=r2)
ans++;
}
else if(x>r1)
{
while(x>r1)
{
x-=bi;y+=ai;
}
for(i=x;i>=l1;i-=bi,y+=ai)
if(y>=l2&&y<=r2)
ans++;
}
else
{
int yi=y;
for(i=x;i<=r1;i+=bi,yi-=ai)
if(yi>=l2&&yi<=r2)
ans++;
yi=y+ai;
for(i=x-bi;i>=l1;i-=bi,yi+=ai)
if(yi>=l2&&yi<=r2)
ans++;
}
printf("%d\n",ans);
}
return ;
}

codevs 1213 解的个数(我去年打了个表 - -)的更多相关文章

  1. 扩展gcd codevs 1213 解的个数

    codevs 1213 解的个数  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description 已知整数x,y满足如下面的条件: ax+by ...

  2. codevs 1213 解的个数

    1213 解的个数 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold       题目描述 Description 已知整数x,y满足如下面的条件: ax+by+c = ...

  3. Codevs 1213 解的个数(exgcd)

    1213 解的个数 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 已知整数x,y满足如下面的条件: ax+by+c=0 p< ...

  4. 解的个数(codevs 1213)

    题目描述 Description 已知整数x,y满足如下面的条件: ax+by+c = 0 p<=x<=q r<=y<=s 求满足这些条件的x,y的个数. 输入描述 Input ...

  5. n元线性方程非负整数解的个数问题

    设方程x1+x2+x3+...+xn = m(m是常数) 这个方程的非负整数解的个数有(m+n-1)!/((n-1)!m!),也就是C(n+m-1,m). 具体解释就是m个1和n-1个0做重集的全排列 ...

  6. codevs1213 解的个数

    题目描述 Description 已知整数x,y满足如下面的条件: ax+by+c = 0 p<=x<=q r<=y<=s 求满足这些条件的x,y的个数. 输入描述 Input ...

  7. P1098 方程解的个数

    题目描述 给出一个正整数N,请你求出x+y+z=N这个方程的正整数解的组数(1<=x<=y<=z<1000).其中,1<=x<=y<=z<=N . 输入 ...

  8. PE文件格式详解,第三讲,可选头文件格式,以及节表

    PE文件格式详解,第三讲,可选头文件格式,以及节表 作者:IBinary出处:http://www.cnblogs.com/iBinary/版权所有,欢迎保留原文链接进行转载:) 一丶可选头结构以及作 ...

  9. HDU1573 线性同余方程(解的个数)

    X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

随机推荐

  1. 前端html+css之第十四天

    一.HTML 1.HTML是什么? Hypertext Markup Language, 中文也就是超文本链接标示语言. HTML是一套规则,一套浏览器认识的规则. 2.开发者: (1)学习Html规 ...

  2. git extrad_addons 部署说明

    注册一个git账号 : 网址:  https://github.com/ 1:安装git   sudo apt-get install git 2:  b把urc扩展占模块pull下来    cd   ...

  3. while if 循环判断

    temp=input("猜一下我想的那个数字吧:") guess=int(temp) while guess!=8: temp=input("诶呀错误了在输入一次吧:&q ...

  4. readline函数分析

    函数功能:提示用户输入命令,并读取命令/****************************************************************************/ /* ...

  5. How to solve "The specified service has been marked for deletion" error

    There may be several causes which lead to the service being stuck in “marked for deletion”. Microsof ...

  6. WEB工程数据库相关安装脚本写作

    1. 数据库oracle安装 2. 数据库用户创建,表空间创建,表创建 #!/bin/bash current_path=`pwd` create_tablespace=${current_path} ...

  7. 【技术贴】解决前台js传参中文乱码

    方法1: 前台两次编码,后台一次解码.因为getParamet已经自动解了一次了. JavaScript: window.self.location="list.jsp?searchtext ...

  8. java security

    安全性是Java应用程序的非功能性需求的重要组成部分,如同其它的非功能性需求一样,安全性很容易被开发人员所忽略.当然,对于Java EE的开发人员来说,安全性的话题可能没那么陌生,用户认证和授权可能是 ...

  9. Cylinder

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2374 思路:三分枚举. #include &l ...

  10. 使用NetUserAdd API函数创建远程用户

    http://apps.hi.baidu.com/share/detail/33407620 使用NetUserAdd编程创建远程用户Windows API NetUserAdd()可以创建Windo ...