HDU 4891 The Great Pan (字符串处理)
来源:互联网 发布:ubuntu 安装 交换分区 编辑:程序博客网 时间:2024/04/30 21:07
题目链接:HDU 4891 The Great Pan
求一串字符有多少种不同的意思,其中关心‘{’,‘}’之间的‘|’。和‘$','$'之间的空格,连续N个空格算N+1种;
AC代码:
#include<stdio.h>#include<string>#include<string.h>using namespace std;char s[2*1024*1024+10];string ss;int cnt;int find(int x,int y){ int i,count=0; for(i=x;i<=y;i++) { if(ss[i]=='|') count++; } return count+1;}int find2(int x,int y){ int mark=0; int i,count=1,ret=1; for(i=x;i<=y;i++) { if(ss[i]==' ') { mark=1; count++; } else { if(mark==1) ret*=count; if(ret>100000) cnt=1; count=1; mark=0; } } return ret;}int main(){ int len; int n,i; __int64 ans; while(scanf("%d",&n)!=EOF) { len=strlen(s); ss=""; cnt=0; ans=1; getchar(); for(i=0;i<n;i++) { gets(s); ss+=s; } int x,y,a,b; x=y=a=b=-1; for(i=0;i<ss.length();i++) { if(ss[i]=='{') a=i; if(ss[i]=='}') b=i; if(a!=-1 && b!=-1) { ans*=find(a,b); a=b=-1; } if(x==-1 && ss[i]=='$') { x=i; ss[i]='*'; } if(y==-1 && ss[i]=='$') y=i; if(x!=-1 && y!=-1) { ans*=find2(x,y); x=y=-1; } if(ans>100000) cnt=1; } if(cnt==1) printf("doge\n"); else printf("%I64d\n",ans); } return 0;}
1 0
- HDU 4891 The Great Pan (字符串处理)
- hdu 4891 The Great Pan 字符串的处理
- Hdu 4891 The Great Pan
- HDU 4891 The Great Pan
- hdu 4891 The Great Pan
- HDU 4891 The Great Pan
- hdu 4891 The Great Pan
- hdu 4891 The Great Pan(模拟)
- HDU 4891 The Great Pan(模拟)
- hdu 4891 The Great Pan(模拟)
- hdu 4891 The Great Pan (模拟)
- HDU 4891 The Great Pan (模拟)
- HDU 4891 The Great Pan(模拟)
- HDU--4891--The Great Pan--暴力搜索
- HDU 4891— The Great Pan
- HDU 4891 The Great Pan 模拟
- HDU 4891 The Great Pan(字符串处理)只要看懂就能做出,毕竟英语渣渣
- 【HDU 4891 多校联合】The Great Pan【模拟】
- android 实用闹钟开发过程记(一)--创建数据库
- rsync+ inotify实时同步
- android 实用闹钟开发过程记(二)--sqlite数据库的操作
- About Bluetooth LE
- poj 2021 Relative Relatives
- HDU 4891 The Great Pan (字符串处理)
- Android实用闹钟开发(三)---AlarmManager和Calendar
- Android 一键清理动画
- android闹钟开发(四)--音乐播放与音量调节
- android屏幕适配
- MySQL数据库插入中文出现“Incrrect Strng value '\xE9\x9C\x82'"错误
- 字典树 详解
- 去掉ExpandableListView的箭头图标
- Android设置RadioButton在文字的右边