Number (Standard IO)

本文探讨了一种通过特定数学操作使整数变为1000000007倍数的方法。通过定义两种操作(将x变为4x+3和8x+7),文章提出了一种算法来确定达到目标所需的最小步骤。

题意/Description:

       给出一个整数 ,你可以对 进行两种操作。
  1、将x变成4x+3
  2、将x变成8x+7
  问,最少通过多少次操作,使得x是1000000007的倍数?


读入/Input

        一行,一个整数x(1<=x<=1000000006)。


输出/Output

      一行,表示最少的操作步数。保证答案不超过10^5。


题解/solution

       画画的时候,发现(4x+3)的3次方等于(8x+7)的二次方。于是就想到它们的一次方是什么......(2x+1)。之后自己做吧。(考完才想到)


代码/Code

const
  mo=1000000007;
var
  a:int64;
  i:real;
begin
  readln(a);
  while a mod mo<>0 do
    begin
      i:=i+1;
      a:=a*2+1;
      a:=a mod mo;
    end;
  i:=i/3;
  if trunc(i)<>i then writeln(trunc(i)+1)
                 else writeln(trunc(i));
end.


### RK3568 IO Pull-Up and Pull-Down Configuration For configuring the pull-up or pull-down resistors on the IO pins of an RK3568 chip, one must interact with specific registers that control these functionalities. The process involves setting bits within certain register addresses to enable either a pull-up or pull-down resistor for each pin. The configuration typically requires including necessary header files relevant to the hardware abstraction layer (HAL) provided by Rockchip for the RK3568 platform. Although not directly related to BL808 GPIO configurations mentioned previously[^1], similar principles apply when dealing with different SoCs like RK3568 where HAL libraries offer functions to manipulate GPIO settings easily. To configure the IOs: ```c #include "rk_gpio.h" // Initialize GPIO as output mode. gpio_direction_output(GPIO_PORT, PIN_NUMBER); // Set pull up/down resistance. if (PULL_UP == direction){ gpio_set_pull_up_down(GPIO_PORT, PIN_NUMBER, PULL_UP); } else { gpio_set_pull_up_down(GPIO_PORT, PIN_NUMBER, PULL_DOWN); } ``` In this code snippet, `GPIO_PORT` represents which port you are working with while `PIN_NUMBER` specifies the exact pin number inside that particular port. Functions such as `gpio_direction_output()` set the direction of the pin whereas `gpio_set_pull_up_down()` configures whether it should be pulled high (`PULL_UP`) or low (`PULL_DOWN`). Note how these operations align closely with standard practices seen across various microcontroller platforms but tailored specifically towards RK3568's architecture and its associated software development kit (SDK).
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值