Gym - 102021E
Gym - 102021E
https://vjudge.net/problem/2109787/origin
主要是一个处理精度的技巧,避免精度误差可以加eps,然后乘1e(小数点之后的位数)。
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 10000010
#define For(i,a,b) for(int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
int T;
double x,y,t;
int a,b;
int n,cnt;
int prime[N];
bool vis[N]; void in(int &x){
int y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(int x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
} void Euler(){
vis[]=;
For(i,,){
if(!vis[i]) prime[++cnt]=i;
for(int j=;j<=cnt&&i*prime[j]<=;j++){
vis[i*prime[j]]=;
if(i%prime[j]==)
break;
}
}
} int gcd(int a,int b){
return (a%b==?b:gcd(b,a%b));
} int main(){
in(T);
Euler();
while(T--){
cin>>x>>y;
a=(int)((x+1e-)*1e5);
b=(int)((y+1e-)*1e5);
t=gcd(a,b);
a/=t;
b/=t;
if(a==b){
cout<<"2 2"<<endl;
continue;
}
if(!vis[a]&&!vis[b])
cout<<a<<" "<<b<<endl;
else
cout<<"impossible"<<endl;
}
return ;
}
Gym - 102021E的更多相关文章
- GCPC 2018
C.Coolest Ski Route 题意:n个点,m条边组成的有向图,求任意两点之间的最长路径 dfs记忆化搜索 #include<iostream> #include<stri ...
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
随机推荐
- leetcood学习笔记-45-跳跃游戏二
题目描述: 第一次提交;超时 class Solution: def jump(self, nums: List[int]) -> int: l = [] for i in range(len( ...
- [JZOJ3347] 【NOI2013模拟】树的难题
题目 题目大意 给你一棵树,每个节点有三种黑.白.灰三种颜色. 你要割掉一些边(每条边被割需要付出一定的代价),使得森林的每棵树满足: 没有黑点或至多一个白点. 思考历程 这题一看就知道是一个树形DP ...
- 【JZOJ6354】最短路(tiring)
description analysis 显然边权有变化规律\(x,{1\over{x-1}},{x-1\over x},x,...\) 于是把一个点拆成三个点,分别表示步数到除\(3\)余\(0,1 ...
- hdu多校第四场 1007 (hdu6620) Just an Old Puzzle 逆序对
题意: 给你一个数字拼图,问你数字拼图能否能复原成原来的样子. 题解: 数字拼图的性质是,逆序数奇偶相同时,可以互相转化,逆序数奇偶不同,不能互相转化. 因此统计逆序对即可. #include< ...
- Linux课程---16、apache虚拟主机设置(如何在一台服务器上配置三个域名)
Linux课程---16.apache虚拟主机设置(如何在一台服务器上配置三个域名) 一.总结 一句话总结:有三个网站www.lampym.com,bbs.lampym.com,mysql.lampy ...
- 转:C语言中volatile关键字的作用 专家博客
源地址:http://blog.csdn.net/tigerjibo/article/details/7427366 一.前言 1.编译器优化介绍: 由于内存访问速度远不及CPU处理速度,为提高机器整 ...
- typedef void (*funcptr)(void) typedef void (*PFV)(); typedef int32_t (*PFI)();
看到以下代码,不明白查了一下: /** Pointer to Function returning Void (any number of parameters) */ typedef void (* ...
- joda 获取每个月第一天第一秒和最后一天最后一秒
/** * 获取每个月第一天的第一秒 * @return */ public static final Date getMouthOfFirst(){ DateTimeFormatter format ...
- vue打包后index.html界面报错
vue项目完成后,打包放到服务器上,打开index.html页面时发现一片空白并且报错 很明显是js和css引用不到. 解决办法: 修改vue项目config文件夹下面的index.js,将asset ...
- python代码打包成exe文件
1.准备工作 1.安装pywin32.pyinstaller 2.准备好ico文件 找一个png格式的图片,使用png2ico脚本生成包含以下6个尺寸的ico文件:128×128 64×64 48×4 ...