Luo Gu P1372

Topic background

"Jingle ring ring", a branch junction with the last bell sounded college entrance examination, three youth suddenly solidified in time at the moment. Graduation joy how the enemy that parting of sadness, looking forward to the future not to forget the song still lost. More than 1,000 day and night of laughter and tears, all gather at the graduation party, believe that this must be the most memorable moments of a lifetime!

Title Description

In order to do a better graduation party, I want to pick the greatest teacher of individuals involved in understanding the extent k graduation party dress rehearsal. But how to choose it? The teacher listed the class of the number 1, 2, ......, n, k and I believe understanding the extent of the individual is their greatest common divisor (this is not a superstition oh). This can be difficult for him, please help out!

PS: a number that is the greatest common divisor itself.

Input Format

Two spaces separated positive integers n and k. (N> = k> = 1)

Output Format

An integer value for the maximum understanding.

Sample input and output

Input # 1 copy
42
output copy # 1
2
Description / Tips

[Source] title

Original lzn

【data range】

For 20% of the data, k <= 2, n <= 1000

Another 30% of the data, k <= 10, n <= 100

To 100% of the data, k <= 1e9, n <= 1e9 (Ben God school, large number)

The meaning of problems: seeking the maximum number n takes any value GCD number k.
Ideas: we know that if a multiple relationship between two numbers, then the two numbers GCD is the lesser of the number. So we set a maximum possible value GCD, 1 ~ n in the
take-out number k x1, x2, x3 ... xk and satisfies x1> = a x2> = 2a ... xk> = ka because xk <= n -> a <= n / k is the answer.

#include<iostream>

using namespace std;

long long n,k;

int main()
{
    cin>>n>>k;
    
    cout<<n/k<<endl;
    
    return 0;
}
Published 54 original articles · won praise 0 · Views 1235

Guess you like

Origin blog.csdn.net/weixin_44144278/article/details/98806627