-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiv_olp.cpp
More file actions
55 lines (49 loc) · 1.04 KB
/
Copy pathDiv_olp.cpp
File metadata and controls
55 lines (49 loc) · 1.04 KB
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
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
/*
Trong gio toan hoc o truong hoc ve tinh chat chia het cua cac so.De dien giai ve tinh chia het,
giao vien viet len bang cac so nguyen tu 1->N vao cac nhom rieng biet.Trong do neu mot so ma chia het cho
so khac thi 2 so do phai nam o hai nhom khac nhau.vi du: N = 10, ta co 4 nhom:
N1: 1
N2: 2,7,9
N3: 3,4,10
N4: 5,6,8
vi rang moi so dieu chia het cho 1 ne luon co mot nhom chi chua so 1.nhung cac nhom con lai co the phan theo
nhieu cach khac nhau.Ban can chi ra so luong it nhat cac nhom sao cho co the phan chia cac so tu 1 den N theo
cach giao vien toan.
Dau vao: so nguyen duong N< 10^5, dau ra: so nhom it nhat.
vi du
input: 10
output: 4
*/
using namespace std;
int countDiv(int n)
{
int count =1;
for(int i =2;i<=n;++i)
{
if(n%i==0)
{
count++;
}
}
return count;
}
void maxDiv(int n)
{
int temp =0;
while(n){
temp = max(temp,countDiv(n));
n--;
}
cout<<temp;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
// maxDiv(n);
cout<<countDiv(n);
return 0;
}