Problem B: Ternarian Weights
2024-08-27 02:16:59
大致题意:使用三进制砝码采取相应的措施衡量出给定的数字
主要思路:三进制,如果 大于 2 向前进位,之前一直没写好放弃了,这次终于写好了……
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <cctype> const double Pi = atan() * ; using namespace std;
long long base[] = {,,,,,,,,,,,,,,,,,,,,,};
int a[];
int tt[];
int main()
{
//freopen("input.in","r",stdin);
//freopen("output.in","w",stdout);
int n;
cin >> n;
while(n--){
int x;
cin >> x;
memset(a,,sizeof(a));
memset(tt,,sizeof(tt));
int tmp = x;
while(tmp){
a[++a[] ] = tmp % ;
tmp /= ;
}
for(int i = ;i <= a[];i++){
if(a[i] == ){
a[i+]++;
a[] = max(i+,a[]);
tt[ ++tt[] ] = i;
a[i] = ;
}
if(a[i] == ){
a[i+]++;
a[] = max(i+,a[]);
a[i] = ;
}
}
cout << "left pan:";
for(int i = tt[];i > ;i--){
cout << " " << base[ tt[i] ];
}
cout << endl;
cout << "right pan:";
for(int i = a[];i > ;i--){
if(!a[i])
continue;
cout << " " << base[i];
}
cout << endl;
if(n)
cout << endl;
}
return ;
}
最新文章
- Ubuntu 16 安装ElasticSearch
- QT中检索设定目录下所有指定文件的方法
- ZeroMQ接口函数之 :zmq_init - 初始化ZMQ环境上下文
- Qt中2D绘图问题总结(二)----------坐标系统
- javascript中的自增与自减
- oracle中=>;是什么意思
- PIL(Python Image Library)生成验证码
- 图片左右循环连续滚动代码,解决marquee的留白问题
- Linux Curl常用命令使用【转】
- Servlet--超链接,表单提交,重定向,转发4种情况的路径
- AOP的相关概念
- How to change Eclipse loading image
- Wavelet Ridgelet Curvelet Contourlet Ripplet
- 2018年尚硅谷《全套Java、Android、HTML5前端视频》
- 卖给高通之后的CSR的现状和未来
- hostswap dcevm
- Apache提供的dbUtils
- 添加mysqld、apache服务到windows服务
- 20170706xlVBA根据工资汇总表生成个人工资条
- Fire Game 双向bfs
热门文章
- ecshop后台添加栏目
- poj 1363 Rails in PopPush City &;&;【求堆栈中合法出栈顺序次数】
- 【深圳,武汉】一加科技(One Plus)招聘,寻找不...
- quant_百度百科
- [Android] FileInputStream跟踪
- zoj 2277 The Gate to Freedom
- QTP的基本功能介绍
- 用Swift完成不同View Controller之间的切换
- AOP编程
- Fix Windows 7 Msvcp71.dll And Msvcr71.dll Missing Error