HOJ 12822 The Alphabet Sticker
来源:互联网 发布:w7如何连接网络打印机 编辑:程序博客网 时间:2024/06/15 20:46
AC代码:
#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <string>#include <cmath>#include <assert.h>#include <algorithm>#define MAX 1234567890#define MIN -1234567890#define exps 1e-8#define MOD 1000000007using namespace std;char* ptr;char tmp[10008];char str[10008];int i, len;int cnt(){ int c = 0; while (str[i] == '?') { c++; i++; } i--; return c + 1;}int main(){ #ifdef BellWind freopen("A.in", "r", stdin); #endif // BellWind int t; scanf("%d", &t); for (int k = 0; k < t; k++) { long long ans = 1; memset(str, 0, sizeof(str)); scanf("%s\n", tmp); ptr = tmp; int tlen = strlen(tmp); int l = 0; while (tmp[l] == '?') {l++;} int r = tlen - 1; while (tmp[r] == '?') {r--;} int j; for (j = l, i = 0; j <= r; i++, j++) str[i] = tmp[j]; str[i] = '\0'; len = strlen(str);// cout << len << endl;// printf("%s\n", str); for (i = 0; i < len; i++) { if(str[i] == '?') { char ch1 = str[i-1]; int tmpn = cnt(); char ch2 = str[i+1]; if (ch1 != ch2) ans = ((ans % MOD) * (tmpn % MOD)) % MOD; } } printf("%d\n", ans); } return 0;}
0 0
- HOJ 12822 The Alphabet Sticker
- HOJ 12822 The Alphabet Sticker
- POJ 1231 The Alphabet Game
- poj 1231 The Alphabet Game
- Alphabet
- [暴力搜索]poj1231 The Alphabet Game
- POJ 1231 The Alphabet Game 笔记
- HOJ The Colored Cubes
- HOJ 3074 The Position
- HOJ 2785 The Game
- Hoj 1140 The Game
- Hoj 1760 The jackpot
- hoj Counting the algorithms
- hoj 2430 Counting the algorithms
- HOJ 2100 Beat the Spread!
- HOJ 2546 The right time
- Hoj 2991 Find the Point
- [DP]HOJ 1760The jackpot
- hdu 1754 I Hate It
- 使用OSChina代码托管管理项目(一)
- JavaScript语言学习以及部分ThreeJs分析
- IDC:给企业建站租用服务器的建议
- 如何用VS2010 MFC制作一个简单的加法器
- HOJ 12822 The Alphabet Sticker
- linux目录权限为“777”时绿色过亮字体看不清问题
- Android开发学习1 - Android架构
- What you may need to know while calling Application Module methods from Java EE components such as E
- 关于hive RegexSerDe的源码分析
- Java基础温习 (7)Java抽象类和接口的学习
- windows系统调用int 2e处理过程
- 互联网时代,企业培训管理如何创新?
- Reorder List