#include <bits/stdc++.h>
using namespace std;
int n = 5;
long long sum = 0,total = 0;
int howmany[1000];
void rec(int now) {
if(now == n){
total++;
for (int i = 1; i <= n; i++) {
if (howmany[i] == i) {
sum++;
return;
}
}
return;
}
for (int i = 1;i <= n; i++) {
howmany[i]++;
rec(now + 1);
howmany[i]--;
}
}
int main()
{
cin >> n;
rec(0);
cout << sum << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
7 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
7 ms |
204 KB |
Output is correct |
6 |
Execution timed out |
1085 ms |
204 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
7 ms |
204 KB |
Output is correct |
6 |
Execution timed out |
1085 ms |
204 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |