CodeForces 374 B. Inna and Nine

Inna想要从一个包含数字1到9的数中最大化数字九的数量。通过选择相邻且和为9的两个数字并替换为单个9,她能实现这一目标。此挑战包括输入一个数a,并输出通过上述操作后能获得的最大数字九数量的唯一可能数。此外,解释了Inna如何将14545181变换为99919,以及解决此问题的策略。


B. Inna and Nine
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Inna loves digit9very 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 numbera, consisting of digits from1to9.

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 equals9and replace them by a single digit9.

For instance, Inna can alter number14545181like this:14545181 → 1945181 → 194519 → 19919. Also, she can use this method to transform number14545181into number19991. Inna will not transform it into149591as she can get numbers19919and19991which 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 integera(1 ≤ a ≤ 10100000). Numberadoesn'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 exceed263 - 1.

Please, do not use the%lldspecifier to read or write 64-bit integers in С++. It is preferred to use thecin,coutstreams or the%I64dspecifier.

Sample test(s)
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.


xyxyxy....xy 时有1种变换方法
xyxyxy....xyx 时可以空出任意一个x
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>

using namespace std;

string a;

int main()
{
    unsigned long long int cnt=1;
    cin>>a;
    unsigned long long int len=a.size();
    unsigned long long int last=1;
    for(int i=0;i<len;i++)
    {
        if(a[i]=='9') continue;
        if(a[i]+a[i+1]==9+2*'0') last++;
        else if(last)
        {
            if(last%2) cnt*=(last+1)/2;
            last=1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}




【四轴飞行器】非线性三自由度四轴飞行器模拟器研究(Matlab代码实现)内容概要:本文围绕非线性三自由度四轴飞行器模拟器的研究展开,重点介绍基于Matlab代码实现的四轴飞行器动力学建模与仿真方法。研究构建了考虑非线性特性的飞行器数学模型,涵盖姿态动力学与运动学方程,实现了三自由度(滚转、俯仰、偏航)的精确模拟。文中详细阐述了系统建模过程、控制算法设计思路及仿真结果分析,帮助读者深入理解四轴飞行器的飞行动力学特性与控制机制;同时,该模拟器可用于算法验证、控制器设计与教学实验。; 适合人群:具备一定自动控制理论基础和Matlab编程能力的高校学生、科研人员及无人机相关领域的工程技术人员,尤其适合从事飞行器建模、控制算法开发的研究生和初级研究人员。; 使用场景及目标:①用于四轴飞行器非线性动力学特性的学习与仿真验证;②作为控制器(如PID、LQR、MPC等)设计与测试的仿真平台;③支持无人机控制系统教学与科研项目开发,提升对姿态控制与系统仿真的理解。; 阅读建议:建议读者结合Matlab代码逐模块分析,重点关注动力学方程的推导与实现方式,动手运行并调试仿真程序,以加深对飞行器姿态控制过程的理解。同时可扩展为六自由度模型或加入外部干扰以增强仿真真实性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值