Yet Another Two Integers Problem

简介: Yet Another Two Integers Problem

文章目录

一、Yet Another Two Integers Problem

总结


一、Yet Another Two Integers Problem

本题链接:Yet Another Two Integers Problem


题目:

A. Yet Another Two Integers Problem

time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

You are given two integers a and b.


In one move, you can choose some integer k from 1 to 10 and add it to a or subtract it from a. In other words, you choose an integer k∈[1;10] and perform a:=a+k or a:=a−k. You may use different values of k in different moves.


Your task is to find the minimum number of moves required to obtain b from a.


You have to answer t independent test cases.


Input

The first line of the input contains one integer t (1≤t≤2⋅1e4) — the number of test cases. Then t test cases follow.


The only line of the test case contains two integers a and b (1≤a,b≤1e9).


Output

For each test case, print the answer: the minimum number of moves required to obtain b from a.


Example

input

6

5 5

13 42

18 4

1337 420

123456789 1000000000

100500 9000

output

0

3

2

92

87654322

9150

Note

In the first test case of the example, you don’t need to do anything.


In the second test case of the example, the following sequence of moves can be applied: 13→23→32→42 (add 10, add 9, add 10).


In the third test case of the example, the following sequence of moves can be applied: 18→10→4 (subtract 8, subtract 6).


本博客给出本题截图:

image.png

题意:给出两个数ab,每次我们可以把b加上或减去(1~10)中的任何一个数字,问最少操作几步可以把数字b变成数字a

AC代码

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t -- )
    {
        int a, b;
        cin >> a >> b;
        int t = abs(a - b);
        if (t % 10) 
            cout << t / 10 + 1 << endl;
        else cout << t / 10 << endl;
    }
    return 0;
}

总结

水题,不解释


目录
打赏
0
0
0
0
62
分享
相关文章
从0搭建Vue3组件库(七):使用 gulp 打包组件库并实现按需加载
从0搭建Vue3组件库(七):使用 gulp 打包组件库并实现按需加载
491 0
【链表】还不会用C++实现链表?一文教会你各种链表的实现
【链表】还不会用C++实现链表?一文教会你各种链表的实现
409 0
【Java用法】Java 过滤html标签获取纯文本信息
【Java用法】Java 过滤html标签获取纯文本信息
303 0
|
10月前
|
Java线程池原理与锁机制分析
综上所述,Java线程池和锁机制是并发编程中极其重要的两个部分。线程池主要用于管理线程的生命周期和执行并发任务,而锁机制则用于保障线程安全和防止数据的并发错误。它们深入地结合在一起,成为Java高效并发编程实践中的关键要素。
128 0
MaxCompute产品使用问题之如何对现有的非分区表数据进行分区处理
MaxCompute作为一款全面的大数据处理平台,广泛应用于各类大数据分析、数据挖掘、BI及机器学习场景。掌握其核心功能、熟练操作流程、遵循最佳实践,可以帮助用户高效、安全地管理和利用海量数据。以下是一个关于MaxCompute产品使用的合集,涵盖了其核心功能、应用场景、操作流程以及最佳实践等内容。
133 0
《数据治理简易速速上手小册》第6章 数据访问与共享(2024 最新版)
《数据治理简易速速上手小册》第6章 数据访问与共享(2024 最新版)
169 0
css用法 :is()、:where()和:has()的用法
【4月更文挑战第2天】 css用法 :is()、:where()和:has()的用法
220 12
平滑迁移DNS到阿里云的方案
本文主要介绍当前DNS服务器在未使用云解析场景下,如何使用云解析(平滑迁移)。
405 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问