Smiling & Weeping

                    ----总有一个人,

                      一直住在心底,

                      却消失在生活里。

Given a positive integer n, find the maximum size of an interval [l,r] of positive integers such that, for every in the interval (i.e., l≤i≤r), n is a multiple of i.

Given two integers l≤r, the size of the interval [l,r] is r−l+1 (i.e., it coincides with the number of integers belonging to the interval).

题目链接:Problem - B - Codeforces

题目大意:给出一个整数n,求一个区间(要求区间连续,且每个整数都能整除n)

思路:当时这个题目感觉很奇怪,不难但是不好想,例如,若n不能被3整除,那么一定不能被三的倍数整除(也就是说每取出三个连续的数,必有一个不能不符合题意),那么我们就好想通了,直接求从1-n,最多能被多少个连续的数字整除。

Input:

10
1
40
990990
4204474560
169958913706572972
365988220345828080
387701719537826430
620196883578129853
864802341280805662
1000000000000000000

Output:

1
2
3
6
4
22
3
1
2
2

现在是代码时间 ̄へ ̄:Show me Your Code

 1 #include<bits/stdc++.h>
2 using namespace std;
3 int t;
4 typedef long long ll;
5 int main()
6 {
7 scanf("%d",&t);
8 while(t--)
9 {
10 int i = 1;
11 ll num , cnt = 0;
12 scanf("%lld",&num);
13 while(num%i == 0) i++ , cnt++;
14 printf("%lld\n",cnt);
15 }
16 return 0;
17 }

文章到此结束,我们下次再见ヾ( ̄▽ ̄)Bye~Bye~

Longest Divisors Interval的更多相关文章

  1. 【leetcode】1124. Longest Well-Performing Interval

    题目如下: We are given hours, a list of the number of hours worked per day for a given employee. A day i ...

  2. Longest subarray of target sum

    2018-07-08 13:24:31 一.525. Contiguous Array 问题描述: 问题求解: 我们都知道对于subarray的问题,暴力求解的时间复杂度为O(n ^ 2),问题规模已 ...

  3. Milking Cows

    Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The f ...

  4. 【USACO】Milking Cows

    Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer b ...

  5. Contiguous Array with Equal Number of 0 & 1

    2018-07-08 13:24:31 问题描述: 问题求解: 问题规模已经给出是50000量级,显然只能是O(n),至多O(nlogn)的复杂度.本题使用DP和滑动数组都比较棘手,这里给出的方案是p ...

  6. Primes on Interval(二分 + 素数打表)

    Primes on Interval Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u ...

  7. [leetcode] 5.Longest Palindromic Substring-2

    想了很多方法 搞轴对称,算对称轴,偶数都高出了一堆0.5在那加加减减,最后发现在移轴之前可能就返回了. class Solution: def longestPalindrome(self, s: s ...

  8. [leetcode] 5.Longest Palindromic Substring-1

    开始觉得挺简单的 写完发现这个时间超限了: class Solution: def longestPalindrome(self, s: str) -> str: # longest palin ...

  9. 5. Longest Palindromic Substring - Unsolved

    https://leetcode.com/problems/longest-palindromic-substring/#/description Given a string s, find the ...

  10. LeetCode解题报告—— 2 Keys Keyboard & Longest Palindromic Substring & ZigZag Conversion

    1. Longest Palindromic Substring Given a string s, find the longest palindromic substring in s. You ...

随机推荐

  1. 代码随想录算法训练营Day12 栈与队列

    代码随想录算法训练营 代码随想录算法训练营Day12 栈与队列| 239. 滑动窗口最大值  347.前 K 个高频元素  总结 239. 滑动窗口最大值 给定一个数组 nums,有一个大小为 k 的 ...

  2. selenium4-定位组元素

    总体思路:find_elements() 该方法将所有定位到的元素放到一个列表中,再通过列表的下标定位到具体元素. 例1.使用tag name定位到百度搜索框,并输入selenium关键字 servi ...

  3. V8是如何执行JavaScript代码的?

    前言 一般来讲,电脑是不能直接运行我们的javascript代码的,它需要一个翻译程序将人类能够理解的编程语言 JavaScript,翻译成机器能够理解的机器语言.目前市面上有很多种 JavaScri ...

  4. JavaWeb中Servlet、web应用和web站点的路径细节("/"究竟代表着什么)

    JavaWeb中Servlet.web应用和web站点的路径细节("/"究竟代表着什么) 1 开门见山 新建一个tomcat web项目,配置tomcat的虚拟目录,取默认值(/项 ...

  5. PHP处理模板 cookie优先 检测用户登录

    <?php// +----------------------------------------------------------------------// | easy pay [ pa ...

  6. python打包exe总结 pyinstaller py2exe

    Python打包exe 有很多可以用的 如 pyinstaller py2exe cx_Freeze nuitka py2app py0xidizer 其中cx_Freeze没用过 nuitka是把p ...

  7. 精讲Mybatis··#{}和${}

    题目 笔记Notes 面试题目:#{}和${}的区别是什么? 网上的答案是:#{}是预编译处理,${}是字符串替换.mybatis在处理#{}时, 会将sql中的#{}替换为?号,调用Prepared ...

  8. 楠少音乐盒(PC端)突破校园网限制

    楠少音乐盒 突破校园网限制 最近在将音乐盒从web迁移到PC端,过程中的记录 在我们学校,工作时间内(周一至周五为工作日,下午上班时间)校园网都会拦截一些与工作无关的网站,例如购物.炒股.游戏.音乐等 ...

  9. 前端查询天气的html

    <html> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script&g ...

  10. 用git bash 生成 hexo 博客文件,报错node: command not found

    有git bash,也安装了node.js, 为什么在bash里面会说node: command not found? 电脑有段时间不能上网,下载了360系统急救箱,删了很多文件,包括一些exe文件, ...