Codeforces Round #465 (Div. 2) A. Fafa and his Company

http://codeforces.com/problemset/problem/935/A

题意:公司有n个人,把人数等分为几个小组。小组里至少一个领导和一个员工。问有几种分法。

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <bits/stdc++.h>
using namespace std;

int main() {
int n;
while (cin >> n) {
// 这种有点Uva的风格,是可以连续输入的。
int res = 0;
for (int i = 1; i <= n / 2; i++) {
if (n % i == 0 && n / i >= 2) {
res++;
}
// 可除尽,且每组人数至少2人。
// n / i >= 2也可以不写,因为n / n 才=1,上一句已经保证n不可能=n。
}
printf("%d\n", res);
}
return !printf("\n");
}