Codeforces374B
B. Inna and Nine
1 second
256 megabytes
standard input
standard output
Inna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9.
Inna wants to slightly alter the number Dima wrote so that in the end the number contained as many digits nine as possible. In one move, Inna can choose two adjacent digits in a number which sum equals 9 and replace them by a single digit 9.
For instance, Inna can alter number 14545181 like this: 14545181 → 1945181 → 194519 → 19919. Also, she can use this method to transform number 14545181 into number 19991. Inna will not transform it into 149591 as she can get numbers 19919 and19991 which contain more digits nine.
Dima is a programmer so he wants to find out how many distinct numbers containing as many digits nine as possible Inna can get from the written number. Help him with this challenging task.
Input
The first line of the input contains integer a (1 ≤ a ≤ 10100000). Number a doesn't have any zeroes.
Output
In a single line print a single integer — the answer to the problem. It is guaranteed that the answer to the problem doesn't exceed 263 - 1.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64dspecifier.
Examples
input
369727
output
2
input
123456789987654321
output
1
input
1
output
1
Note
Notes to the samples
In the first sample Inna can get the following numbers: 369727 → 99727 → 9997, 369727 → 99727 → 9979.
In the second sample, Inna can act like this: 123456789987654321 → 12396789987654321 → 1239678998769321.
//2016.11.19
#include <iostream>
#include <cstdio> using namespace std;
const int N = 1e5+;
int num[N], sum[N]; int main()
{
string str;
while(cin >> str)
{
long long ans = ;
int n = str.length();
for(int i = ; i < n; i++)
{
num[i] = str[i]-'';
if(i==)sum[i] = ;
else sum[i] = num[i] + num[i-];
}
for(int i = ; i < n; i++)
{
int cnt = ;
while(sum[i] == )
{
cnt++;
i++;
}
if(cnt && cnt%==)ans*=(cnt/+);
}
cout<<ans<<endl;
}
return ;
}
Codeforces374B的更多相关文章
随机推荐
- 合并BIN文件的两种方法(转)
源:http://blog.chinaunix.net/uid-20745340-id-1878803.html 合并BIN文件的两种方法 在单片机的开发过程中,经常需要将两个单独的BIN文件合并成一 ...
- ural1028 Stars
Stars Time limit: 0.25 secondMemory limit: 64 MB Astronomers often examine star maps where stars are ...
- Android 4.0 ICS SystemUI浅析——StatusBar结构分析
Android 4.0 ICS SystemUI浅析——StatusBar结构分析 分类: Android2012-06-30 14:45 23687人阅读 评论(8) 收藏 举报 androidsi ...
- [iOS Animation]-CALayer 视觉效果
视觉效果 嗯,圆和椭圆还不错,但如果是带圆角的矩形呢? 我们现在能做到那样了么? 史蒂芬·乔布斯 我们在第三章『图层几何学』中讨论了图层的frame,第二章『寄宿图』则讨论了图层的寄宿图.但是图层不仅 ...
- 单片机裸机下写一个自己的shell调试器
该文章是针对于串口通讯过程中快速定义命令而写的,算是我自己的一个通用化的平台,专门用来进行串口调试用,莫要取笑 要处理串口数据首先是要对单片机的串口中断进行处理,我的方法是正确的命令必须要在命令的结尾 ...
- ListView与RadioButton组合——自定义单选列表
标签: radiobuttonlistviewandroidlayout 2013-09-10 11:13 19396人阅读 评论(8) 收藏 举报 分类: Android(19) 版权声明: ...
- Laravel 用户验证Auth::attempt fail的问题
1.在laravel项目中,当使用Auth::attempt()用于用户验证时,Auth::attempt()会把密码通过Hash进行转换,变成一串不知啥的长字符,如果你在数据库里事先设置了明文的密码 ...
- P4语言编程快速开始 实践二
参考:P4语言编程快速开始 上一篇系列博客:P4语言编程快速开始 实践二 Demo 2 本Demo所做的修改及实现的功能: 为simple_router添加一个计数器(counter),该计数器附加( ...
- 1602A液晶
液晶显示屏中,1602型算是比较简单的一种,据说和12864还是全兼容的.这两天学习的结果如下.一.1602里的存储器有三种:CGROM.CGRAM.DDRAM.CGROM保存了厂家生产时固化在LCM ...
- Leetcode 182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...