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~
标签:integers,cnt,interval,题目,int,Interval,Longest,整除,Divisors From: https://www.cnblogs.com/smiling-weeping-zhr/p/17595311.html