zoukankan      html  css  js  c++  java
  • HDU 3783

    读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的仍然按照ZOJ的顺序输出。

    MY:(OUTPUT LIMIT EXCEED)

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<cstring>
     4 #include<ctime>
     5 #include<algorithm>
     6 #include<cmath>
     7 //#include<stack>
     8 #define R(a,b,c) for(register int (a)=(b);(a)<=(c);++(a))
     9 #define nR(a,b,c) for(register int (a)=(b);(a)>=(c);--(a))
    10 #define Ii inline int
    11 #define Il inline long long
    12 #define Iv inline void
    13 #define Id inline double
    14 #define Ib inline bool
    15 #define ll long long
    16 #define re register
    17 #define Fill(a,b) memset((a),(b),sizeof((a)))
    18 #define Cmax(a,b) ((a)=(a)>(b)?(a):(b))
    19 #define Cmin(a,b) ((a)=(a)<(b)?(a):(b))
    20 #define D_e(x) printf("&_____%d______&",x);
    21 #define D_e_Line printf("
    -----------------
    ");
    22 #define Pause system("pause")
    23 using namespace std;
    24 //const int N=100001;
    25 //const int M=500001;
    26 Ii read(){
    27     int s=0,f=1;char c;
    28     for(c=getchar();c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
    29     while(c>='0'&&c<='9')s=s*10+(c^'0'),c=getchar();
    30     return s*f;
    31 }
    32 Iv print(int x){
    33     if(x<0)putchar('-'),x=-x;
    34     if(x>9)print(x/10);
    35     putchar(x%10^'0');
    36 }
    37 int main(){
    38     string s;
    39     while(1){
    40         getline(cin,s);
    41         if(s=="E")return 0;
    42         int P_o=s.find('O'),P_j=s.find('J'),
    43             c1=P_o,c2=P_j-P_o,c3=s.length()-P_j;
    44         while(1){
    45             int flag=0;
    46             if(c1)--c1,putchar('Z'),flag=1;
    47             if(c2)--c2,putchar('O'),flag=1;
    48             if(c3)--c3,putchar('J'),flag=1;
    49             if(flag==0)break;
    50         }
    51         cout<<endl;
    52     }
    53 }
    My.cpp

    STD:

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<cstring>
     4 #include<ctime>
     5 #include<algorithm>
     6 #include<cmath>
     7 //#include<stack>
     8 #define R(a,b,c) for(register int (a)=(b);(a)<=(c);++(a))
     9 #define nR(a,b,c) for(register int (a)=(b);(a)>=(c);--(a))
    10 #define Ii inline int
    11 #define Il inline long long
    12 #define Iv inline void
    13 #define Id inline double
    14 #define Ib inline bool
    15 #define ll long long
    16 #define re register
    17 #define Fill(a,b) memset((a),(b),sizeof((a)))
    18 #define Cmax(a,b) ((a)=(a)>(b)?(a):(b))
    19 #define Cmin(a,b) ((a)=(a)<(b)?(a):(b))
    20 #define D_e(x) printf("&_____%d______&",x);
    21 #define D_e_Line printf("
    -----------------
    ");
    22 #define Pause system("pause")
    23 using namespace std;
    24 //const int N=100001;
    25 //const int M=500001;
    26 Ii read(){
    27     int s=0,f=1;char c;
    28     for(c=getchar();c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
    29     while(c>='0'&&c<='9')s=s*10+(c^'0'),c=getchar();
    30     return s*f;
    31 }
    32 Iv print(int x){
    33     if(x<0)putchar('-'),x=-x;
    34     if(x>9)print(x/10);
    35     putchar(x%10^'0');
    36 }
    37 int main(){
    38     char s[1001];
    39     while(scanf("%s",s)!=EOF){
    40         int c1=0,c2=0,c3=0;
    41         if(strcmp(s,"E")==0)break;
    42         int len=strlen(s);
    43         R(i,0,len-1)
    44             c1+=(s[i]=='Z'),
    45             c2+=(s[i]=='O'),
    46             c3+=(s[i]=='J');
    47         while(1){
    48             int flag=0;
    49             if(c1>0)--c1,putchar('Z'),flag=1;
    50             if(c2>0)--c2,putchar('O'),flag=1;
    51             if(c3>0)--c3,putchar('J'),flag=1;
    52             if(flag==0)break;
    53             //D_e(c1);
    54             //D_e_Line;
    55         }
    56         cout<<endl;
    57     }
    58 }
    59 /*
    60 ZOJZOJZOZOZOOOO
    61 ZOJZOJZOZOZOOOO
    62 */
    STD.cpp

    RAND:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define random(a,b) ((a)+rand()%((b)-(a)+1))
     4 
     5 stringstream ss;
     6 
     7 int main( int argc, char *argv[] )
     8 { 
     9     int seed=time(NULL);
    10     if(argc)
    11     {
    12         ss.clear();
    13         ss<<argv[1];
    14         ss>>seed;
    15     }
    16     srand(seed);
    17     int T=rand()%100+1;
    18     while(T--){
    19         int num_z=rand()%100+1,
    20             num_o=rand()%100+1,
    21             num_j=rand()%100+1;
    22         while(num_z--)putchar('Z');
    23         while(num_o--)putchar('O');
    24         while(num_j--)putchar('J');
    25         putchar('
    ');        
    26     }
    27     putchar('E');
    28     return 0;
    29 }
    RAND.cpp
  • 相关阅读:
    Oracle基础知识整理
    linux下yum安装redis以及使用
    mybatis 学习四 源码分析 mybatis如何执行的一条sql
    mybatis 学习三 mapper xml 配置信息
    mybatis 学习二 conf xml 配置信息
    mybatis 学习一 总体概述
    oracle sql 语句 示例
    jdbc 新认识
    eclipse tomcat 无法加载导入的web项目,There are no resources that can be added or removed from the server. .
    一些常用算法(持续更新)
  • 原文地址:https://www.cnblogs.com/bingoyes/p/10311520.html
Copyright © 2011-2022 走看看