-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpackets.cpp
More file actions
executable file
·43 lines (36 loc) · 778 Bytes
/
packets.cpp
File metadata and controls
executable file
·43 lines (36 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll int maxDivisor(ll int n)
{
ll int _max
// Note that this loop runs till square root
for (ll int i=1; i<=sqrt(n); i++)
{
if (n%i == 0)
{
// If divisors are equal, print only one
if (n/i == i)
{
if(i>=_max)
_max=i;
}
else // Otherwise print both
{
if(i>=_max && i!=n)
_max=i;
if((n/i)>=_max && (n/i)!=n)
_max=(n/i);
}
}
}
return _max;
}
int main(void)
{
ll int n;
cin >> n;
ll int res=maxDivisor(n);
cout << res <<"\n";
return 0;
}