标签:color height pad view cas tle print weight rip
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 200 Accepted Submission(s): 64
#include <stdio.h> #include <algorithm> #include <string.h> #include <math.h> using namespace std; typedef long long LL; const int N = 2016; int s,n; int graph[N][N]; int linker[N]; bool vis[N]; bool dfs(int u){ for(int i=1;i<=n;i++){ if(graph[u][i]==1&&!vis[i]){ vis[i] = true; if(linker[i]==-1||dfs(linker[i])){ linker[i] = u; return true; } } } return false; } int main() { int t = 1,tcase; scanf("%d",&tcase); while(tcase--){ scanf("%d%d",&s,&n); if(s<n) swap(s,n); if(n>1000) { printf("Case #%d: No\n",t++); continue; } memset(graph,0,sizeof(graph)); int res = 0; for(int i=1;i<=n;i++){ int t = i+s; for(int j=1;j<=n;j++){ if(t%j==0) { graph[i][j] = 1; } } } memset(linker,-1,sizeof(linker)); for(int i=1;i<=n;i++){ memset(vis,0,sizeof(vis)); if(dfs(i)) res++; } if(res==n){ printf("Case #%d: Yes\n",t++); }else printf("Case #%d: No\n",t++); } return 0; }
标签:color height pad view cas tle print weight rip
原文地址:http://www.cnblogs.com/liyinggang/p/6012611.html