Longest Divisors Interval
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).
题目大意:给出一个整数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的更多相关文章
- 【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 ...
- Longest subarray of target sum
2018-07-08 13:24:31 一.525. Contiguous Array 问题描述: 问题求解: 我们都知道对于subarray的问题,暴力求解的时间复杂度为O(n ^ 2),问题规模已 ...
- Milking Cows
Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The f ...
- 【USACO】Milking Cows
Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer b ...
- Contiguous Array with Equal Number of 0 & 1
2018-07-08 13:24:31 问题描述: 问题求解: 问题规模已经给出是50000量级,显然只能是O(n),至多O(nlogn)的复杂度.本题使用DP和滑动数组都比较棘手,这里给出的方案是p ...
- Primes on Interval(二分 + 素数打表)
Primes on Interval Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u ...
- [leetcode] 5.Longest Palindromic Substring-2
想了很多方法 搞轴对称,算对称轴,偶数都高出了一堆0.5在那加加减减,最后发现在移轴之前可能就返回了. class Solution: def longestPalindrome(self, s: s ...
- [leetcode] 5.Longest Palindromic Substring-1
开始觉得挺简单的 写完发现这个时间超限了: class Solution: def longestPalindrome(self, s: str) -> str: # longest palin ...
- 5. Longest Palindromic Substring - Unsolved
https://leetcode.com/problems/longest-palindromic-substring/#/description Given a string s, find the ...
- 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 ...
随机推荐
- ODOO之四Odoo 13 开发之模块继承
Odoo 的一个强大功能是无需直接修改底层对象就可以添加功能.这是通过其继承机制来实现的,采取在已有对象之上修改层来完成.这种修改可以在不同层上进行-模型层.视图层和业务逻辑层.我们创建新的模块来做出 ...
- 为什么说 Go 语言字符串是不可变的?
原文链接: 为什么说 Go 语言字符串是不可变的? 最近有读者留言说,平时在写代码的过程中,是会对字符串进行修改的,但网上都说 Go 语言字符串是不可变的,这是为什么呢? 这个问题本身并不困难,但对于 ...
- 高级程序员和新手小白程序员区别你是那个等级看解决bug速度
IT入门深似海 ,程序员行业,我觉得是最难做的.加不完的班,熬不完的夜. 和产品经理,扯不清,理还乱的宿命关系 一直都在 新需求-做项目-解决问题-解决bug-新需求 好像一直都是这么一个循环.(哈哈 ...
- tryhackem_wonderland
涉及,解密,扫描,横向移动,纵向移动 仙境 掉进兔子洞,进入仙境. 获得shell 解法一: 目录扫描 ffuf -u http://10.10.134.189/FUZZ -w /usr/share/ ...
- Python自动化测试面试题精选(一)
Python自动化测试面试题精选 今天由勇哥给你介绍一些Python自动化测试中常见的面试题,涵盖了Python基础.测试框架.测试工具.测试方法等方面的内容,希望能够帮助你提升自己的水平和信心. 项 ...
- [ARM汇编]计算机原理与数制基础—1.1.1计算机的基本原理
计算机是一种能够根据指令集自动.高速处理数据的现代化设备.它的基本原理可以总结为:输入.存储.处理和输出数据.接下来,我们将详细介绍这些基本原理. 输入 计算机通过输入设备(如键盘.鼠标等)接收外部数 ...
- 使用 Sa-Token 实现 [记住我] 模式登录、七天免登录
一.需求分析 如图所示,一般网站的登录界面都会有一个 [记住我] 按钮,当你勾选它登录后,即使你关闭浏览器再次打开网站,也依然会处于登录状态,无须重复验证密码: 本文将详细介绍在 Sa-Token中, ...
- 前端Vue自定义加载中loading加载结束end组件 可用于分页展示 页面加载请求
前端Vue自定义加载中loading加载结束end组件 可用于分页展示 页面加载请求, 请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=132 ...
- httpx的两个坑(httpx.ReadTimeout; SSL: CERTIFICATE_VERIFY_FAILED)
关于python异步网络请求库httpx的两个坑 其一:httpx.ReadTimeout 实测发现,网络不稳定的情况下,极其容易出现该错误. 相对于requests库, httpx库是有默认的超时时 ...
- 1 opencv-python图像读写模块
这个分类记录自己学习opencv的随笔文档,方便以后查询和复习.python-opencv环境配置网上教程很多,此处就不做赘述了,该文档记录opencv最基础的图像读写和显示,工具是jupyter n ...