I love string,SpringCloud微服务详解

**Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)

Total Submission(s): 2070    Accepted Submission(s): 965**

Problem Description

Mr X likes to play string games.

Mr X has an operation sequence. This operation sequence can be written as a string. For each operation, the next character of the operation sequence can be inserted before or after the current string. For example, my operation sequence is “aabac”, suppose the sequence obtained after the first four operations is “baaa”, then after the last operation, the string may become “baaac” or “cbaaa”. It can be seen that there is only one operation method for the first operation. For other operations, there are only two methods of operation.

For each operation method, there will be a score. The smaller the lexicographic order of the final string, the higher the final score.

Then, for a given operation sequence, how many operation methods can get the maximum score.

The two operation methods are different. If and only if there is a certain operation (not the first operation), one operation will be inserted before the current string, and the other operation will be inserted after the current string.

Input

Enter a positive integer T (T≤10) on the first line to represent the number of test cases.

For each test case:

the first line contains a integer n (1≤n≤100000) to represent the length of the string.

the second line contains a string of lowercase letters , which represents the sequence of operations.

Output

For each test case, output a line of a positive integer to represent the number of schemes, and the answer is modulo 1000000007

Sample Input

1

5

abcde

Sample Output

1

题解

这题在写的时候就发现了,只要判断前面几个是否是一个字母

如果是就算出有多少个就行

然后用快速幂来乘

得出最后的结果

代码


#include<iostream>

#define ll long long 

using namespace std;

ll fastPower(ll base, ll power,ll mod) {//快速幂 

    ll result = 1;



### 最后

### **[CodeChina开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频】](https://codechina.csdn.net/m0_60958482/java-p7)**

![](https://img-blog.csdnimg.cn/img_convert/dff92c27d5214a04439cbb22a8d5f0fb.png)

![](https://img-blog.csdnimg.cn/img_convert/a521671fb568290bf9f2c15321deb45e.png)

![](https://img-blog.csdnimg.cn/img_convert/f8fa0a58022988d6b8c0b737346026b2.png)

![](https://img-blog.csdnimg.cn/img_convert/bd541a704de10721c8536bd8ecab17f4.png)

![](https://img-blog.csdnimg.cn/img_convert/8fa072a8aedd74929a8b1a5821e448a4.png)

![](https://img-blog.csdnimg.cn/img_convert/e22d9be786786fb56c2135ffa14769fe.png)


由于篇幅原因,就不多做展示了
片转存中...(img-RJGorZ4D-1630817123459)]

[外链图片转存中...(img-V0t5Ughw-1630817123461)]

[外链图片转存中...(img-DUOgYdUB-1630817123462)]


由于篇幅原因,就不多做展示了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值