Ternary String (规律+欧拉降幂 )牛客

博客探讨了一个自我繁殖的ternary字符串问题,即每秒按照特定规则增长,然后首字符消失。目标是求字符串变为空字符串所需的时间,并对结果取模(10^9 + 7)。提供了解题思路的链接。
摘要由CSDN通过智能技术生成

A ternary string is a sequence of digits, where each digit is either 0, 1, or 2.
Chiaki has a ternary string s which can self-reproduce. Every second, a digit 0 is inserted after every 1 in the string, and then a digit 1 is inserted after every 2 in the string, and finally the first character will disappear.
For example, 212 will become 11021 after one second, and become 01002110 after another second.
Chiaki would like to know the number of seconds needed until the string become an empty string. As the answer could be very large, she only needs the answer modulo (109 + 7).
题意: 有一串数字串s,只包含三个数字0,1,2,每过一分钟,先是每个2后面会产生一个1,每个1后面会产生一个0,然后串头第一个数字会消失,

问经过多少秒,整个串全部消失。
思路: https://www.cnblogs.com/dilthey/p/9411125.html 附上优秀题解

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Mod=1e9+7;
int c[105];
map<ll,ll>mp;
string s;
ll phi(ll n)
{
   
	ll res=n;
	for(int i=2;i
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值