题解:

硬是把一道傻逼题写到了200行。。

长长的模板就有70行。。

由于我没有做的时候觉得并不保证$a1|a0$ $b0|b1$ 然后就加了很多特判。。

我的做法就是暴力分解质因数

T*sqrt(n)/log(n)

#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define rg register
#define IL inline
#define ll long long
#define rep(i,h,t) for (int i=h;i<=t;i++)
#define dep(i,t,h) for (int i=t;i>=h;i--)
#define setit set<int>::iterator
#define fi first
#define se second
#define mp make_pair
#define me(x) memset(x,0,sizeof(x))
#define mid ((h+t)>>1)
#define mid2 ((h+t+1)>>1)
char ss[<<],*A=ss,*B=ss;
IL char gc()
{
return A==B&&(B=(A=ss)+fread(ss,,<<,stdin),A==B)?EOF:*A++;
}
template<class T>void read(T &x)
{
rint f=,c; while (c=gc(),c<||c>) if (c=='-') f=-; x=(c^);
while (c=gc(),c>&&c<) x=(x<<)+(x<<)+(c^); x*=f;
}
char sr[<<],z[]; int Z,C=-;
template<class T>void wer(T x)
{
if (x<) sr[++C]='-',x=-x;
while (z[++Z]=x%+,x/=);
while (sr[++C]=z[Z],--Z);
}
IL void wer1()
{
sr[++C]=' ';
}
IL void wer2()
{
sr[++C]='\n';
}
template<class T>IL void maxa(T &x,T y)
{
if (x<y) x=y;
}
template<class T>IL void mina(T &x,T y)
{
if (x>y) x=y;
}
template<class T>IL T MAX(T x,T y)
{
return x>y?x:y;
}
template<class T>IL T MIN(T x,T y)
{
return x<y?x:y;
}
const int N=5e4;
const int M=N+1e3;
int f[M],cnt,g1[M],g2[M],g3[N],g4[N];
bool t[M],tt;
IL int fj(int *a,int b)
{
rep(i,,cnt)
while (b%f[i]==) a[i]++,b/=f[i];
return b;
}
IL void prf()
{
wer(); wer2();
tt=;
}
int main()
{
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
rep(i,,N)
if (!t[i])
{
for (int j=;j*i<=N;j++) t[i*j]=;
}
rep(i,,N) if (!t[i]) f[++cnt]=i;
int n,a0,a1,b0,b1;
read(n);
rep(i,,n)
{
read(a0); read(a1); read(b0); read(b1);
rep(j,,cnt) g1[j]=g2[j]=g3[j]=g4[j]=;
int t1,t2,t3,t4;
t1=fj(g1,a0); t2=fj(g2,a1);
t3=fj(g3,b0); t4=fj(g4,b1);
ll ans=;
tt=;
rep(i,,cnt)
{
if (g1[i]<g2[i]||g3[i]>g4[i])
{
prf(); break;
}
if (g1[i]>g2[i])
{
if (g3[i]<g4[i])
if (g4[i]!=g2[i])
{
prf(); break;
}
if (g3[i]==g4[i])
{
if (g3[i]<g2[i])
{
prf(); break;
}
}
} else
{
if (g3[i]<g4[i])
if (g4[i]<g2[i])
{
prf(); break;
}
if (g3[i]==g4[i])
{
if (g3[i]<g2[i])
{
prf(); break;
} else
{
ans*=(g3[i]-g2[i]+);
}
}
}
}
if (tt) continue;
if (t2!=)
{
if (t1!=t2)
{
prf();
} else
{
if ((t3!=&&t3!=t2)||(t4!=t2)) prf();
else wer(ans),wer2();
}
} else
{
if (t1==)
{
if (t4==&&t3==)
{
wer(ans); wer2();
} else
if (t4==&&t3!=)
{
prf();
} else
if (t4!=&&t3==)
{
wer(ans); wer2();
} else
{
if (t4==t3) wer(ans*),wer2();
else prf();
}
} else
{
if (t4==&&t3==)
{
wer(ans); wer2();
} else
if (t4==&&t3!=)
{
prf();
} else
if (t4!=&&t3==)
{
if (t1!=t4) wer(ans),wer2();
else prf();
} else
{
if (t3==t4)
if (t3!=t1) wer(ans*),wer2();
else wer(ans),wer2();
else prf();
}
}
}
}
fwrite(sr,,C+,stdout);
return ;
}

