Multiplication operation is not always easy! For example, it is hard to calculate 27 × 20 using your mind, but it is easier to find the answer using the following methods: 30 × 20 - 3 × 20. It turns out that people can calculate the multiplication of two special numbers very easily.

A number is called special if it contains exactly one non-zero digit at the beginning (i.e. the most significant digit), followed by a non-negative number of zeros. For example, 30, 7, 5000 are special numbers, while 0, 11, 8070 are not.

In this problem, you are given two numbers a and b. Your task is to calculate the multiplication of a and b (a × b), by writing the multiplication expression as a summation or subtraction of multiplication of special numbers. Can you?

Input

The first line contains an integer T (1 ≤ T ≤ 104) specifying the number of test cases.

Each test case consists of a single line containing two integers a and b ( - 109 ≤ a, b ≤ 109, a ≠ 0, b ≠ 0), as described in the problem statement above.

Output

For each test case, print a single line containing the multiplication expression of a and b as a summation or subtraction of multiplication of special numbers. All special numbers must be between  - 109 and 109 (inclusive). If there are multiple solutions, print any of them. It is guaranteed that an answer always exists for the given input.

The multiplication expression must be printed in exactly one line. A single term must be printed as  in which z and w are both special numbers, # represents a single space, and x represents the multiplication operation. Two consecutive terms must be printed as  in which z and w are both special numbers, # represents a single space,  represents the multiplication operation, and  represents either the addition operation  +  or the subtraction operation  - . (Check the sample output for more clarification).

Example

Input

2
55 20
70 17

Output

60 x 20 - 5 x 20
-3 x 70 + 70 x 20

起初我们要选择一种输出方式

我选择的是(s1-s2)*(s3-s4)=s1*s2+s2*s4-s1*s4-s2*s3;

即我选择的是向上取,你也可以选择向下取,也可以一个向上一个向下

代码:

import java.util.Scanner;public class Main {static int T,a,b;static int s1,s2,s3,s4;public static void main(String[] args) {// TODO Auto-generated method stubScanner sc=new Scanner(System.in);T=sc.nextInt();while(T>0){a=sc.nextInt();b=sc.nextInt();s1=s2=s3=s4=0;if(a%10!=0){s1=(a/10+1)*10;//向上取后的值s2=10-a%10;//向上取后应减去的值}if(b%10!=0){s3=(b/10+1)*10;//向上取后的值s4=10-b%10;//向上取后应减去的值}if(s1==0&&s2==0&&s3==0&&s4==0){//如果都是特殊数直接输出System.out.println(a+" x "+b);}else if(s1==0&&s2==0){//第一个数是特殊的System.out.println(a+" x "+s3+" - "+a+" x "+s4);}else if(s3==0&&s4==0){//第二个数是特殊的System.out.println(s1+" x "+b+" - "+s2+" x "+b);}else{//都不是特殊的System.out.println(s1+" x "+s3+" + "+s2+" x "+s4+" - "+s1+" x "+s4+" - "+s2+" x "+s3);}T--;}}}

2018 ACM ICPC Arabella Collegiate Programming Contest A相关推荐

  1. A - Multiplication Dilemma (思维)( 2018 ACM ICPC Arabella Collegiate Programming Contest)

    滴答滴答---题目链接 Multiplication operation is not always easy! For example, it is hard to calculate 27 × 2 ...

  2. 2015 ACM Arabella Collegiate Programming Contest(F题)

    F. Palindrome [ Color: Pink ] A string is palindrome if it can be read the same way in either direct ...

  3. 2015 ACM Arabella Collegiate Programming Contest

    题目链接:https://vjudge.net/contest/154238#overview. ABCDE都是水题. F题,一开始分类讨论,结果似乎写挫了,WA了一发.果断换并查集上,A了. G题, ...

  4. 2017 ACM Arabella Collegiate Programming Contest(solved 11/13)

    省选考前单挑做点ACM练练细节还是很不错的嘛- 福利:http://codeforces.com/gym/101350 先来放上惨不忍睹的virtual participate成绩(中间跑去食堂吃饭于 ...

  5. gym100676 [小熊骑士限定]2015 ACM Arabella Collegiate Programming Contest

    Kuma Rider久违的第二场训练,这场很水,又在vj的榜单上看到第一场的大哥了,2小时ak,大哥牛啤! A.水 #include<cstdio> #include<iostrea ...

  6. Gym - 101972B Arabella Collegiate Programming Contest (2018) B. Updating the Tree 树DFS

    题面 题意:T组数据,每次给你1e5个点的树(1为根),每个点有一权值,询问1-n每个节点的子树中, 至少修改几个点的权值(每次都可以任意修改),才能让子树中任意2点的距离==他们权值差的绝对值 无解 ...

  7. 2017 ACM Arabella Collegiate Programming Contest div2的题,部分题目写个题解

    F. Monkeying Around   维护点在多少个线段上 http://codeforces.com/gym/101350/problem/F 题意:有m个笑话,每个笑话的区间是[L, R], ...

  8. Codeforces Gym 2015 ACM Arabella Collegiate Programming Contest

    比赛链接: http://codeforces.com/gym/100676 题目链接: http://codeforces.com/gym/100676/attachments/download/3 ...

  9. Codeforces Gym 2015 ACM Arabella Collegiate Programming Contest(二月十日训练赛)

    A(By talker): 题意分析:以a(int) op b(int)形式给出两个整数和操作符, 求两个整数是否存在操作符所给定的关系 ,有则输出true,无则输出false:思路:由于无时间复杂度 ...

最新文章

  1. 独家 | 综述:情感树库上语义组合的递归深层模型
  2. JetBrains放出Java代码质量检查工具Qodana,不了解一下?
  3. strcpy,strncpy,memcpy,memmove
  4. 多个redistemplate_Spring boot 使用多个RedisTemplate
  5. 10个优秀的Objective-C和iOS开发在线视频教程
  6. mysql时间间隔年份_MySQL DATEDIFF函数获取两个日期的时间间隔的方法
  7. 连接oracle出现ORA-12514错误
  8. 详解淘宝直播背后的技术!
  9. 蓝桥杯dfs搜索专题
  10. parse Json
  11. python从入门到实践课后答案-Python编程:从入门到实践(课后习题8)
  12. c语言中一些公用的方法
  13. thymeleaf菜鸟教程_Spring MVC应用程序中的Thymeleaf模板布局,无扩展
  14. 过年倒计时 java swing 附源码
  15. 01. Introdunction to Zero Knowlege -- Alon Rosen[零知识介绍]
  16. VM虚拟机占内存非常大
  17. C#.NET发EMAIL的几种方法 MailMessage/SmtpClient/CDO.Message
  18. openwrt mt7620a使能uartf
  19. 计算机房电源引入方式,(完整版)通信机房电源计算公式.pdf
  20. intellij idea报错:类文件具有错误的版本 61.0, 应为 52.0

热门文章

  1. 海思开发板设置开机自启动方法
  2. Erlang 下载安装
  3. 人人美剧迅雷链接多线程和多进程爬虫分析
  4. php elasticsearch更新文档
  5. 非关系型数据库NoSQL的崛起
  6. C#将PDF文件转为图片
  7. 计算机人工智能分数,分数一般想学人工智能?这6所双一流大学是首选
  8. 招商银行信用卡中心笔试
  9. 分析大量壹米滴答物流揽收后是否有物流的实例步骤
  10. 计算机视觉-图像处理基础