“As a special bonus, if they order
by midnight, what would they receive?
Colin: They’d receive it earlier than if
they’d ordered it later.
Songs of the Butcher

Colin and Ryan had a party. They baked C cookies and invited G guests. Each guest ate Q cookies, and R cookies were left (R < Q).
Input
The first line of input gives the number of cases, N. N test cases follow. Each one is a line containing C and R (at most 2000000000).
Output
For each test case, output one line containing ‘Case #x:’ followed by Q — the number of cookies each guest ate. If there are multiple answers, print them in increasing order, separated by spaces. Do not print trailing spaces. Print a ‘0’ in the case when R = C.
Sample Input
4
10 0
13 2
300 98
1000 997
Sample Output
Case #1: 1 2 5 10
Case #2: 11
Case #3: 101 202
Case #4:

问题链接:UVA10880 Colin and Ryan
问题简述:总共C块饼干,请G个客人吃,每人吃Q块,余下R块。给定C和R,问每位客人可以吃多少块饼干,有多种解,从小到大输出这些解。
问题分析:整除问题,求C-R的因子即可,用STL的set来排序。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10880 Colin and Ryan */#include <bits/stdc++.h>using namespace std;int main()
{int t, caseno = 0;scanf("%d", &t);while (t--) {int c, r;scanf("%d%d", &c, &r);int diff = c - r;printf("Case #%d:", ++caseno);if (diff == 0)printf(" 0\n");else {set<int> ans;for (int i = 1; i * i <= diff; i++)if (diff % i == 0) {ans.insert(diff / i);ans.insert(i);}for (set<int>::iterator iter = ans.begin(); iter != ans.end(); iter++)if (*iter > r) printf(" %d", *iter);printf("\n");}}return 0;
}

UVA10880 Colin and Ryan【整除】相关推荐

  1. 群论中的拉格朗日定理(子群的阶必然能整除群阶---数学

    前言:仅个人小记.本文记录的证明逻辑上不具有流畅性,主要是在一开始不流畅,拉格朗日神乎其技地引入了一个等价关系,进而实现了整个定理的证明,目前我没能给出拉格朗日是如何想到引入该等价关系. 最后给出推论 ...

  2. 求未知数X最临近的能被某个数字N整除的数

    求未知数X最近的能被N整除的数:比X大的临近数:Math.ceil(X/N)*N 比X小的临近数:Math.floor(X/N)*N---------------------------------- ...

  3. 杭电2099 整除的尾数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2099 解题思路:将a扩大100倍之后,再给它从加上i(i从0到99),一个一个的看哪一个能整除 反思: ...

  4. 小于60的数中能被1到10整除的数量

    代码: # coding=utf-8 def record1(n,m):for i in range(len(n)):# print('77')print(str(n[i])+"对应的可以整 ...

  5. SDOI2015 约数个数和(莫比乌斯反演经典、双上限整除分块)超详细笔记

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 AcWing 1358. 约数个数和(莫比乌斯反演经典.双上限整除分块) #include <c ...

  6. 【数学专题】整除相关 - 素数

    整理的算法模板合集: ACM模板 目录 Part 6.2.1 素数 P4718 [模板]Pollard-Rho算法 P1075 质因数分解 P2441 角色属性树 P5535 [XR-3]小道消息 题 ...

  7. luogu P3455 [POI2007]ZAP-Queries (莫比乌斯反演 + 整除分块)

    整理的算法模板合集: ACM模板 题目传送门 本题中数据为5e4,我们只需要筛一次5e4就行了. 双倍经验的P4450 双亲数中数据达到了1e6,我们直接筛1e6的莫比乌斯函数有点不可取,因为只有一组 ...

  8. python2.7除法_对python中的float除法和整除法的实例详解

    从python2.2开始,便有两种除法运算符:"/"."//".两者最大区别在: python2.2前的版本和python2.2以后3.0以前的版本的默认情况下 ...

  9. python输入正整数n、求n以内能被17整除的最大正整数_求100之内自然数中最大的能被17整除的数...

    . . 1 求 100 之内自然数中最大的能被 17 整除的数 #include void main() { int i ; for (i=100;i>0;i--) if(i%17--0)bre ...

最新文章

  1. 最高3000元/人 , 助你成为C站红人 !
  2. NAACL | 通过对抗性修改,探究链接预测的鲁棒性和可解释性
  3. 2018 俄罗斯世界杯赛程时间表
  4. ArcEngine数据删除几种方法和性能比较
  5. solaris UFS文件系统 要点
  6. 接口超时后程序还会继续执行嘛_答网友问:分析一段STL程序,并就如何读懂一段程序谈几点感想...
  7. 重要接口—Serializable接口
  8. mkhd中的matrix
  9. TensorFlow CTC
  10. 选择排序算法-C程序设计
  11. Python标准库中的shutil
  12. 绝版经典《Linux与UNIX Shell编程指南》中文文字PDF版
  13. 飞鱼科技2019笔试题
  14. C#怎么调用MATLAB的动态链接库
  15. 如何撰写发明专利申请文件 - 赵烟桥
  16. 【软考系统架构设计师】2015年下系统架构师综合知识历年真题
  17. 中国云计算产业2016年度点评
  18. booting和adbboost
  19. python循环案例:模拟银行ATM存款取款
  20. python-机器学习-决策树算法

热门文章

  1. 2022-03-28 术语MES、WMS
  2. 正版Fiddler下载地址
  3. Flutter 生命周期
  4. r语言c50算法的过程,【机器学习与R语言】5-规则学习算法
  5. linux centos网卡配置,centos网卡配置详解
  6. android firefox x86,Firefox 26桌面版加强安全 移动版支持x86
  7. jquery 操作 input显示或者隐藏
  8. xmapp mysql打不开_XAMPP 的MYSQL无法启动
  9. 移动端vue实现部门结构功能_基于Vue的组织架构树组件
  10. php解析压缩包csv文件,php解析csv文件