关注
A-Tree IV
long long tree4(long long n) {
// write code here
long long depth = (log(n) / log(2))+1;//树深度
long long result = 0;//最终结果
long long i=0;//循环下标,从[1,depth-1]
long long m=0;//循环下标,仅对depth那层处理
for(i = 1;i <= depth-1;i++)//获得前depth-1层的和
{
long long temp=static_cast<long long >(pow(2,i-1)+pow(2,i)-1) %998244353;
long long temp1=static_cast<long long >(pow(2,i)- pow(2,i-1))%998244353 ;
result+= (i * temp*temp1/2)%998244353; //求和的公式
}
for(m =pow(2,depth-1);m<=n;m++)//获得第depth层的和
{
result+=(depth*m)%998244353;
}
return result % 998244353;
}
查看原帖
4 评论
相关推荐
飞天大腚:我直接睡过头 看起来我赢了😎
点赞 评论 收藏
分享
牛客热帖
- 1... 面试反问环节怎么问!看这一篇就够了!6.6W
- 2... 10月份,还有这些国企能投1.9W
- 3... 🧧央国企笔面经全网征集令!1.3W
- 4... 关于我和我女朋友同时收到秋招意向书这件事6289
- 5... 蚂蚁,是我太菜了5235
- 6... 润回家了4668
- 7... 科大讯飞笔试09284447
- 8... 放弃敲代码做产品经理4435
- 9... 也不知道是因为我只是硕士学历,还是因为我不是男生,亦或者是因为我本科学校只是个211不管我研究生多么拼命,发了多少论文和专利,拿了多少奖学金,干了多少重点项目在茫茫简历中,依然不是被认可的那一个即使有幸进面,也只是众多备选中的一条迟迟得不到回应的小鱼从来没有这么累过突然开始觉得,不是所有努力都能有好的结果但是除了比昨天更加拼命喝努力,我找不到别的方法3558
- 10... 算法笔试骗分,不会做也能过50%样例3044
正在热议
# 0offer互助地 #
104509次浏览 1137人参与
# 数据人offer决赛圈怎么选 #
85057次浏览 1172人参与
# 建信金科校招 #
19343次浏览 249人参与
# 国央企求职进展汇总 #
13545次浏览 63人参与
# 银行笔面经互助 #
4655次浏览 93人参与
# 比亚迪求职进展汇总 #
360734次浏览 2023人参与
# 埃科光电开奖 #
15358次浏览 233人参与
# 你的简历改到第几版了 #
583149次浏览 8622人参与
# 投递实习岗位前的准备 #
1046880次浏览 16880人参与
# 汇川技术求职进展汇总 #
49505次浏览 423人参与
# 运营人的第一份offer应该如何选 #
66230次浏览 802人参与
# 滴滴求职进展汇总 #
12933次浏览 161人参与
# 毕业季,你想好怎么跟生活对线了吗? #
114130次浏览 2593人参与
# 硬件人的简历怎么写 #
187425次浏览 2464人参与
# 产品薪资爆料 #
68989次浏览 721人参与
# 小米硬件提前批进度交流 #
135965次浏览 1382人参与
# 哪些公司面试官让你印象深刻? #
70712次浏览 724人参与
# 浅聊一下我实习的辛苦费 #
160516次浏览 1457人参与
# 腾讯求职进展汇总 #
83692次浏览 784人参与
# 机械/制造每日一题 #
41977次浏览 890人参与
# 通信硬件投递记录 #
282470次浏览 6450人参与
# OPPO求职进展汇总 #
462526次浏览 4102人参与