1 |
|
Time Limit: 1000MS | Memory Limit: 65535KB |
Submissions: 187 | Accepted: 75 |
1
1
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 |
#include <iostream> #include <stdio.h> #include <cstring> using
namespace std; int
n,leap; int
vis[12]; void
dfs( int
index, int
num) { if (leap) return
; if (index>n) { leap = 1; cout<<num<<endl; return
; } for ( int
i=1;i<=9;i++) { if (leap) return
; if (!vis[i]&&(num*10+i)%index==0) { vis[i] = 1; dfs(index+1,num*10+i); vis[i] = 0; } } } int
main() { scanf ( "%d" ,&n); memset (vis,0, sizeof (vis)); leap = 0; dfs(1,0); return
0; } |
原文:http://www.cnblogs.com/locojyw/p/3704889.html