HDU4731+找规律

来源:互联网 发布:java内存溢出解决方法 编辑:IT博客网 时间:2020/02/25 13:10

规律题!!!

/**/#include<algorithm>#include<iostream>#include<string.h>#include<stdlib.h>#include<stdio.h>#include<math.h>#include<queue>#include<stack>#include<map>#include<set>using namespace std;typedef long long int64;//typedef __int64 int64;typedef pair<int64,int64> PII;#define MP(a,b) make_pair((a),(b)) const int inf = 0x3f3f3f3f;const double pi=acos(-1.0);const int dx[]={1,-1,0,0};const int dy[]={0,0,1,-1};const double eps = 1e-8;const int maxm = 1005;const int maxn = 100005;char ans[ maxn ];int main(){    int T;    scanf("%d",&T);    int Case = 1;    while( T-- ){        int n,m;        scanf("%d%d",&n,&m);        printf("Case #%d: ",Case ++ );        if( min(n,m)>=3 ){            int cnt = 0;            for( int i=0;i<m;i++ ){                if( cnt==0 ) printf("a");                else if( cnt==1 ) printf("b");                else printf("c");                cnt ++ ;                if( cnt>=3 ) cnt = 0;            }            printf("\n");        }        else if( n==1 ){            for( int i=0;i<m;i++ )                printf("a");            printf("\n");        }        else if( n==2 ){            if( m==1 ) printf("a\n");            else if( m==2 ) printf("ab\n");            else {                if( m==3 ) printf("aab\n");                else if( m==4 ) printf("aabb\n");                else if( m==5 ) printf("aaaba\n");                else if( m==6 ) printf("aaabab\n");                else if( m==7 ) printf("aaababb\n");                else if( m==8 ) printf("aaababbb\n");                else if( m>=9 ){                    printf("aa");                    int len = 2;                    while( 1 ){                        if( len+6<=m ){                            printf("aababb");                            len += 6;                        }                        else {                            if( len+1==m ) printf("a");                            else if( len+2==m ) printf("aa");                            else if( len+3==m ) printf("aab");                            else if( len+4==m ) printf("aaba");                            else if( len+5==m ) printf("aabab");                            else printf("aababb");                            break;                        }                    }                    printf("\n");                }            }//        }        else if( m==1 ){            printf("a\n");        }        else if( m==2 ){            if( n==1 ) printf("aa\n");            else printf("ab\n");        }            }    return 0;}