2016弱校联盟十一专场10.3(12点场)
来源:互联网 发布:视频加速软件 编辑:程序博客网 时间:2024/05/12 02:09
水题。
//#pragma comment(linker, "/STACK:102400000,102400000")#include <iostream>#include<string.h>#include<vector>#include<queue>#include<algorithm>#include<stdio.h>#include<math.h>#include<map>#include<stdlib.h>#include<time.h>#include<stack>#include<set>#include<deque>using namespace std;typedef long long ll;bool cmp(int x){ int tem[20],bj=0; while(x) { tem[bj++]=x%10; x/=10; } for(int i=0; i<bj-1; i++) if(tem[i]!=tem[i+1]+1) return 0; return 1;}int a[1010];int main(){ int n; scanf("%d",&n); for(int i=0; i<n; i++) scanf("%d",&a[i]); int max0=-1; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) { int tem=a[i]*a[j]; if(cmp(tem)) max0=max(max0,tem); } printf("%d\n",max0); return 0;}
简单bfs。
//#pragma comment(linker, "/STACK:102400000,102400000")#include <iostream>#include<string.h>#include<vector>#include<queue>#include<algorithm>#include<stdio.h>#include<math.h>#include<map>#include<stdlib.h>#include<time.h>#include<stack>#include<set>#include<deque>using namespace std;typedef long long ll;char a[210][210];int fx[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};int si,sj,ei,ej;int n,m;struct data{ int i,j,step; data (int x,int y,int s) { i=x,j=y,step=s; }};bool vis[210][210];void bfs2(int ans1){ memset(vis,0,sizeof(vis)); queue<data>q; data a0(ei,ej,0); q.push(a0); int flag=0,ans=0; vis[ei][ej]=1; while(!q.empty()) { data t=q.front(); q.pop(); for(int i=0; i<4; i++) { int x=t.i+fx[i][0],y=t.j+fx[i][1]; if(x>=0&&x<n&&y>=0&&y<m) { if(!vis[x][y]) { vis[x][y]=1; if(a[x][y]=='.') { data aa(x,y,t.step+1); q.push(aa); } else if(a[x][y]=='$') { ans=t.step+1; flag=1; break; } } } } if(flag)break; } // cout<<ans1<<" "<<ans<<endl; if(!flag) puts("Yes"); else if(ans<=ans1) puts("No"); else puts("Yes");}void bfs1(){ memset(vis,0,sizeof(vis)); queue<data>q; data a0(si,sj,0); q.push(a0); int flag=0,ans=0; vis[si][sj]=1; while(!q.empty()) { data t=q.front(); q.pop(); for(int i=0; i<4; i++) { int x=t.i+fx[i][0],y=t.j+fx[i][1]; if(x>=0&&x<n&&y>=0&&y<m) { if(!vis[x][y]) { vis[x][y]=1; if(a[x][y]=='.') { data aa(x,y,t.step+1); q.push(aa); } else if(a[x][y]=='%') { ans=t.step+1; flag=1; break; } } } } if(flag)break; } if(flag) bfs2(ans); else puts("No");}int main(){ scanf("%d%d",&n,&m); for(int i=0; i<n; i++) for(int j=0; j<m; j++) { scanf(" %c",&a[i][j]); if(a[i][j]=='@') si=i,sj=j; else if(a[i][j]=='%') ei=i,ej=j; } bfs1(); return 0;}
找规律……
//#pragma comment(linker, "/STACK:102400000,102400000")#include <iostream>#include<string.h>#include<vector>#include<queue>#include<algorithm>#include<stdio.h>#include<math.h>#include<map>#include<stdlib.h>#include<time.h>#include<stack>#include<set>#include<deque>using namespace std;typedef long long ll;int bj=0;ll hh[45010];int main(){ for(ll i=1; i<=45000; i++) hh[i]=(i*(i+1))/2; ll n; scanf("%lld",&n); int flag=0; for(int i=45000; i>=0; i--) if(n<=hh[i]&&n>hh[i-1]) { flag=i; break; } if((flag*(flag+1))/2==n) { for(int i=0; i<flag; i++) printf(")"); for(int i=0; i<flag; i++) printf("("); } else { int tem=(flag*(flag+1))/2-n-1; for(int i=0; i<flag-1-tem; i++) printf(")"); printf("()"); for(int i=0; i<tem; i++) printf(")"); for(int i=0; i<(flag-1); i++) printf("("); } puts(""); return 0;}
0 0
- 2016弱校联盟十一专场10.3(12点场)
- 2016弱校联盟十一专场10.5(12点场) Increasing or Decreasing bnu 52325
- 2016弱校联盟十一专场10.5(12点场) Increasing or Decreasing
- 2016弱校联盟十一专场10.7(12点场)-D. Blocks
- 2016弱校联盟十一专场10.7(12点场)-M. Subimage Recognition
- 2016弱校联盟十一专场10.7(12点场) E. Training little cats
- POJ 3735 Training little cats(矩阵乘法 + 稀疏矩阵优化)——2016弱校联盟十一专场10.7(12点场)
- 2016弱校联盟十一专场10.3,BNU52308,大模拟
- 2016弱校联盟十一专场10.2 Longest Increasing Subsequence
- [Contests]2016弱校联盟十一专场10.7
- Blocks(弱校联盟十一专场)
- UmBasketella(弱校联盟十一专场)
- 2016弱校联盟十一专场10.3 C.We don't wanna work!(集合操作)
- 2016弱校联盟十一专场10.3 ABest Matched Pair(水)
- 2016弱校联盟十一专场10.3 We don't wanna work!
- (2016 弱校联盟十一专场10.3) Similarity of Subtrees DFS + hash
- (2016弱小联盟十一专场10.3)Parentheses 找规律
- (2016弱小联盟十一专场10.3) Best Matched Pair 暴力
- DirectX导图(2):初始化
- 繁琐的数据类型和转义字符
- 20161003 Python笔记之正则表达式 re
- 解决GooglePlayStore提示您的设备与此版本不兼容(Your device isn't compatible with this version)
- mysql扩展库mysqli讲解!!!!!
- 2016弱校联盟十一专场10.3(12点场)
- [置顶] AndroidStudio导入项目总是不成功之终极解决方案
- DirectX导图(3):渲染管线
- SQLite同时读报错null pointer openOrCreateDatabase(java.lang.String, int, android.database.sq
- DirectX导图(4):画图
- EDA软件_PCB板覆铜
- 跳帧及使用线程将获取下一帧与处理当前帧同时进行
- php empty()出错,Fatal error: Can’t use function return
- ANDROID 开发常用的框架、工具、API最全集合