标签:des style http color os io strong 数据
4 2 3 1 1 3 2 1 0 1 1 1 1 1 1 1 1 3 2 1 1 3 1 1 2 1 0 1 1 1 2 1 3 0
Case #1: 1 3 2 0
可以抽象为10进制找到规律,输入输出数据太多,需要用到输入挂,否则会T
#include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <set> #include <vector> #include <algorithm> #define maxn 510 using namespace std; int mark[maxn]; void read(int &a) { int t; while (t = getchar(), isspace(t)); a = t - '0'; while (t = getchar(), !isspace(t)) a = a * 10 + t - '0'; } int mk[maxn],cnt[maxn],get_zero[maxn]; int main() { //freopen("1007.in","r",stdin); //freopen("data.out","w",stdout); int n; int cas=0; while (~scanf("%d",&n)) { for(int i=0;i<n;i++) { cnt[i]=0; } if(n==0) break; int tp,tp2; printf("Case #%d:",++cas); for(int i=0;i<n;i++) { int bl=0; memset(mk,-1,sizeof(mk)); for(int j=0;j<n;j++) { read(tp);read(tp2); //scanf("%d %d",&tp,&tp2); if(mk[tp]!=tp){ cnt[i]++; mk[tp]=tp; } if(mk[tp2]!=tp2) { bl=1; } } if(!bl&&cnt[i]==1) { cnt[i]=0; } } for(int i=0;i<n;i++) { // printf("%d\n",cnt[i]); mark[cnt[i]]=i; } for(int i=0;i<n;i++) { printf(" %d",mark[i]); } puts(""); } return 0; }
HDU 4951 Multiplication table 数论,布布扣,bubuko.com
HDU 4951 Multiplication table 数论
标签:des style http color os io strong 数据
原文地址:http://blog.csdn.net/alpc_paul/article/details/38579809