F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Transformation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 436    Accepted Submission(s): 126


Problem Description
给你一个二元组$(a,b)$,支持AB两种操作,分别是将其变成$(a,2b-a)$和$(2a-b,b)$。问能否通过大于等于零次操作将其变成$(c,d)$。
 

Input
第一行一个正整数$T(T\leq 8 \times 10^4)$表示数据组数。

接下来$T$行,每行$4$个整数$a, b, c, d (-10^{18} \leq a, b, c, d\leq 10^{18})$。
 

Output
对于每组数据,如果有解,首先输出一行Yes,然后输出一行由$AB$构成的字符串,表示一系列操作。如果有多解,输出长度最短的解,如果有多个长度最短的解,输出字典序最小的。如果无解,输出No。
 

Sample Input
3 0 1 2 3 0 1 0 1 0 1 -1 3
 

Sample Output
No Yes Yes BA
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 10:37:55, Gzip enabled