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 ...
随机推荐
- Python连接es笔记一之连接与查询es
本文首发于公众号:Hunter后端 原文链接:Python连接es笔记一之连接与查询es 有几种方式在 Python 中配置与 es 的连接,最简单最有用的方法就是定义一个默认的连接,如果系统不是需要 ...
- 【Python&目标识别】调用百度智能云API实现植被识别
百度智能云于2015年正式对外开放运营,以"云智一体"为核心赋能千行百业,致力于为企业和开发者提供全球领先的人工智能.大数据和云计算服务及易用的开发工具.凭借先进的 ...
- 解决log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory). log4j:WARN Please initialize the log4j system properly.警告
1. 问题分析 使用log4j时不起作用,因为找不到配置文件log4j.properties,存在的问题可能是没有配置log4j.properties文件,也可能是配置文件log4j.properti ...
- 关于进程、线程、协程的概念以及Java中的应用
进程.线程.协程 本文将从"操作系统"."Java应用"上两个角度来探究这三者的区别. 一.进程 在我本人的疑惑中,我有以下3个问题. 1.1为什么要引入进程? ...
- 自然语言处理 Paddle NLP - 预训练语言模型及应用
什么是语言理解? 关于疫情的一段对话: 中国:我们这边快完了 欧洲:我们这边快完了 中国:我们好多了 欧洲:我们好多了 挑战: 语言的复杂性和多样性 多义/同义/歧义现象 灵活多变的表达形式 语言背后 ...
- C++ 学习笔记 (一)
C++标准化组织 https://isocpp.org/std/status http://open-std.org/JTC1/SC22/WG21/ why C++王者归来? https://cool ...
- 企业battle宝典Q1 每一个身处于抑郁与困难的朋友必看!
里面有看不懂的可以留言,我会解释!
- 一文解开主流开源变更数据捕获技术之Flink CDC的入门使用
@ 目录 概述 定义 什么是CDC? CDC的分类 特性 应用场景 支持数据源 实战 Flink DataStream方式代码示例 FlinkSQL方式代码示例 概述 定义 flink-cdc-con ...
- PHP检查更新加载本地版本号并解压覆盖
<?phperror_reporting(0);ob_implicit_flush(true);$begin = microtime(true);//检查更新,加载本地版本号$config = ...
- Selenium:设置元素等待、上传文件、下载文件
前言:在工作和学习selenium自动化过程中记录学习知识点,深化知识点 1. 设置元素等待 元素定位之元素等待-- WebDriver提供了两种类型的等待:显示等待和隐式等待. 1.1 显示等待 显 ...