文章目录

  • 一、Divisibility Problem
  • 总结

一、Divisibility Problem

本题链接:Divisibility Problem

题目
A. Divisibility Problem
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
You are given two positive integers a and b. In one move you can increase a by 1 (replace a with a+1). Your task is to find the minimum number of moves you need to do in order to make a divisible by b. It is possible, that you have to make 0 moves, as a is already divisible by b. You have to answer t independent test cases.

Input
The first line of the input contains one integer t (1≤t≤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 you need to do in order to make a divisible by b.

Example
input
5
10 4
13 9
100 13
123 456
92 46
output
2
5
4
333
0

本博客给出本题截图

题意:输入两个数ab,问a需要加多少才能变成b的倍数

AC代码

#include <cstdio>using namespace std;int main()
{int t;scanf("%d", &t);while (t -- ){int a, b;scanf("%d%d", &a, &b);int t = a % b;if (!t) puts("0");else printf("%d\n", b - t);}return 0;
}

总结

水题,不解释

Divisibility Problem相关推荐

  1. Codeforces Round #629 (Div. 3) A~C

    昨天晚上打了一场CF,由于网卡,还有英语题读题较慢,所以只AC了3道题->_-> (准确的来说AC了2道,因为最后凌晨的时候我这边网络直接崩了,连接不上codefores,就没提交成功QA ...

  2. java文本域不可编辑_javascript:让表单 文本框 只读,不可编辑的方法

    有时候,我们希望表单中的文本框是只读的,让用户不能修改其中的信息,如使 的内容,"中国"两个字不可以修改.实现的方式归纳一下,有如下几种. 方法1: οnfοcus=this.bl ...

  3. linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.

    所有的base 都要取消注释 mirrorlist 加上注释 另外所有的enable都要设为零 目录 今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现y ...

  4. A + B Problem

    1001: A + B Problem Description 计算 A + B. Input 多组测试数据,每组测试数据占一行,包括2个整数. Output 在一行中输出结果. Sample Inp ...

  5. Error:(49, 1) A problem occurred evaluating project ':guideview'. Could not read script 'https://r

    出现问题如下: Error:(49, 1) A problem occurred evaluating project ':guideview'. > Could not read script ...

  6. #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)

    题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...

  7. ADPRL - 近似动态规划和强化学习 - Note 3 - Stochastic Infinite Horizon Problem

    Stochastic Infinite Horizon Problem 3.Stochastic Infinite Horizon Problem 定义3.1 无限范围的马尔可夫决策过程 (Marko ...

  8. ADPRL - 近似动态规划和强化学习 - Note 2 - Stochastic Finite Horizon Problem

    2. Stochastic Finite Horizon Problem 在这一节中主要介绍了随机DP算法来解决不确定性下的有限地范围问题,如Denition 1.4所述,它被表述为一个组合优化问题. ...

  9. There was a problem confirming the ssl certificate ……

    在安装一个Python库onetimepass时发生下面的问题: pip install onetimepass Could not fetch URL https://pypi.python.org ...

最新文章

  1. 激活当前视图菜单高亮呈现 V2.0
  2. 关于函数调用、静态变量、预编译的习题
  3. python学了有什么用处-python教程有什用《学习python有什么好的用处》
  4. python安装pip-安装pip的三种方法
  5. 快速修改HTML5,HTML5无刷新修改URL(示例代码)
  6. git stash简介
  7. django-删除学生数据
  8. Codeforces Round #280 (Div. 2) D. Vanya and Computer Game 二分
  9. php版密码字典生成 原创,真空密码字典生成器-使用教程和下载
  10. ORACLE_mldn_002
  11. FPN网络详解——feature pyramid network
  12. react+clodop打印
  13. ubuntu安装deb文件
  14. cython混淆加密
  15. Python开发 CDN查询子域名查询
  16. Chrome书签插件,让你实现高效整理
  17. CentOS7.5安装Oracle19c
  18. 真正的理解setup time/hold time
  19. linux终端实现骇客帝国的字符雨动画
  20. Debian 9.x 系统安装 Proxmox VE (笔记)

热门文章

  1. 大学生三大痛点及分析
  2. 叮咚买菜拟IPO背后:烧钱难见回报,下一个ofo小黄车?
  3. Winform 串口通讯之地磅
  4. 【大学生活】搞学习还是搞技术
  5. 简单 PHP + MySQL 数据库动态网站制作(速成篇)
  6. 年轻人如何才能实现年薪百万呢?用数据分析来帮你探探路
  7. 信号量机制以及各种例题
  8. 联想计算机游戏本,联想游戏本哪款性价比高
  9. 电商营收增幅155%,Lululemon卖多少条瑜伽裤才能赶超耐克市值?
  10. 自动控制原理(6)——结构图等效变换准则及应用、信号流图、梅逊公式