Hankson 的趣味题的更多相关文章

  1. 算法训练 Hankson的趣味题

    算法训练 Hankson的趣味题   时间限制:1.0s   内存限制:64.0MB        问题描述 Hanks 博士是BT (Bio-Tech,生物技术) 领域的知名专家,他的儿子名叫Han ...

  2. 1172 Hankson 的趣味题[数论]

    1172 Hankson 的趣味题 2009年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解       题目描述 Descrip ...

  3. 1172 Hankson 的趣味题

    1172 Hankson 的趣味题 2009年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解       题目描述 Descrip ...

  4. Codevs 1172 Hankson 的趣味题 2009年NOIP全国联赛提高组

    1172 Hankson 的趣味题 2009年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description Hanks 博 ...

  5. 一本通1626【例 2】Hankson 的趣味题

    1626:[例 2]Hankson 的趣味题 题目描述 Hanks 博士是BT (Bio-Tech,生物技术) 领域的知名专家,他的儿子名叫Hankson.现在,刚刚放学回家的Hankson 正在思考 ...

  6. 洛谷 P1072 Hankson 的趣味题 解题报告

    P1072 \(Hankson\)的趣味题 题目大意:已知有\(n\)组\(a0,a1,b0,b1\),求满足\((x,a0)=a1\),\([x,b0]=b1\)的\(x\)的个数. 数据范围:\( ...

  7. CH3201 Hankson的趣味题

    题意 3201 Hankson的趣味题 0x30「数学知识」例题 描述 Hanks博士是BT(Bio-Tech,生物技术)领域的知名专家,他的儿子名叫Hankson.现在,刚刚放学回家的Hankson ...

  8. luogu P1072 Hankson的趣味题

    题目链接 luogu P1072 Hankson 的趣味题 题解 啊,还是noip的题好做 额,直接推式子就好了 \(gcd(x,a_0)=a_1=gcd(\frac{x}{a_1},\frac{a_ ...

  9. 洛谷P1072 Hankson 的趣味题

    P1072 Hankson 的趣味题 题目描述 Hanks 博士是 BT (Bio-Tech,生物技术) 领域的知名专家,他的儿子名叫 Hankson.现在,刚刚放学回家的 Hankson 正在思考一 ...

  10. NOIP 2009 Hankson 的趣味题

    洛谷 P1072 Hankson 的趣味题 洛谷传送门 JDOJ 1648: [NOIP2009]Hankson的趣味题 T2 JDOJ传送门 Description Hanks 博士是BT (Bio ...

随机推荐

  1. DBUtils--数据库连接池

    介绍 DBUtils是一套Python数据库连接池包,并允许对非线程安全的数据库接口进行线程安全包装. pg大概是是PostgreSQL(基于PyGreSQL)数据库,DB是其他数据库 Steady[ ...

  2. VIsual Studio编译OpenCV:无法打开python27_d.lib(python36_d.lib)的问题

    原文地址:http://blog.csdn.net/Chris_zhangrx/article/details/78947526 在用 VS2015 编译 Debug 版的 openCV 源码时,最后 ...

  3. 030_CORS深究

    在日常的项目开发时会不可避免的需要进行跨域操作,而在实际进行跨域请求时,经常会遇到类似 No 'Access-Control-Allow-Origin' header is present on th ...

  4. VS2017编译LevelDB

    环境: 操作系统:Win7 x64 编译器:VS2017 需要Boost库支持,需要先将Boost库编译成为64位版本. 一.项目文件导入 1. 下载leveldb-windows,https://c ...

  5. 最新版Kali Linux虚拟机安装Open-vm-tools替代VMware tools

    自从Kali 2.0发布之后,会经常遇到安装vmware tools无法成功,或者提示安装成功了但是仍旧无法进行文件拖拽.复制和剪切的问题. 今天给新电脑装系统,重新下载了最新版,Kali 2017. ...

  6. C语言实现程序跳转到绝对地址0x100000处执行

    嵌入式笔试题:想让程序跳转到绝对地址0x100000处执行,该如何做? 请详细解释一下所给的答案: 网上看到有如下答案: *((void(*)(void))0x100000)(); 经过在VC++6. ...

  7. VS下载Github的项目引用报错

    错误如下 1.添加新的Nuget包源 添加新的源 https://www.nuget.org/api/v2/ 2.还原Nuget包 3.升级Visual Studio到最新 工具-->获取工具和 ...

  8. python 基础 01

    什么是计算机? cpu: 计算机的大脑; 读写速度 3GHZ 内存: (为了提高利用率) 缓冲硬盘和cpu 硬盘: 机械硬盘读写速度70mb/s 计算机里面读写的内容都是01代码 二进制(计算机只认二 ...

  9. 洛谷P4859 已经没有什么好害怕的了 [DP,容斥]

    传送门 思路 大佬都说这是套路题--嘤嘤嘤我又被吊打了\(Q\omega Q\) 显然,这题是要\(DP\)的. 首先思考一下性质: 为了方便,下面令\(k=\frac{n+k}{2}\),即有恰好\ ...

  10. web.xml详细选项配置

    Web.xml常用元素 <web-app> <display-name></display-name>定义了WEB应用的名字 <description> ...