当前位置:网站首页>Construction problem of D Xiaohong
Construction problem of D Xiaohong
2022-06-13 04:39:00 【I would like to have egg yolk and meat dumplings】
Portal :
D Xiao Hong's construction problem
The question : Construct a length that does not exceed 2e5 String of , Make it include k individual “red” Subsequence .(k<=1e14)
analysis : At first, I wanted to get together rreedd This string , Then add the letters . However, the newly added letters have aftereffect and the number of subsequences cannot be added 1, be unable to do sth. .
consider rrrededed This string , Again only again ed Before to add r, Then add... At any position r There will be no aftereffect . If r Yes x individual , So this string has x*(x+1)*x/2 Subsequence , obviously x The length of is pow(1e14,1/3.0) Level , The remaining k The length of x^2 The level of . After that in each ed Add one before r, Will increase i(i+1)/2 Subsequence , And no aftereffect . As if ,- The largest square number is also a function of rapid numerical descent ? Run fast anyway .
Code :
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
// cout<<pow(1e14,1/3.0)<<endl;
int k;
cin>>k;
int x=0;
while(1)
{
if(x*x*(x+1)/2>k)
{
x--;
break;
}
else x++;
}
cout<<x<<endl;
k-=x*x*(x+1)/2;
for(int i=1;i<=x;i++)
{
cout<<"r";
}
// int cnt=0;
for(int i=x;i>=1;i--)
{
while(k>=i*(i+1)/2)
{
k-=i*(i+1)/2;
cout<<"r";
// cnt++;
}
cout<<"ed";
}
cout<<endl;
// cout<<cnt<<endl;
}
边栏推荐
猜你喜欢
力扣刷题338.比特位计数
Powershell 加域 Add-Computer模块
Hugo blog building tutorial
PowerShell plus domain add computer module
【Flutter 問題系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 彈窗中不能二次跳轉路由問題的解决方案
The data obtained from mongodb query data command is null
Redis
Analyse du principe de mise en œuvre d'un éditeur de texte open source markdown - to - rich
Normal distribution (Gaussian distribution)
Common terms of electromagnetic compatibility
随机推荐
Express framework knowledge - Art template template, cookie, session
用navicat将mysql数据转化为postgresql
Nodejs parsing get request URL string
Li Kou brush question 338 Bit count
Serial communication learning
Ionic Cordova command line
Solve the problem of running server nodemon reporting errors
Common terms of electromagnetic compatibility
php开发16退出模块
你的一对一会议效率低下,你可以这么做!
Catalan number
Third party comment plugin
推荐的图片临时在线压缩工具
2022 ICLR | CONTRASTIVE LEARNING OF IMAGE- AND STRUCTURE BASED REPRESENTATIONS IN DRUG DISCOVERY
[flutter problem Series Chapter 67] the Solution to the problem of Routing cannot be jumped again in in dialog popup Using get plug - in in flutter
Tita:新锐集团采用一对一面谈推动绩效变革成功
D 小红的构造题
JS, how to add grid style
Collection of wrong questions in soft test -- morning questions in the first half of 2011
Introduction to applet Basics (dark horse learning notes)