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 ...
随机推荐
- redis.conf 7.0 配置和原理全解,生产王者必备
5.5 redis.conf 配置详解 我是 Redis, 当程序员用指令 ./redis-server /path/to/redis.conf 把我启动的时候,第一个参数必须是redis.conf ...
- < Python全景系列-9 > Python 装饰器:优雅地增强你的函数和类
欢迎来到我们的系列博客<Python全景系列>第九篇!在这个系列中,我们将带领你从Python的基础知识开始,一步步深入到高级话题,帮助你掌握这门强大而灵活的编程语法.无论你是编程新手,还 ...
- “AI Earth”人工智能创新挑战赛:助力精准气象和海洋预测Baseline[1]、NetCDF4使用教学、Xarray 使用教学,针对气象领域.nc文件读取处理
1."AI Earth"人工智能创新挑战赛:助力精准气象和海洋预测Baseline[1].NetCDF4使用教学.Xarray 使用教学,针对气象领域.nc文件读取处理 比赛官网: ...
- 使用C语言实现简单的通用的链表
在数据结构中,我们已经学习到了简单的静态链表以及单链表和双链表,它们各有优缺点,但是有个共同的问题是他们呢无法存储不同的数据.下面提供了一种方法,可以将不同节点的数据链接起来. 下面的代码都是基础的C ...
- ChatGPT在工业领域的研究与应用探索-AI助手实验应用
为什么我的工作效率和质量要比其他人要高,因为我的电脑里有代码库.产品库.方案库.自己工作经验资料库等,根据一个应用场景或需求能够很快关联到想要的资料,并且整合成新的方案.我的核心竞争力是什么?各种资料 ...
- Neo4J 图库的集群部署与基础使用
Ned4J 图库的集群部署与基础使用 部署机器 名称 配置 IP server1 8 核 16G 172.16.0.2 server2 8 核 16G 172.16.0.3 server3 8 核 1 ...
- 生成式预训练Transformer在机器翻译中的应用与挑战
目录 1. 引言 2. 技术原理及概念 3. 实现步骤与流程 4. 应用示例与代码实现讲解 5. 优化与改进 6. 结论与展望 机器翻译是人工智能领域的重要应用之一,而生成式预训练Transforme ...
- IcedID恶意文档钓鱼手法剖析
析 利用oletools静态分析,提取宏代码,如图: Function contents() With ActiveDocument.Content.Find loveDoor = .Execute( ...
- JWT解析详解
JWT解析详解:> https://www.fke6.com/html/77107.html
- Google Colab:云端的Python编程神器
Google Colab,全名Google Colaboratory,是Google Research团队开发的一款云端编程工具,它允许任何人通过浏览器编写和执行Python代码.Colab尤其适合机 ...