滴答滴答---题目链接

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 aand 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

 方法一:

#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{int t;scanf("%d",&t);while(t--){int a,b;scanf("%d%d",&a,&b);int s1,s2,s3,s4;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){printf("%d x %d \n",a,b);}else if(s3==0&&s4==0){printf("%d x %d - %d x %d\n",s1,b,s2,b);}else if(s1==0&&s2==0){printf("%d x %d - %d x %d\n",a,s3,a,s4);}else printf("%d x %d + %d x %d - %d x %d - %d x %d\n",s1,s3,s2,s4,s1,s4,s2,s3);}return 0;
}

A - Multiplication Dilemma (思维)( 2018 ACM ICPC Arabella Collegiate Programming Contest)相关推荐

  1. 2018 ACM ICPC Arabella Collegiate Programming Contest A

    Multiplication operation is not always easy! For example, it is hard to calculate 27 × 20 using your ...

  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. 2017 ACM Arabella Collegiate Programming Contest(solved 11/13)

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

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

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

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

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

  6. Codeforces Gym 2015 ACM Arabella Collegiate Programming Contest

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

  7. 2015 ACM Arabella Collegiate Programming Contest

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

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

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

  9. 2017 ACM Arabella Collegiate Programming Contest G. Snake Rana GYM101350G

    先算一下总的子矩阵个数 总共最多只有20个点 状压一下然后枚举 容斥一下 把求出来的答案减去包含1个点的子矩阵再加上包含2个点的减去3个点的-- #include <iostream> # ...

最新文章

  1. ceph-objectstore-tool工具使用详解
  2. 爆料!传阿里人靠脸吃饭真相是......
  3. 数字图像处理与机器视觉——Visual C++与Matlab实现书中代码勘误
  4. 2018ICPC南京赛区网络选拔B The writing on the wall (单调栈)
  5. 计算机网络自考顺序,自考计算机网络课程复习顺序是怎样?有没有好用的计算机网络自考APP?...
  6. 栈操作与栈帧 (转)
  7. Session的clear方法和flush方法
  8. 计算机水平拼音怎么写,电脑上的拼音到底是怎么敲出来的
  9. 抢火车票,出行必备程序(12306bypass)--可以抛掉同程什么的抢票软件了
  10. 通信笑笑点(2010.08.14)
  11. NFT的未来:RFT、数据经济和Web3堆栈创新的推动者
  12. Idea的类注释和方法注释
  13. saas模式人力资源管理系统
  14. 网贷害人,迷途知返后,天真的以为外包只要会增删改查就够了???
  15. 优思学院|权力下放,给下属自由发挥的空间
  16. 【舒适区如何影响着我的生活】
  17. 分享45个android实例源码,很好很强大.收藏吧!!!
  18. [Android 基础] -- Android 属性系统简介
  19. 柯尼卡美能达提示关闭第一侧盖板未关闭故障
  20. 【福利】成为专业程序员路上用到的各种优秀资料、神器及框架

热门文章

  1. 一条Sql查询语句的优化
  2. 微信小程序开发——动态改变按钮背景颜色
  3. scratch3.0加载自己的作品最新版
  4. 牛客小白月赛24 J—建设道路
  5. 宁波市第23届中小学生计算机程序设计竞赛初赛,宁波市第24届中小学生计算机程序设计竞赛初赛试题(小学组)...
  6. vue项目引入icon图标
  7. 闭式系统蒸汽管径推荐速度_暖通设计常用参考数据1
  8. Polychain重仓的Findora公链,想带领DeFi脱虚向实
  9. Android 关于Excel表格的读与写(包括图片、字体颜色,语言)
  10. 同时查询多个韵达快递物流信息,分析出多次派件的单号