zoukankan      html  css  js  c++  java
  • UVA 1594 set 里面放queue

    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    #include<string>
    #include<queue>
    #include<set>
    #include<vector>
    #define maxn 20
    using namespace std;
    typedef queue<int> Q;
    int main(){
        set<Q> se;
        int t,n,a[maxn],flag=1,ff[maxn],nn=0;
        scanf("%d",&t);
        while(t--){
        nn=0;
        flag=1;
        scanf("%d",&n);
        Q q;
        se.clear();
        memset(a,0,sizeof(a));
        memset(ff,0,sizeof(ff));
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
            if(a[i]==0) nn++;
            q.push(a[i]);
        }
        if(nn==n){
            printf("%s
    ","ZERO");
            flag=0;
        }
        se.insert(q);
    
        while(flag==1){
        int f=q.front(),m,b;
        int x=f;
        q.pop();
        int j=0;
        for(int i=1;i<n;i++){
            m=q.front();
            q.pop();
            b=abs(f-m);
            q.push(b);
            ff[j++]=b;
            f=m;
        }
        q.push(abs(x-f));
        ff[j++]=abs(x-f);
        if(!se.count(q)){se.insert(q);}
        else{
            printf("%s
    ","LOOP");
            flag=0;
        }
    
         nn=0;
        for(int k=0;k<j;k++){
            if(ff[k]==0) nn++;
        }
        if(nn==n) {
            printf("%s
    ","ZERO");
            flag=0;
        }
    
    
        }
       }
      return 0;
    }
  • 相关阅读:
    课程总结第十一周
    用户场景分析
    团队冲刺10
    课程总结第十周
    团队冲刺09
    梦断代码阅读笔记03
    转发和重定向的区别
    request
    servletConfig
    servlet
  • 原文地址:https://www.cnblogs.com/wintersong/p/5059847.html
Copyright © 2011-2022 走看看