当前位置: 移动技术网 > 移动技术>移动开发>IOS > Codeforces Global Round 8-B. Codeforces Subsequences(字符串,思维)

Codeforces Global Round 8-B. Codeforces Subsequences(字符串,思维)

2020年07月09日  | 移动技术网移动技术  | 我要评论

题目链接

题意:

有一个只含codeforces的字符串,你可以改变其中任意字母的数量使得其中所包含的完整codeforces字串的数量(子串可以不连续)。

思路:

每次每一个字符加1,然后每个字符的数量想乘就是完整codeforces字串的数量。

代码:

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=2e5+7;
const int mod=998244353;
const int inf=0x7fffffff;
const double pi=3.1415926535;
using namespace std;
char s[15]={"codeforces"};
signed main() 
{
	int k,sum=1;
	cin>>k;
	if(k==1)
    {
		cout<<s;
		return 0;
	}
	for(int i=2;i<100;i++) 
    {
		for(int j=0;j<10;j++)
		{
			sum=sum/(i-1)*i;
			if(sum>=k)
			{
				for(int h=0;h<=j;h++)
				{
					for(int u=0;u<i;u++)
                    {
						cout<<s[h];
					}
				}
				for(int h=j+1;h<10;h++)
                {
					for(int u=0;u<i-1;u++)
					{
						cout<<s[h];
					}
				}
				return 0;
			} 
		}
	}
	return 0;
}

本文地址:https://blog.csdn.net/ACkingdom/article/details/107214846

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网