完全k叉树

谜之WA

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll k,n;
ll res=;
ll check()
{
ll ans=;
ll t=1ll;
ll b=k-;
while((t*k-)/b<n)t*=k,ans++;
// if(t*k<0)puts(0);
res=n-(t-)/b;
if(res==)
{
res=;
return ans;
}
if(res>t/k)res=;
else res=;
return ans;
}
int main()
{
ll t;
cin>>t;
while(t--)
{
res=;
cin>>k>>n; //else
if(k==)cout<<n-<<'\n';
//else if(k>1000000000)puts(0);
else
{
ll x=check();
if(res)cout<<x+x<<'\n';
else cout<<x+(x-)<<'\n';
}
}
}

AC:

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll k,n;
ll res=;
ll check()
{
ll ans=;
ll t=; while(t<n)n-=t,t*=k,ans++;
//ll a=1; // if(t*k<0)puts(0);
res=n;
//cout<<res<<'\n';
if(res==)
{
res=;
return ans-;
}
if(res>t/k)res=;
else res=;
return ans;
}
int main()
{
ll t;
cin>>t;
while(t--)
{
res=;
cin>>k>>n; //else
if(k==)cout<<n-<<'\n';
//else if(k>1000000000)puts(0);
else
{
ll x=check();
if(res)cout<<x+x<<'\n';
else cout<<x+(x-)<<'\n';
}
}
}

最新文章

  1. 基於tiny4412的Linux內核移植--- 中斷和GPIO學習(1)
  2. Mac 开发者常用的工具
  3. easyui 中重复加载两次url
  4. 在MyEclipse上搭建web服务器
  5. 安装wampserver出现“The Program can&#39;t start because MSVCR110.dll is missing from your computer. Try reinstalling the program to fix this problem”
  6. python time 模块详解
  7. 转:推荐!国外程序员整理的 C++ 资源大全
  8. Java过滤器Filter使用详解
  9. Django 系列博客(十一)
  10. selenium测瀑布流UI页面的Python代码
  11. Coffee and Coursework (Easy version)
  12. c# 遍历类中的方法名称
  13. ViewDragHelper
  14. Xshell中vim退出内容仍停留在屏幕的问题
  15. vue版本冲突解决办法
  16. VS Code 中文注释显示乱码 解决方法
  17. C和指针第七章第五题
  18. 接触mybatis使用
  19. texlive2018和texstudio的安装及汉化教程
  20. centos7最小化安装后配置笔记

热门文章

  1. React-onsenui之RouterNavigator组件解读
  2. java 泛型深入
  3. Web高级 JavaScript中的数据结构
  4. 2019寒假作业二:PTA7-1币值转换
  5. 【sql server复制】不重新初始化快照的情况下新增表/存储过程/函数等
  6. 对第一个HelloWorld程序的总结:
  7. 使用内核LED框架搭建驱动 ——led_classdev_register
  8. [常用类]String 类
  9. IETester——用来测试IE5.5~IE11兼容性的工具
  10. uve (mui/light7)写APP的使用心得(大坑);