ICPC Pacific Northwest Regional Contest 2019-------E

https://nanti.jisuanke.com/t/45349

1000ms

262144K

Define a string to be a rainbow string if every letter in the string is distinct. An empty string is also considered a rainbow string.Given a string of lowercase letters, compute the number of different subsequences which are rainbow strings. Two subsequences are different if an index is included in one subsequence but not the other, even if the resulting strings areidentical.

In the first example, there are 8 subsequences. The only subsequences that aren't rainbow strings are aaaa and aabaab.The remaining 6 subsequences are rainbow strings.

input

The input will consist of a single line with a single string consisting solely of lowercase letters. The length of the stringis between 1 and 100 000 (inclusive).

output

Write on a single line the number of rainbow sequences, modulo the prime 11092019.

样例输入1复制

aab

样例输出1复制

6

样例输入2复制

icpcprogrammingcontest

样例输出2复制

209952

题意:所有由不同字符组成的子串有多少个。

思路:就是求当前字符串中所有字符有多少种排列组合,转化为知道所有质因子,利用算术基本定理,求因数的个数。

#include<iostream>
#include<cstring>
#include<map>
#define ll long long

using namespace std;

const int mod = 11092019;

map<char,int> mp;

int main()
{
	string s;
	cin>>s;
	for(int i=0; i<s.size(); i++)
	{
		mp[s[i]]++;
	}
	ll ans = 1;
	for(auto a : mp)
	{
		ans = (ans *(1 + a.second)) % mod;
	}
	cout<<ans;
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值