当前位置:网站首页>aaaaaaaaaaA heH heH nuN
aaaaaaaaaaA heH heH nuN
2022-07-25 11:14:00 【梦中醉卧惊起】
aaaaaaaaaaA heH heH nuN
题意:
规定一个字符串芳香的前缀是nunhehheh,后缀是数量个的a;给定一个n ,找出有n个芳香子序列的字符串。
思路:
nunhehheh + a * x,有2^x - 1个有效子序列
nunhehhe hhhha ,有p个h,则有p个有效子序列
那么在最后一个a前面加一个h就可以构成2 ^ x个有效子串
例如 haha == 4 haaha == 8
直接对应到2进制,所以我们直接枚举有多少个二进制位有1,然后在最前面那个a后面加h和对应二进制位上加h(即a与a之间的空位)即可构造
AC代码:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <string.h>
using namespace std;
int s[50];
void solve(){
int n;cin >> n;
bitset<33>q(n);
memset(s,0,sizeof s);
if(q.test(0)) s[1] ++;
for(int i = 1;i <= 31;i ++)
if(q.test(i)) s[i]++,s[1]++;
cout << "nunhehhe";
for(int i = 31;i > 0;i --){
for(int j = 0;j < s[i];j ++)
cout << "h";
cout << "a";
}
cout << endl;
return;
}
int main(){
int t;cin >> t;
while(t --){
solve();
}
return 0;
}
边栏推荐
- brpc源码解析(三)—— 请求其他服务器以及往socket写数据的机制
- 【Debias】Model-Agnostic Counterfactual Reasoning for Eliminating Popularity Bias in RS(KDD‘21)
- Attendance system based on w5500
- [RS sampling] a gain tuning dynamic negative sampler for recommendation (WWW 2022)
- Intelligent information retrieval(智能信息检索综述)
- 【AI4Code】《IntelliCode Compose: Code Generation using Transformer》 ESEC/FSE 2020
- Brpc source code analysis (I) -- the main process of RPC service addition and server startup
- 【AI4Code】《InferCode: Self-Supervised Learning of Code Representations by Predicting Subtrees》ICSE‘21
- 【高并发】我用10张图总结出了这份并发编程最佳学习路线!!(建议收藏)
- 任何时间,任何地点,超级侦探,认真办案!
猜你喜欢

GPT plus money (OpenAI CLIP,DALL-E)

微信公众号开发 入手

brpc源码解析(四)—— Bthread机制

brpc源码解析(二)—— brpc收到请求的处理过程

Power Bi -- these skills make the report more "compelling"“

brpc源码解析(五)—— 基础类resource pool详解

Video Caption(跨模态视频摘要/字幕生成)

【RS采样】A Gain-Tuning Dynamic Negative Sampler for Recommendation (WWW 2022)

'C:\xampp\php\ext\php_ zip. Dll'-%1 is not a valid Win32 Application Solution

【6篇文章串讲ScalableGNN】围绕WWW 2022 best paper《PaSca》
随机推荐
brpc源码解析(五)—— 基础类resource pool详解
剑指 Offer 22. 链表中倒数第k个节点
已解决 Files‘ name is invalid or does not exist (1205)
【MySQL 17】安装异常:Could not open file ‘/var/log/mysql/mysqld.log‘ for error logging: Permission denied
小程序image 无法显示base64 图片 解决办法 有效
[MySQL 17] installation exception: could not open file '/var/log/mysql/mysqld log‘ for error logging: Permission denied
Introduction to redis
【无标题】
【AI4Code】《Unified Pre-training for Program Understanding and Generation》 NAACL 2021
Arrays in JS
php curl post Length Required 错误设置header头
brpc源码解析(四)—— Bthread机制
[untitled]
对比学习的应用(LCGNN,VideoMoCo,GraphCL,XMC-GAN)
How to solve the problem of the error reported by the Flink SQL client when connecting to MySQL?
[multimodal] transferrec: learning transferable recommendation from texture of modality feedback arXiv '22
Return and finally? Everyone, please look over here,
【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)
JS中的函数
30套中国风PPT/创意PPT模板