Problem A. Lazy Spelling Bee Google APAC 2017 University Test Practice Round
来源:互联网 发布:哪个新顶级域名好 编辑:程序博客网 时间:2024/05/17 08:56
这一题只要判断一下i,i-1,i+1位置处有多少个不同的字母就可以了。注意首尾两端要特判一下。
#include<iostream>#include<stdio.h>#include<cstdio>#include<stdlib.h>#include<vector>#include<string>#include<cstring>#include<cmath>#include<algorithm>#include<stack>#include<queue>#include<ctype.h>#include<map>#include<time.h>#include<set>#include<bitset>#include<sstream>using namespace std;//Google APAC2017 Practice Round Problem A. Lazy Spelling Beeconst long long mod=1e9+7;const int maxn=1010;//lead to WA it set it as 1000, since need end symbolint T;char w[maxn];long long ans;int combnum(int idx){ if(idx==0) { if(w[idx]==w[idx+1]) { return 1; } else { return 2; } } else if(idx==strlen(w)-1) { if(w[idx]==w[idx-1]) { return 1; } else { return 2; } } else { set<char>letter; letter.clear(); letter.insert(w[idx-1]); letter.insert(w[idx]); letter.insert(w[idx+1]); return letter.size(); }}int main(){ freopen("A-large-practice.in","r",stdin); freopen("A-large-practice.out","w",stdout); scanf("%d",&T); for(int ca=1;ca<=T;ca++) { scanf("%s",w); int len=strlen(w); ans=1; if(len==1) { ans=1; } else { for(int i=0;i<len;i++) {// ans=(ans%mod)*(combnum(i)%mod); ans=ans*combnum(i); ans%=mod; } } printf("Case #%d: %lld\n",ca,ans); } return 0;}
0 0
- Problem A. Lazy Spelling Bee Google APAC 2017 University Test Practice Round
- Practice Round APAC test 2017--Problem A. Lazy Spelling Bee
- Practice Round APAC test 2017——1.Problem A. Lazy Spelling Bee
- [Google APAC 2017] Lazy Spelling Bee
- Problem A. Vote Google APAC 2017 University Test Round D
- Problem B. Rain Google APAC 2017 University Test Round A
- Google APAC 2017 University Test Round A
- Problem C. Not So Random Google APAC 2017 University Test Practice Round
- Problem B. Robot Rock Band Google APAC 2017 University Test Practice Round
- Google APAC 2016 University Graduates Test Practice Round APAC test
- Problem A. gRanks Google APAC 2016 University Test Round C
- Problem A. Travel Google APAC 2016 University Test Round B
- Problem B. gCube Google APAC 2016 University Test Round A
- Problem C. gCampus Google APAC 2016 University Test Round A
- Problem A. Country Leader Google APAC 2017 University Test Round A
- Problem C. Evaluation Google APAC 2017 University Test Round C
- Problem D. Soldiers Google APAC 2017 University Test Round C
- Problem C. Jane's Flower Shop Google APAC 2017 University Test Round A
- 网游加速器开发
- HTTP协议
- ThinkPHP之数据模型操作
- linux常见命令
- 如何退出Activity?如何安全退出已调用多个Activity的Application?
- Problem A. Lazy Spelling Bee Google APAC 2017 University Test Practice Round
- 通讯录 数据库文件读入链表 链表数据存入数据库
- PAM Chroot用法
- 题目1086:最小花费
- 配置centos所遇问题集锦
- 横竖屏切换的时候 接下来会发生生么
- STL算法_基本算法篇
- 教你理解复杂的C-C++ 指针函数声明
- java之pdf转jpg图片