特殊数
Time Limit: 1000MS | Memory Limit: 65535KB |
Submissions: 187 | Accepted: 75 |
Sample Input
1
Sample Output
1
#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; }