Nov 6, 2017 · 616 words · 2 mins
http://acm.hdu.edu.cn/showproblem.php?pid=4782
题意: # 将格式混乱的html代码输出成标准格式。
思路: # 模拟。
说下细节:
* 遇到open tag,先打印,后dep++ * 遇到close tag,先dep--,再打印 * 遇到空标签,直接在当前深度打印 * 遇到空白字符时,只有当前面出现了text以及后面也出现了text的时候才打印。**也就是说第一个string和最后一个string都是紧邻标签的。** 最坑的一点是…虽然题目给了数据组数,但是在所在行的同一行,可能出现下一组的开始
May 12, 2017 · 391 words · 1 min
题目链接
题意:初始有一个锅,每t分钟可以做好k个饼,现在需要N个饼。还可以另外建一个锅,花费d时间,建好以后两个锅可以并行烙饼。问是否应该建锅?(以期减少烙饼时间)
思路:求出两种情况下的总时间,比较一下。
Mar 31, 2017 · 816 words · 2 mins
#1197 : Give My Text Back # 时间限制:10000ms
单点时限:1000ms
内存限制:256MB
描述 # To prepare for the English exam Little Ho collected many digital reading materials. Unfortunately the materials are messed up by a malware.
Nov 1, 2016 · 331 words · 1 min
题目链接
题意:求一个小数的循环节…
思路:其实直接模拟就好…
模拟竖式计算…
这里用到一个小技巧。
由于多组数据,每次都memset一个bool会很慢,导致超时。
Sep 23, 2016 · 451 words · 1 min
题意:一串电话号码,每个数字+8取各位后,把每个数字写成对应的大写英文,从"ZERO"和“NINE”,然后打乱字母的顺序。现在给出打乱的字母顺序,问可能的字典序最小的电话号码是是多少(可能有前导0)
Aug 14, 2016 · 561 words · 2 mins
hdu 5835 题目链接 题意:n种礼物,每种a[i]个。现在有无穷个小朋友排成一排,分给每个人一个“普通”的礼物,一个“昂贵”的礼物(哪个普通哪个昂贵是自己定的,或者说,任意的) 要求是相邻的小朋友的普通的礼物不能是同一种。现在问最多能给多少小朋友分礼物。。。
Aug 7, 2016 · 491 words · 1 min
题目链接 傻逼模拟。。读完题就ac了。。。
代码实现 1/* *********************************************** 2Author :111qqz 3Created Time :2016年08月07日 星期日 18时04分18秒 4File Name :code/whust2016/#1/D.cpp 5************************************************ */ 6#include <cstdio> 7#include <cstring> 8#include <iostream> 9#include <algorithm> 10#include <vector> 11#include <queue> 12#include <stack> 13#include <set> 14#include <map> 15#include <string> 16#include <cmath> 17#include <cstdlib> 18#include <deque> 19#include <ctime> 20#define fst first 21#define sec second 22#define lson l,m,rt<<1 23#define rson m+1,r,rt<<1|1 24#define ms(a,x) memset(a,x,sizeof(a)) 25typedef long long LL; 26#define pi pair < int ,int > 27#define MP make_pair 28using namespace std; 29const double eps = 1E-8; 30const int dx4[4]={1,0,0,-1}; 31const int dy4[4]={0,-1,1,0}; 32const int inf = 0x3f3f3f3f; 33const int N=280; 34int n,m; 35int total,adva,advb; 36struct Friend 37{ 38 int money; 39 int adv; 40}f[N]; 41struct Room 42{ 43 int type; 44 int cost; 45 int adv; 46}r[N]; 47struct Ans 48{ 49 int val; 50 int rid; 51 int fid; 52 bool operator < (Ans b)const 53 { 54 return val>b.val; 55 } 56}ans[300*300]; 57int main() 58{ 59 #ifndef ONLINE_JUDGE 60 freopen("code/in.txt","r",stdin); 61 #endif 62 cin>>total>>adva>>advb; 63 cin>>n; 64 for ( int i = 1 ; i <= n ; i++) 65 scanf("%d %d",&f[i].money,&f[i].adv); 66 scanf("%d",&m); 67 for ( int i = 1 ; i <= m ; i++) 68 scanf("%d%d%d",&r[i].type,&r[i].cost,&r[i].adv); 69 int cnt = 0 ; 70 for ( int i = 1 ; i <= m ; i++) 71 { 72 if (r[i].type==1) 73 { 74 if (r[i].cost<=total) 75 { 76 cnt++; 77 ans[cnt].val = r[i].adv+adva; 78 ans[cnt].rid = i; 79 ans[cnt].fid = -1; 80 } 81 continue; 82 } 83 else 84 { 85 for ( int j = 0 ; j <= n ; j++) 86 { 87 if (j==0) //自己住双人间 88 { 89 if (r[i].cost<=total) 90 { 91 cnt++; 92 ans[cnt].val = r[i].adv+advb; 93 ans[cnt].rid = i ; 94 ans[cnt].fid = -1; 95 } 96 } 97 else 98 { 99 if (r[i].cost<=total*2&&r[i].cost<=f[j].money*2) 100 { 101 cnt++; 102 ans[cnt].val = r[i].adv+f[j].adv; 103 ans[cnt].rid = i ; 104 ans[cnt].fid = j; 105 } 106 } 107 } 108 } 109 } 110// for ( int i = 1 ; i <= cnt ; i++) 111// { 112// printf("val:%d room: %d friend : %d \n",ans[i].val,ans[i].rid,ans[i].fid); 113// } 114 if (cnt==0) 115 { 116 puts("Forget about apartments. Live in the dormitory."); 117 }else 118 { 119 sort(ans+1,ans+cnt+1); 120 if (r[ans[1].rid].type==1) 121 { 122 printf("You should rent the apartment #%d alone.\n",ans[1].rid); 123 } 124 else 125 { 126 if (ans[1].fid==-1) 127 { 128 printf("You should rent the apartment #%d alone.\n",ans[1].rid); 129 } 130 else 131 { 132 133 printf("You should rent the apartment #%d with the friend #%d.\n",ans[1].rid,ans[1].fid); 134 135 } 136 } 137 } 138 #ifndef ONLINE_JUDGE 139 fclose(stdin); 140 #endif 141 return 0; 142}
Jul 18, 2016 · 510 words · 2 mins
cf689A
思路:一个老式的电话键盘。。。。给出一个拨号的移动路径。。。问这个路径是否唯一。
思路:如果唯一就说明。。。不能平移。。。否则不唯一。。
平移可以上下左右。。所以先写4个常亮数组。。。标记平移后的结果。。。设置不合法位就可以了。。。
May 10, 2016 · 785 words · 2 mins
1689: [Usaco2005 Open] Muddy roads 泥泞的路 # Time Limit: 5 Sec Memory Limit: 64 MB Submit: 311 Solved: 227 [Submit][Status][Discuss]
Description # Farmer John has a problem: the dirt road from his farm to town has suffered in the recent rainstorms and now contains (1 <= N <= 10,000) mud pools. Farmer John has a collection of wooden planks of length L that he can use to bridge these mud pools. He can overlap planks and the ends do not need to be anchored on the ground. However, he must cover each pool completely. Given the mud pools, help FJ figure out the minimum number of planks he needs in order to completely cover all the mud pools.
Mar 31, 2016 · 589 words · 2 mins
# Time Limit: 5 Sec Memory Limit: 64 MB Submit: 774 Solved: 593 [Submit][Status][Discuss]
Description # Farmer John有一个过时的打谷机(收割小麦),它需要带子来带动。发动机驱动轮1总是顺时针旋转的,用来带动转轮2,转轮2来带动转轮3,等等。一共有n(2<=n<=1000)个转轮(n-1条带子)。上面的图解描述了转轮的两种连接方式,第一种方式使得两个轮子旋转的方向相同,第二种则相反。 给出一串带子的信息: *Si—驱动轮 *Di—被动轮 *Ci—连接的类型(0=直接连接,1=交叉连接) 不幸的是,列出的信息是随即的。 作为样例,考虑上面的图解,n=4,转轮1是驱动轮,可以得知最后转轮4是逆时针旋转的。
Jan 23, 2016 · 757 words · 2 mins
http://acm.hdu.edu.cn/showproblem.php?pid=5611 题意:给出n个电话号码(长度为11的字符串),满足特殊条件的价格为a,否则为b.特殊条件为最后5位数字一样,最后5位严格递增或者严格递减,最后8位是一个1980年1月一日到2016年12月31日的合法日期。问最后的价值。
Jan 1, 2016 · 465 words · 1 min
http://codeforces.com/contest/611/problem/C 题意:给出一个n*m的地图,.表示可以空,#表示墙。一个东西需要占两个相邻的格子,问给定一个矩形,放一个东西的方案数。 思路:q很大。。应该是先预处理出来直接调用答案。。。计数问题累加性。。应该是前缀和之类。。需要做的就是怎么标记。。我的做法是竖着放和横着放的个数分开来存。从左往右从上往下,每次标记到后一个点。然后二维的前缀和。然后每次询问的时候,去掉最上边和最左边两条边界上对应的多加的点。
Dec 29, 2015 · 845 words · 2 mins
http://codeforces.com/problemset/problem/31/C 题意:给出n个借用教室的时间安排,可能会有冲突。要求恰好去掉一个时间安排使得剩下的时间安排不冲突。问多多少种方案。 思路:首先一个直觉是。。除非初始就没有任何冲突。。不然这个答案不会很大。。
Dec 14, 2015 · 632 words · 2 mins
http://codeforces.com/problemset/problem/1/B 题意:给出了两种表格的表示方法。要求互相转化。 思路:直接模拟即可。注意和一般的进制转化不同的是,26进制对应的是1到26而不是0到25,所以要记得处理下借位。
代码实现 1/* *********************************************** 2Author :111qqz 3Created Time :2015年12月13日 星期日 19时46分09秒 4File Name :code/cf/problem/1B.cpp 5************************************************ */ 6 7#include <cstdio> 8#include <cstring> 9#include <iostream> 10#include <algorithm> 11#include <vector> 12#include <queue> 13#include <set> 14#include <map> 15#include <string> 16#include <cmath> 17#include <cstdlib> 18#include <ctime> 19#define fst first 20#define sec second 21#define lson l,m,rt<<1 22#define rson m+1,r,rt<<1|1 23#define ms(a,x) memset(a,x,sizeof(a)) 24typedef long long LL; 25#define pi pair < int ,int > 26#define MP make_pair 27 28using namespace std; 29const double eps = 1E-8; 30const int dx4[4]={1,0,0,-1}; 31const int dy4[4]={0,-1,1,0}; 32const int inf = 0x3f3f3f3f; 33 34char st[100]; 35int a26[100]; 36int a10[100]; 37 38void pre() 39{ 40 a26[0]=1; 41 for ( int i = 1 ;i<=5; i++) 42 { 43 a26[i] = a26[i-1]*26; 44// cout<<"i:"<<i<<" "<<a26[i]<<endl; 45 } 46 a10[0] = 1; 47 for ( int i = 1 ; i<=7 ; i++) 48 { 49 a10[i] = a10[i-1]*10; 50 } 51} 52void solve() 53{ 54 cin>>st; 55 int len = strlen(st); 56 int p1=-1,p2=-1; 57 for ( int i = 0 ; i < len ; i++) 58 { 59 char ch = st[i]; 60 if (ch>='A'&&ch<='Z') 61 { 62 if (p1==-1) 63 { 64 p1 = i ; 65 } 66 else 67 { 68 p2 = i; 69 break; 70 } 71 } 72 } 73 if (p2-p1==1||p2==-1) 74 { 75 int dig = 0 ; 76 int alp = 0; 77 int sum = 0 ; 78 int sum2 = 0 ; 79 for ( int i = len -1 ; i>= 0 ; i--) 80 { 81 char ch = st[i]; 82 if (!isdigit(ch)) 83 { 84 sum += (ch-'A'+1)*a26[alp]; 85 alp++; 86 } 87 else 88 { 89 sum2+= (ch-'0')*a10[dig]; 90 dig++; 91 } 92 } 93 printf("R%d\n",sum2,sum); 94 } 95 else 96 { 97 int dig1 = 0 ; 98 int dig2 = 0; 99 int sum1 = 0 ; 100 int sum2 = 0 ; 101 int p = 1; 102 for ( int i = len-1 ; i>= 0 ; i-- ) 103 { 104 char ch = st[i]; 105 if (isdigit(ch)) 106 { 107 // cout<<"ch:"<<ch<<endl; 108 if (p) 109 { 110 sum1+=(ch-'0')*a10[dig1]; 111 // cout<<"sum1:"<<sum1<<endl; 112 dig1++; 113 } 114 else 115 { 116 sum2+=(ch-'0')*a10[dig2]; 117 dig2++; 118 } 119 120 121 } 122 else 123 { 124 p = 0 ; 125 } 126 } 127// cout<<"sum1:"<<sum1<<" sum2:"<<sum2<<endl; 128 int cnt = 0 ; 129 int b[50]; 130 while(sum1) 131 { 132 cnt++; 133 b[cnt] = sum1; 134 sum1/=26; 135// cout<<"sum1::::"<<sum1<<endl; 136 } 137// cout<<"cnt:"<<cnt<<endl; 138 for ( int i = 1 ; i <= cnt -1 ; i ++) 139 { 140 if (b[i]<=0) 141 { 142 b[i]+=26; 143 b[i+1]--; 144 } 145 } 146 while (b[cnt]==0) cnt--; 147 148 for ( int i = cnt ; i >=1 ; i--) 149 { 150 151 // cout<<"b[i]:"<<b[i]<<endl; 152 cout<<char(b[i]+'A'-1); 153 } 154 cout<<sum2<<endl; 155 156 157 158 159 } 160 161 162} 163int main() 164{ 165 #ifndef ONLINE_JUDGE 166 freopen("code/in.txt","r",stdin); 167 #endif 168 169 pre(); 170 int T; 171 cin>>T; 172 while (T--) 173 { 174 solve(); 175 } 176 177 #ifndef ONLINE_JUDGE 178 fclose(stdin); 179 #endif 180 return 0; 181}
Dec 6, 2015 · 419 words · 1 min
http://codeforces.com/problemset/problem/158/B 题意:n组人,每组有si个(1<=si<=4),每辆车能装4个人。问最少需要多少辆车装下所有人并且保证同一组的人在一辆车里。 思路:统计人数分别为1,2,3,4的人数。对于4的直接加到答案。贪心的思路是:优先用人数少的去填人数多的。
Sep 26, 2015 · 257 words · 1 min
模拟.
直接搞…
并不明白坑在哪里...
排在我前面被hack了100多人…
代码实现 1/************************************************************************* 2 > File Name: code/bc/#57/1001.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年09月26日 星期六 19时04分34秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#include<cctype> 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define ms(a,x) memset(a,x,sizeof(a)) 25#define lr dying111qqz 26using namespace std; 27#define For(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef double DB; 30const int inf = 0x3f3f3f3f; 31const int N=1E3+7; 32char str[N]; 33int len; 34int main() 35{ 36 #ifndef ONLINE_JUDGE 37 freopen("in.txt","r",stdin); 38 #endif 39 int T; 40 cin>>T; 41 while (T--) 42 { 43 scanf("%s",str); 44 len = strlen(str); 45 int cnt = 0; 46 int ans = 0 ; 47 for ( int i = 0 ; i < len ; i++) 48 { 49 if (str[i]=='(') 50 { 51 cnt++; 52 } 53 else 54 { 55 cnt--; 56 if (cnt>=0) 57 { 58 ans++; 59 } 60 if (cnt<0) 61 cnt = 0 ; 62 } 63 } 64 printf("%d\n",ans); 65 } 66 67 #ifndef ONLINE_JUDGE 68 fclose(stdin); 69 #endif 70 return 0; 71}
Aug 23, 2015 · 991 words · 2 mins
B. Order Book
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
In this task you need to process a set of stock exchange orders and use them to create order book.
An order is an instruction of some participant to buy or sell stocks on stock exchange. The order number i has price p__i, direction d__i – buy or sell, and integer q__i. This means that the participant is ready to buy or sell q__i stocks at price p__i for one stock. A value q__i is also known as a volume of an order.
Aug 22, 2015 · 262 words · 1 min
傻逼模拟题
我做了半小时….
sssssad
代码实现 1/************************************************************************* 2 > File Name: code/bc/#52/1001.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月22日 星期六 18时51分44秒 6 ************************************************************************/ 7#include<iostream> 8#include<iomanip> 9#include<cstdio> 10#include<algorithm> 11#include<cmath> 12#include<cstring> 13#include<string> 14#include<map> 15#include<set> 16#include<queue> 17#include<vector> 18#include<stack> 19#include<cctype> 20#define y1 hust111qqz 21#define yn hez111qqz 22#define j1 cute111qqz 23#define ms(a,x) memset(a,x,sizeof(a)) 24#define lr dying111qqz 25using namespace std; 26#define For(i, n) for (int i=0;i<int(n);++i) 27typedef long long LL; 28typedef double DB; 29const int inf = 0x3f3f3f3f; 30const int N=1E6+7; 31int main() 32{ 33 #ifndef ONLINE_JUDGE 34 freopen("in.txt","r",stdin); 35 #endif 36 int x,y,w,n; 37 while (scanf("%d%d%d%d",&x,&y,&w,&n)!=EOF){ 38 int num = 1; 39 int cnt; 40 int q; 41 bool on = true; 42 bool flag = false; 43 int t = 0; 44 while (t<N&&!flag){ 45 if (num==n) { 46 cout<<t<<endl; 47 flag = true; 48 break; 49 } 50 cnt = t+x; 51 q = 0; 52 while (t<cnt){ 53 q++; 54 t++; 55 if (q%w==0){ 56// cout<<"aaat:"<<t<<endl; 57 num++; 58 } 59 if (num == n){ 60 cout<<t<<endl; 61 flag = true; 62 break; 63 } 64 } 65 on = false; 66 t = t + y; 67 on = true; 68 num++; 69 if (num==n){ 70 cout<<t<<endl; 71 flag = true; 72 } 73 } 74 } 75 #ifndef ONLINE_JUDGE 76 fclose(stdin); 77 #endif 78 return 0; 79}
Aug 16, 2015 · 135 words · 1 min
代码实现 1/************************************************************************* 2 > File Name: code/cf/#313/B.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: Wed 22 Jul 2015 09:52:54 PM CST 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#define y0 abc111qqz 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define tm crazy111qqz 25#define lr dying111qqz 26using namespace std; 27#define REP(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef unsigned long long ULL; 30 31 int a1,b1,a2,b2,a3,b3; 32bool judge (int x2,int y2,int x3,int y3) 33{ 34 if (x2<=a1&&x3<=a1&&y2+y3<=b1) 35 return true; 36 if (y2<=b1&&y3<=b1&&x2+x3<=a1) 37 return true; 38 return false; 39} 40int main() 41{ 42 cin>>a1>>b1>>a2>>b2>>a3>>b3; 43 if (judge(a2,b2,a3,b3)||judge(b2,a2,a3,b3)||judge(b2,a2,b3,a3)||judge(a2,b2,b3,a3)) 44 { 45 puts("YES"); 46 } 47 else 48 { 49 puts("NO"); 50 } 51 52 return 0; 53}