LightOJ 1136 Division by 3 (想法题)

西电微机系统课程设计步进电机开环控制系统 ** 微机系统与应用课程设计 课题二 步进电机开环控制系统设计** 一、程设计目的 掌握微机系统总线与各芯片管脚连接方法,提高接口扩展硬件电路的连接能力。 加深对 A/D 和并行接口芯片的工作方式和编程方法的理解。 搞懂步进电机的工作原理及控制方式,掌握开环控制系统的设计思路和实现方法。 二、课程设计的内容 手动调节电位器旋钮(0V~5V),通过 ADC0809 模拟输入水库水位 0 米~50... 阅读详情

http://www.lightoj.com/volume_showproblem.php?problem=1136


开始打算解二次同余的,算了一会发现有很多解。。-->转而分析序列结构。

分析发现:

连续三个整数并排在一起组成的数的数字和必然能被3整除。(x+x+1+x+2=3x+3=3(x+1))

从而有:

1.题目中的第3k个数,必然能被三整除。

2. 题目中的第3k + 1个数,其第2个数字到最末一个数字之和必然能被3整除,再加上第一个数字,也就是1,就不能被3整除了。

3. 题目中的第3k + 2个数,其第3个数字到最末一个数字之和必然能被3整除,再加上第一、二个数字,也就是1 + 2 = 3,也能被3整除。

所以1~k中能被3整除的有2k/3+(k%3==2?1:0)个


完整代码:

/*0.008s,1088KB*/

#include<cstdio>
typedef unsigned int ll;

ll calc(ll k)
{
	return k / 3 * 2 + (k % 3 == 2 ? 1 : 0);
}

int main()
{
	int t, cas = 0;
	ll a, b;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%u%u", &a, &b);
		printf("Case %d: %u\n", ++cas, calc(b) - calc(a - 1));
	}
	return 0;
}

代付系统/代付系统源码/支付宝代付系统/API代付系统 简介: 其他站买的,没有做测试,源码是JAVA的,附带了安装文档,需要的拿无售后 源码下载地址https://www.skpan.cn/2QnIARSZDxG 代付系统/代付系统源码/支付宝代付系统/API代付系统 系统流程: 后台开通代理——开通商户——商户做代付(后台手工提交和 api 提交两种方式) 1、纯代付系统 2、支持个人支付宝全自动 3、支持单笔/批量/API接口方式代付 4、支持白名单、谷歌验证 5、收付款模式采用自动回调/自动转账 一、运营平台 商户管. 阅读详情

相关推荐

WRF后处理避坑指南:从namelist配置到降水计算的全流程解析

本文提供了一份详尽的WRF模式后处理避坑指南,涵盖从理解wrfout文件结构、核心变量解析到累计降水计算与专业气象图绘制的全流程。重点解析了RAINC与RAINNC的正确处理方法,并分享了使用wrf-python库高效绘制位势高度叠加风场图、累计降水图等专业图表的实战技巧与代码,旨在帮助用户规避常见错误,提升后处理效率与图表质量。

weixin_29200485的博客 353

1136 - Division by 3

题意: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...

bancaidun1539的博客 376

【WB32库开发】第9章 TIM1高级定时器——输出多路PWM

PWM(Pulse Width Modulation)意为脉冲宽度调制,简称脉宽调制 。在工控行业,PWM信号可以用来调节电机转速、调节变频器以及BLDC电机驱动等;在LED照明行业,可以通过PWM来控制LED的亮暗变化;还可以通过PWM信号来控制无源蜂鸣器发出简单的声音等。 WB32也可输出PWM,需配置WB32上的定时器。 在WB32中有4个定时器,其中TIM1为高级定时器,TIMx(2-4)为通用定时器,这四个定时器均挂载在APB1总线上,每个定时器都可以输出4路PWM。 本章需要使用固件库TIM例程

北海村夫的博客 4637

1136 mysql_MySQL错误:Error Code: 1136

