您的位置:首页 >滚动 >

环球新资讯:Leetcode 2549. Count Distinct Numbers on Board

2023-01-29 11:58:09    来源:哔哩哔哩

You are given a positive integer n, that is initially placed on a board. Every day, for 109days, you perform the following procedure:


(相关资料图)

For each number xpresent on the board, find all numbers 1 <= i <= nsuch that x % i == 1.

Then, place those numbers on the board.

Return the number of distinct integers present on the board after 109days have elapsed.

Note:

Once a number is placed on the board, it will remain on it until the end.

%stands for the modulo operation. For example, 14 % 3is 2.

Example 1:

Input: n = 5Output: 4Explanation: Initially, 5 is present on the board. The next day, 2 and 4 will be added since 5 % 2 == 1 and 5 % 4 == 1. After that day, 3 will be added to the board because 4 % 3 == 1. At the end of a billion days, the distinct numbers on the board will be 2, 3, 4, and 5.

Example 2:

Input: n = 3Output: 2Explanation: Since 3 % 2 == 1, 2 will be added to the board. After a billion days, the only two distinct numbers on the board are 2 and 3.

Runtime: 0 ms, faster than 100.00% of Java online submissions for Count Distinct Numbers on Board.

Memory Usage: 38.9 MB, less than 85.71% of Java online submissions for Count Distinct Numbers on Board.

关键词: DAYS Java DISTINCT INITIALLY

相关阅读

精彩放送

CFTC商品持仓解读:投机者提高美国原油净多头头寸|环球观热点

国家税务总局:春节假期旅行社及相关服务业销售收入同比增长1.3倍|世界快消息

复合碳源商品报价动态(2023-01-27)|环球快消息

天天即时:去年巴彦淖尔市农产品出口值创新高

看懂这4只狗和4段爱情,你就看懂了《无名》 新视野

四川泸定发生5.6级地震!震区及周边移动网络运行正常

今日聚焦!春节假期出行需求释放 杭州景区持续升温酒店火热

环球热头条丨吉林省造老银元价格(2023年01月25日)

天天即时:去年巴彦淖尔市农产品出口值创新高

看懂这4只狗和4段爱情,你就看懂了《无名》 新视野

四川泸定发生5.6级地震!震区及周边移动网络运行正常

今日聚焦!春节假期出行需求释放 杭州景区持续升温酒店火热

环球热头条丨吉林省造老银元价格(2023年01月25日)

《命运逆转手作第二季冬季卷》第二章 意外穿越的美穗

环球今热点:台湾的传统节日_台湾节日习俗

暗流涌动!北京2队或同时换帅,解立彬失去权威,八一名宿成绩差_焦点滚动

【环球时快讯】(新春走基层)六旬台商在长春八过除夕:他乡变家乡

只是点燃引线?专访焰火导演黄成:7年没回家过年,春节期间要办40场烟花秀,是“给天空绘...