Educational Codeforces Round 25
来源:互联网 发布:欧莱雅淘宝旗舰店 编辑:程序博客网 时间:2024/05/18 00:15
我是个爆零的菜鸡
A - Binary Protocol
A题题意一直没看清楚,一直就很难理解样例。 题目意思是把一个十进制数字转化成二进制数(不是平时的方法),用1来表示每一个数字,比如3=111 , 然后每两个数字之间加一个0. 这题找下规律就好了,如果有3个0就说明有2个0,如果末尾是0,再输出一个0.
/*If I get TLE , it is good.If I get AC,it's NICE !*/#include <stdio.h>#include <iostream>#include <algorithm>#include <string.h>#include <vector>#include <cmath>#include <queue>#include <map>using namespace std;typedef long long ll;const int INF=2147483647;const int MAXN=1e7+10;const ll mod=1e9+7;using namespace std;#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)typedef long long ll;char str[100];int main(void){ int n; cin >>n; cin >> str; int sum=0; int cnt=0; for(int i=0; i<n; i++) { if(str[i]=='1') { sum++; for(int j=1; j<=cnt-1; j++) cout << "0"; cnt=0; } else if(str[i]=='0') { if(sum) cout << sum; sum=0; cnt++; } } for(int j=1; j<=cnt-1; j++) cout << "0"; if(str[n-1]=='0') printf("0\n"); else if(sum) cout << sum <<endl;}
B - Five-In-a-Row
这题xjb暴力就好了。
/*If I get TLE , it is good.If I get AC,it's NICE !*/#include <stdio.h>#include <iostream>#include <algorithm>#include <string.h>#include <vector>#include <cmath>#include <queue>#include <map>using namespace std;typedef long long ll;const int INF=2147483647;const int MAXN=1e7+10;const ll mod=1e9+7;using namespace std;#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)typedef long long ll;char mp[15][15];int cnt=0;bool check(int x, int y){ //横着走 for(int i=y-1;i>=0;i--) { if(mp[x][i]=='X') cnt++; else break; } for(int i=y+1;i<=9;i++) { if(mp[x][i]=='X') cnt++; else break; } if(cnt>=5) return true; cnt=1; // 竖着走 for(int i=x-1;i>=0;i--) { if(mp[i][y]=='X') cnt++; else break; } for(int i=x+1;i<=9;i++) { if(mp[i][y]=='X') cnt++; else break; } if(cnt>=5) return true; cnt=1; // 左上右下对角线 for(int i=1;i<=11;i++) { if(mp[x-i][y-i]=='X' && x-i>=0 && y-i>=0) { cnt++; } else break; } for(int i=1;i<=11;i++) { if(mp[x+i][y+i]=='X' && x+i<=9 && y+i<=9) { cnt++; } else break; } if(cnt>=5) return true; cnt=1; //右上左下走 for(int i=1;i<=11;i++) { if(mp[x+i][y-i]=='X' && x+i<=9 && y-i>=0) { cnt++; } else break; } for(int i=1;i<=11;i++) { if(mp[x-i][y+i]=='X' && x-i>=0 && y+i<=9) { cnt++; } else break; } if(cnt>=5) return true; return false;}int main(void){ for(int i=0; i<10; i++) cin >> mp[i]; for(int i=0; i<10; i++) { for(int j=0; j<10; j++) { cnt=0; if(mp[i][j]=='.') { cnt=1; if(check(i,j)) { printf("YES\n"); return 0; } } } } printf("NO\n"); return 0;}
C - Multi-judge Solving
坑啊,其实还是自己没看清楚题目意思。感觉早上脑子一片混沌,可能给A题搞心态崩了,后面的题都想不进去。这题sort一下a数组,然后一个个和2*k进行比较。
/*If I get TLE , it is good.If I get AC,it's NICE !*/#include <stdio.h>#include <iostream>#include <algorithm>#include <string.h>#include <vector>#include <cmath>#include <queue>#include <map>using namespace std;typedef long long ll;const int INF=2147483647;const int MAXN=1e7+10;const ll mod=1e9+7;using namespace std;#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)typedef long long ll;int a[3000];int main(void){ int n,k; cin >>n>> k; for(int i=0;i<n;i++) cin >> a[i]; sort(a,a+n); int cnt=0; for(int i=0;i<n;i++) { if(k*2>=a[i]) { if(a[i]>k) k=a[i]; } else { while(k*2<a[i]) { cnt++; k=k*2; } k=a[i]; } } cout << cnt <<endl;}
通过这三题,我学到了什么?
1.题目一定要仔细看,代码才可以敲的快、对
2.一定要把题目想进去,同上。
阅读全文
0 0
- Educational Codeforces Round 25
- Educational Codeforces Round 25
- Educational Codeforces Round 25
- Educational Codeforces Round 25
- Educational Codeforces Round 25
- Educational Codeforces Round 25总结
- Educational Codeforces Round 25 题解
- Educational Codeforces Round 25 D. Suitable Replacement
- Educational Codeforces Round 25 E. Minimal Labels
- Educational Codeforces Round 25 A. Binary Protocol
- Educational Codeforces Round 25 A. Binary Protocol
- Educational Codeforces Round 25A-G题解
- Educational Codeforces Round 25 D. Suitable Replacement
- Educational Codeforces Round 25 E. Minimal Labels
- Educational Codeforces Round 25 G. Tree Queries
- cf Educational Codeforces Round 25 C
- cf Educational Codeforces Round 25 E
- Educational Codeforces Round 1
- Java基础之自增(++)和自减(--)运算符
- PAT甲级 1039
- 机器学习实战【2】(决策树ID3算法)
- DSP的C/C++语言程序设计
- Android中字符串的拆分split方法
- Educational Codeforces Round 25
- 深入Java集合学习系列:HashMap的实现原理
- python 常用函数
- java的substring()
- E
- 使用TensorFlow的LSTM API(3/7)
- 暑期项目开发实训 Day21
- HSSFWorkBook读取excel表格获取数据。
- servlet xml 文件的配置问题