当前位置:网站首页>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;
}边栏推荐
- Idea Download
- D 小红的构造题
- Analysis of the implementation principle of an open source markdown to rich text editor
- 2022年建筑架子工(建筑特殊工种)特种作业证考试题库及在线模拟考试
- Clear timer failure
- C#获取WebService接口的所有可调用方法[WebMethod]
- 2022 question bank and answers for operation certificate examination of safety production management personnel in road transport enterprises
- Gets or sets the content in an object
- SEO specification
- Notes on software test for programmers -- basic knowledge of software development, operation and maintenance
猜你喜欢

PowerShell: because running scripts is prohibited on this system, the solution

记录一次排查问题的经过——视频通话无法接起

Colab tutorial (super detailed version) and colab pro/pro+ evaluation

Day 007: go language string

一致性哈希的简单认识

Colab使用教程(超级详细版)及Colab Pro/Pro+评测

Small program input element moving up

PowerShell:因为在此系统上禁止运行脚本,解决方法

2022 ICML | Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets

C disk lossless move file
随机推荐
Analysis of the implementation principle of an open source markdown to rich text editor
Mongodb compass connects to the Alibaba cloud remote server database or reports an error occurred while loading instance info: command hostinfo req
Go/golang connection to database
是“凯撒密码”呀。(*‘▽‘*)*
Message scrolling JS implementation
Common terms of electromagnetic compatibility
How to implement a custom jdbc driver in only four steps?
H5 the blue background color appears when clicking the picture
php 18 首页的文章列表功能实现
The problem that ionic3 cannot automatically install the APK package
PHP security development 15 user password modification module
C#获取WebService接口的所有可调用方法[WebMethod]
2022 oxidation process operation certificate examination question bank and simulation examination
The processing flow of thread pool depends on the core parameters
Online audio adjustment technology summary
Ctfshow SQL injection (211-230)
Introduction to applet Basics (dark horse learning notes)
Express framework knowledge - Art template template, cookie, session
【JS解决】leedcode 200. 岛屿数量
Ctfshow common postures (821-830)