Codeforces Global Round 8-B. Codeforces Subsequences(字符串,思维)
- 作者: 蒙多叫兽
- 来源: 51数据库
- 2021-08-21
题目链接
题意:
有一个只含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;
}
推荐阅读