HDU 3783
读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的仍然按照ZOJ的顺序输出。
MY:(OUTPUT LIMIT EXCEED)
#include<cstdio>
#include<iostream>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<cmath>
//#include<stack>
#define R(a,b,c) for(register int (a)=(b);(a)<=(c);++(a))
#define nR(a,b,c) for(register int (a)=(b);(a)>=(c);--(a))
#define Ii inline int
#define Il inline long long
#define Iv inline void
#define Id inline double
#define Ib inline bool
#define ll long long
#define re register
#define Fill(a,b) memset((a),(b),sizeof((a)))
#define Cmax(a,b) ((a)=(a)>(b)?(a):(b))
#define Cmin(a,b) ((a)=(a)<(b)?(a):(b))
#define D_e(x) printf("&_____%d______&",x);
#define D_e_Line printf("\n-----------------\n");
#define Pause system("pause")
using namespace std;
//const int N=100001;
//const int M=500001;
Ii read(){
int s=,f=;char c;
for(c=getchar();c<''||c>'';c=getchar())if(c=='-')f=-;
while(c>=''&&c<='')s=s*+(c^''),c=getchar();
return s*f;
}
Iv print(int x){
if(x<)putchar('-'),x=-x;
if(x>)print(x/);
putchar(x%^'');
}
int main(){
string s;
while(){
getline(cin,s);
if(s=="E")return ;
int P_o=s.find('O'),P_j=s.find('J'),
c1=P_o,c2=P_j-P_o,c3=s.length()-P_j;
while(){
int flag=;
if(c1)--c1,putchar('Z'),flag=;
if(c2)--c2,putchar('O'),flag=;
if(c3)--c3,putchar('J'),flag=;
if(flag==)break;
}
cout<<endl;
}
}
My.cpp
STD:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<cmath>
//#include<stack>
#define R(a,b,c) for(register int (a)=(b);(a)<=(c);++(a))
#define nR(a,b,c) for(register int (a)=(b);(a)>=(c);--(a))
#define Ii inline int
#define Il inline long long
#define Iv inline void
#define Id inline double
#define Ib inline bool
#define ll long long
#define re register
#define Fill(a,b) memset((a),(b),sizeof((a)))
#define Cmax(a,b) ((a)=(a)>(b)?(a):(b))
#define Cmin(a,b) ((a)=(a)<(b)?(a):(b))
#define D_e(x) printf("&_____%d______&",x);
#define D_e_Line printf("\n-----------------\n");
#define Pause system("pause")
using namespace std;
//const int N=100001;
//const int M=500001;
Ii read(){
int s=,f=;char c;
for(c=getchar();c<''||c>'';c=getchar())if(c=='-')f=-;
while(c>=''&&c<='')s=s*+(c^''),c=getchar();
return s*f;
}
Iv print(int x){
if(x<)putchar('-'),x=-x;
if(x>)print(x/);
putchar(x%^'');
}
int main(){
char s[];
while(scanf("%s",s)!=EOF){
int c1=,c2=,c3=;
if(strcmp(s,"E")==)break;
int len=strlen(s);
R(i,,len-)
c1+=(s[i]=='Z'),
c2+=(s[i]=='O'),
c3+=(s[i]=='J');
while(){
int flag=;
if(c1>)--c1,putchar('Z'),flag=;
if(c2>)--c2,putchar('O'),flag=;
if(c3>)--c3,putchar('J'),flag=;
if(flag==)break;
//D_e(c1);
//D_e_Line;
}
cout<<endl;
}
}
/*
ZOJZOJZOZOZOOOO
ZOJZOJZOZOZOOOO
*/
STD.cpp
RAND:
#include<bits/stdc++.h>
using namespace std;
#define random(a,b) ((a)+rand()%((b)-(a)+1)) stringstream ss; int main( int argc, char *argv[] )
{
int seed=time(NULL);
if(argc)
{
ss.clear();
ss<<argv[];
ss>>seed;
}
srand(seed);
int T=rand()%+;
while(T--){
int num_z=rand()%+,
num_o=rand()%+,
num_j=rand()%+;
while(num_z--)putchar('Z');
while(num_o--)putchar('O');
while(num_j--)putchar('J');
putchar('\n');
}
putchar('E');
return ;
}
RAND.cpp
HDU 3783的更多相关文章
- HDU 3783 ZOJ
ZOJ Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- hdu 1598 find the most comfortable road (并查集+枚举)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1598 find the most comfortable road Time Limit: 1000/ ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
随机推荐
- ubuntu 环境变量设置
一:用于当前终端:在当前终端中输入:export PATH=$PATH:<你的要加入的路径>不过上面的方法只适用于当前终端,一旦当前终端关闭或在另一个终端中,则无效.export NDK_ ...
- 23、sed常用命令
1.匹配与不匹配: n p ! sed -n '/ATTGC/p' file1 ##-n打印匹配到的行输出,默认所有行输出. sed -n '/AT\|GC/p' fil ...
- 再谈JavaScript的closure--JavaScript 闭包
关于JavaScript的闭包,在我的博客上之前有一篇文章 https://www.cnblogs.com/wphl-27/p/8491327.html 今天看了几篇文章,感觉又有了一些更深的理解,特 ...
- 单元测试NUnit 的文章
请参考 https://www.cnblogs.com/ranh941/p/7629279.htmlhttps://blog.csdn.net/qincode/article/details/1831 ...
- 01 git 概念
本文转自“廖雪峰的git教程” 集中式版本控制系统:版本库是集中存放在中央服务器的,中央服务器就好比是一个图书馆,你要改一本书,必须先从图书馆借出来,然后回到家自己改,改完了,再放回图书馆. 分布式版 ...
- Android onKeyDown、onKeyUp、dispatchKeyEvent的区别
1. onKeyDown.onKeyUp.dispatchKeyEvent的区别和使用场景 区别: 1.1 onKeyDown.onKeyUp是按键事件的回调接口(冒泡式调用),dispatchKey ...
- up6-chrome 45+安装教程
up6-Chrome 45+安装说明 说明:只需要安装up6.exe即可,up6.exe为插件集成安装包. 1.以管理员身份运行up6.exe.up6.exe中已经集成Chrome 45插件.
- java IO Nio 文件拷贝工具类Files
public static void main(String[] args) throws Exception { Files.copy(Paths.get("file/text.txt&q ...
- Java IO输入输出流 字符数组流 ByteArrayOutputStream/ByteArrayInputStream
private static void StringWriterAndReader() throws Exception { //字符串流(字符串的内存流) //字符串输入流 StringWriter ...
- 编写高质量代码改善C#程序的157个建议——建议56:使用继承ISerializable接口更灵活地控制序列化过程
建议56:使用继承ISerializable接口更灵活地控制序列化过程 接口ISerializable的意义在于,如果特性Serializable,以及与其像配套的OnDeserializedAttr ...