题解:

硬是把一道傻逼题写到了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. Entity Framework插入数据报错:Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.

    stackoverflow的解决方法 try { db.Entity.Add(entity); db.SaveChanges(); } catch (DbEntityValidationExcepti ...

  2. CF449C:Jzzhu and Apples

    题意简述 给出正整数n,你要把1-n之间的正整数分成尽可能多组,使得每一组两个数的最大公约数大于1;输出能分成最多组的个数,并按任意顺序输出每组的两个数. 很妙的一道题. 首先我们考虑去处理每个质数的 ...

  3. modsign: could't get uefi db list

    手头上一个工控机,装完 ubuntu  16.04后重启, 一直提示如下错误: modsign: could't get uefi db list 用过ubuntu的修复工具也没有成功. 后经过如下操 ...

  4. MSSQL—行转列

    行转列,是SQL中经常会遇到的一个问题,并且分为静态转换和动态转换,所谓静态转换即在转换的行数已知或固定:动态转换则为转换的行数不固定. 转换的方法一般采用case when语句或pivot(MSSQ ...

  5. CF 189A Cut Ribbon

    #include<bits/stdc++.h> using namespace std; const int maxn = 4000 + 131; int n, a, b, c; int ...

  6. C# 如何获取自定义的config中节点的值,并修改节点的值

    现定义一个方法 DIYConfigHelper.cs using System; using System.Xml; using System.Configuration; using System. ...

  7. python 排序 sort和sorted

    当我们从数据库中获取一写数据后,一般对于列表的排序是经常会遇到的问题,今天总结一下python对于列表list排序的常用方法: 第一种:内建方法sort() 可以直接对列表进行排序 用法: list. ...

  8. Win10 SQL Server 2017安装教程

    Win10 SQL Server 2017安装教程 1:下载地址 2:开始安装 1:安装环境预备说明 还要注意就是要先下载这个VC++的更新,可以解决服务器安装不上的问题,下载链接 :Microsof ...

  9. Confluence 6 安装 Oracle

    如果你还没有在安装可以连接的 Oracle 数据库,请先下载后进行安装.请参考 Oracle 文档 来获取有关安装的指南. 当你设置你的 Oracle 服务器的时候: 字符集 必须使用 AL32UTF ...

  10. SpringBoot事务管理

    1.在UserMapper接口中添加更新和删除方法 package com.cppdy.mapper; import org.apache.ibatis.annotations.Delete; imp ...