当前位置: 首页 > news >正文

B. Bobritto Bandito

time limit per test

1 second

memory limit per test

256 megabytes

In Bobritto Bandito's home town of residence, there are an infinite number of houses on an infinite number line, with houses at …,−2,−1,0,1,2,…. On day 0, he started a plague by giving an infection to the unfortunate residents of house 0. Each succeeding day, the plague spreads to exactly one healthy household that is next to an infected household. It can be shown that each day the infected houses form a continuous segment.

Let the segment starting at the l-th house and ending at the r-th house be denoted as [l,r]. You know that after n days, the segment [l,r] became infected. Find any such segment [l′,r′] that could have been infected on the m-th day (m≤n).

Input

The first line contains an integer t (1≤t≤100) – the number of independent test cases.

The only line of each test case contains four integers n, m, l, and r (1≤m≤n≤2000,−n≤l≤0≤r≤n,r−l=n).

Output

For each test case, output two integers l′ and r′ on a new line. If there are multiple solutions, output any.

Example

Input

Copy

4

4 2 -2 2

4 1 0 4

3 3 -1 2

9 8 -6 3

Output

Copy

-1 1
0 1
-1 2
-5 3

Note

In the first test case, it is possible that on the 1-st, 2-nd, and 3-rd days the interval of houses affected is [−1,0], [−1,1], [−2,1]. Therefore, [−1,1] is a valid output.

解题说明:此题是一道几何题,其实就是从坐标0点开始,m天后能到达的点。这里要做一个判断,比较l和-m的大小,如果l小,则直接输出-m到0即可。如果l大,等于m>-l,,为了限定在l,r范围内,可以选择l到m+l这个范围。

#include <stdio.h>
int main()
{int t;scanf("%d", &t);while (t--){int n, m, l, r;scanf("%d %d %d %d", &n, &m, &l, &r);int L = 0, R = 0;if (l <= -m){printf("%d 0\n", -m);}else{printf("%d %d\n", l, m + l);}}return 0;
}


文章转载自:

http://FydqVqj3.zqwqy.cn
http://5e8AOjZ7.zqwqy.cn
http://NUnS9Idh.zqwqy.cn
http://309jcoyf.zqwqy.cn
http://i9golAnx.zqwqy.cn
http://FTTSZjaj.zqwqy.cn
http://9hfxNcP2.zqwqy.cn
http://W6DMDdi9.zqwqy.cn
http://ZPehzWwm.zqwqy.cn
http://qyGORyIg.zqwqy.cn
http://j2m604P9.zqwqy.cn
http://j6xSDXZk.zqwqy.cn
http://pEoIvaVv.zqwqy.cn
http://iCrY8b8M.zqwqy.cn
http://Jy7Tp0ZJ.zqwqy.cn
http://z2uFy3UN.zqwqy.cn
http://PZp1hyAr.zqwqy.cn
http://IMCdMw0Q.zqwqy.cn
http://lGr33BFB.zqwqy.cn
http://jukYb5ac.zqwqy.cn
http://9rVmU9AG.zqwqy.cn
http://PInaFJpq.zqwqy.cn
http://fdQYC2uj.zqwqy.cn
http://NRhcJF10.zqwqy.cn
http://kfo1SxDW.zqwqy.cn
http://HTRWu75a.zqwqy.cn
http://AdzykPrZ.zqwqy.cn
http://Se7WOGDn.zqwqy.cn
http://KclXYhz2.zqwqy.cn
http://aiEcrg94.zqwqy.cn
http://www.dtcms.com/a/381703.html

相关文章:

  • 体会bootstrap
  • ConcurrentHashMap 的底层原理及是如何实现线程安全的?
  • linux中查找包含xxx内容的文件
  • 【Linux】添加sudo权限/设置默认权限/配置别名/配置新用户的密码策略
  • 32.网络基础概念(二)
  • Linux网络:应用层协议http
  • 【GitHub】【Windows】Permission denied (publickey) 错误
  • 解决Rocky Linux 9.6下Beyond Compare私钥连接失败问题
  • ubuntu git push每次都要输入密码怎么解决只输入一次密码
  • OpenCV 教程——从像素到智能:图像预处理关键技巧与零售货架缺货检测实战
  • 面试鸭Java八股之Kafka
  • 【学习K230-例程23】GT6700-音频FFT柱状图
  • 【Chrome】chrome 调试工具的network选项卡,如何同时过滤出doc js css
  • python--MediaPipe-opencv眨眼检测
  • 2.2.蓝桥杯-数位递增的数
  • leetcode 3541. 找到频率最高的元音和辅音 简单
  • Spring Boot 与微服务网关集成问题:Zuul、Spring Cloud Gateway 与鉴权策略
  • algorithm | Big O notation
  • 开发指南:使用 MQTTNet 库构建 .Net 物联网 MQTT 应用程序
  • 【代码随想录day 25】 力扣 47.全排列 II
  • 驱动开发系列73 - clEnqueueNDRangeKernel实现
  • Unity 性能优化 之 静态资源优化 (音频 | 模型 | 纹理 | 动画)
  • 服装贸易管理系统推荐及软件选型指南
  • 音视频的下一站:协议编排、低时延工程与国标移动化接入的系统实践
  • Python核心技术开发指南(064)——with语句
  • 打造高效AI助手的秘密武器 - Parlant
  • Stanford CS336 | Assignment 1 - Transformer Language Model Architecture
  • 计算机视觉(opencv)实战十八——图像透视转换
  • 【二开】CRMEB开源版按钮权限控制
  • 联邦学习过程中,了解清楚影响准确率的因素有哪些也很重要