我有一张数据表,表结构如下:CREATE TABLE IF NOT EXISTS `icy_car` (`car_id` bigint(20) NOT NULL AUTO_INCREMENT,`car_type` varchar(50) DEFAULT NULL COMMENT '车型代码',`car_brand` varchar(50) DEFAULT NULL COMMENT '品牌',`ca...

weixin_34489345的博客 1万+

全志 mipi屏幕和触摸驱动调试记录

mipi屏幕与触摸调试记录

u011996684的博客 3219

别再调PID了!用MATLAB/Simulink给四旋翼无人机搭个ADRC控制器(附完整仿真模型)

本文详细介绍了在MATLAB/Simulink环境中为四旋翼无人机搭建ADRC控制器的完整流程,包括核心原理、Simulink建模、参数调试技巧及与PID控制的性能对比。ADRC通过扩张状态观测器(ESO)有效提升无人机在复杂扰动下的控制性能,特别适合四旋翼无人机这类强耦合系统。文章还提供了完整的仿真模型和工程实践问题解决方案。

weixin_26808439的博客 382

LightOJ 1136 Division by 3 水题

题目:http://www.lightoj.com/volume_showproblem.php?problem=1136 题意:有序列1,12,123,...12345678910,1234567891011...,问序列中从第a个到第b个有多少个数能被3整除 思路:手算一下可以发现规律:每三个数为一组,每组中第一个数不被3整除,第二三个数可以被整除。于是可以把a向前移动到一组的开端,把b向

弱智就要多努力 619

手把手教您解决 AdGuard Home DNS重写功能失效的问题

AdGuard Home 设置了 DNS 重写,规则明明没问题,客户端却死活解析不到内网 IP?🤯 别急着重装!🚫 本文手把手教你如何解决软路由 DNS 解析“玄学”故障!🛠️🚀

XiaoqiangClub的博客 919

【LightOJ】1136 - Division by 3(规律)

点击打开题目 1136 - Division by 3     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB There is sequence 1, 12, 123, 1234, ..., 123456

wyg1997 1128

利用XGBoost实现短期电力负荷预测

本数据集为某地区2009年-2015年的用电负荷,时间片为每分钟这里我们定义了XGB模型作为实例,来进行模型训练,之后我们会对其使用网格搜索找到最优的参数。

优快云 精品推荐 4495

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Lightoj [基础题系列] 1136 - Division by 3

攻克lightoj基础题系列        给你两个数(在本题中5代表的数是12345为1到五的等差数列,其他数也如此),求两个数之间三的倍数的数的个数,明显的暴力超时,但规律易得,每三个数内都有两个数为三的倍数,把情况讨论一下就可以了。#include <iostream> #include <cstdio> using namespace std;int main() { int t

CodeTank 831

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

LightOJ 1136 - Division by 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

lu_1110的博客 994

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Lightoj1136——Division by 3(数学+规律)

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 divisi

qq_35634181的博客 724

LightOJ - 1136 Division by 3(思维)(找规律)

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 b...

Nerdant 786

LightOJ 1136 Division by 3

#include using namespace std; int main(){ int A, B, T; int caseNo = 0; cin >> T; while(T--){ int count = 0; cin >> A >> B; count = (B - A + 1) / 3 * 2; if((B - A + 1) / 3 * 3 == B - A -

z3635363的专栏 1059

lightoj-1136 - Division by 3【思维】【找规律】

题目链接:点击打开链接 1136 - Division by 3     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB There is sequence 1, 12, 123, 1234, ..., 123

_Somethingwill 721

LightOJ 1136 - Division by 3

1136 - Division by 3     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB There is sequence 1, 12, 123, 1234, ..., 12345678910, ... .

Calm微笑 447

LightOJ 1136 Division by 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 fromAth number to Bth (inclusive) number, w

昨日明眸 783

A - Division by 3 LightOJ - 1136【思维】【找规律】

A - Division by 3  LightOJ - 1136 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 numbe

qq_38465092的博客 316

(LightOJ - 1136 )Division by 3

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 divis

HPU留白的博客 394

lightoj(1136 - Division by 3 )规律

There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Nowyou are given two integers A and B, you have to find the numberof integers from Ath number to Bth (inclusive)number, which are divisibl

Pig_cfbsl的博客 855

Lightoj1136——Division by 3(数学)

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 divisi

Beyond the Sora 608

【LightOJ 1136】Division by 3(简单数学)

BUPT2017 wintertraining(16) #5 C HDU - 1021 题意 1, 12, 123, 1234, ..., 12345678910, ... 问第a到第b个数(inclusive)里有几个可以被3整除。 题解 前几项的各位数之和对3取模,可以找到规律——余数是1,0,0,1,0,0,1,0,0,1...。也就是每三个数有两个可被3整除。 代码 #include &l...

weixin_33852020的博客 111

POJ 2559 / HDU 1506 / LightOJ 1083 Largest Rectangle in a Histogram (单调栈)

Largest Rectangle in a Histogram http://poj.org/problem?id=2559 Time Limit: 1000MS Memory Limit: 65536K Description A histogram is a polygon composed of a sequence of rectangles ali

AC,∑ndless 1991

LightOJ 1258 Making Huge Palindromes (回文&KMP)

http://lightoj.com/volume_showproblem.php?problem=1258 首先原串+翻转过来的串必然是一个回文串,但是二者在中间可以“融合”,而KMP算法恰好可以求出最大融合长度。 所以看翻转过来的串能匹配多少原串即可,答案就是len+(len-匹配个数)。 完整代码: /*0.140s,7548KB*/ #include usin

AC,∑ndless 1926
上一篇: UVa 10277 Boastin' Red Socks (枚举)
下一篇: UVa 306 / POJ 1026 / Central Europe 1995 Cipher (置换群)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值