【LightOJ 1136】
发布日期:2021-11-04 12:59:24 浏览次数:5 分类:技术文章

本文共 1050 字,大约阅读时间需要 3 分钟。

Description

There is sequence 1, 12, 123, 1234, …, 12345678910, … . Now you are given two integers A and B, you have to find the number of integers from Ath number to Bth (inclusive) number, which are divisible by 3.

For example, let A = 3. B = 5. So, the numbers in the sequence are, 123, 1234, 12345. And 123, 12345 are divisible by 3. So, the result is 2.

Input

Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each case contains two integers A and B (1 ≤ A ≤ B < 231) in a line.

Output

For each case, print the case number and the total numbers in the sequence between Ath and Bth which are divisible by 3.

Sample Input

2
3 5
10 110
Sample Output
Case 1: 2
Case 2: 67

找规律题~~

#include
int main(){ int T,a,b,nl=1; long long i,ans=0,sum=0; scanf("%d",&T); while(T--) { scanf("%d%d",&a,&b); a--; sum=a/3*2; if(a%3==2) sum++; ans=b/3*2; if(b%3==2) ans++; ans-=sum; printf("Case %d: %lld\n",nl++,ans); } return 0;}

转载地址:https://blog.csdn.net/WYK1823376647/article/details/52325002 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:【codeforces 710 C Magic Odd Square】
下一篇:【LightOJ 1331 】

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年03月28日 15时34分15秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

Python 技术篇-pip安装tar.gz格式的离线资源包 2019-04-27
windows 技术篇-将本地主机加入域的方法实例演示 2019-04-27
Python 图像处理篇-利用opencv库展示本地图片实例演示 2019-04-27
Python 图像处理篇-利用opencv库和numpy库读取包含中文路径下的本地图片实例演示 2019-04-27
oracle 数据回滚,恢复误删的数据,闪回表功能的使用 2019-04-27
mac 系统新功能体验-根据时间变化的动态桌面背景,看壁纸演绎风景大片中的日出与日落 2019-04-27
ADB的安装和使用教程,小米手机连接adb实例演示 2019-04-27
windows 关闭粘滞键-解决Microsoft Remote Desktop输入自动变为快捷键问题 2019-04-27
测试工具 - Postman接口测试入门使用手册,Postman如何进行数据关联、自动更新cookies、简单编程 2019-04-27
PyQt5 技术篇-调用字体对话框(QFontDialog)获取字体,控件设置字体。 2019-04-27
Python 技术篇-将python项目打包成exe独立运行程序,pyinstaller库打包python代码实例演示 2019-04-27
Geany 权限问题:"Error opening file ... : permission denied.",原因及解决办法。 2019-04-27
CSDN博客主页增加赞赏码收钱模块,高端大气上档次! 2019-04-27
PyQt5 技术篇-调用文件对话框获取文件、文件夹路径。文件对话框返回选中的多个文件路径 2019-04-27
SSM 整合实现 增删改查、PageHelper 实现分页 2019-04-27
[增删改查] Lucene 5 索引 CRUD 2019-04-27
使用 SpringBoot 写增删改查接口 2019-04-27
初步使用 JFreeChart 生成报表与感受 2019-04-27
前端使用 BootStrap 写一些后台常用的界面 2019-04-27
使用 SpringBoot + Ckeditor 富文本编辑器、图片上传 2019-04-27