大致题意:使用三进制砝码采取相应的措施衡量出给定的数字
主要思路:三进制,如果 大于 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 ;
}

Problem B: Ternarian Weights的更多相关文章

  1. HNU 13073 Ternarian Weights 解题报告

    本题大意: 用天平对一物品进行称重,现有重量不同的砝码,砝码的重量分别为:1,3,9,27,..,3^n.(n<20) 天平的右侧放砝码,左侧放物品或物品和砝码,使得左右两边的重量相等. 现有一 ...

  2. Problem F Free Weights

    二分答案. 思路:对于二分给定的mid,即当前允许移动的最大重量,我们可以把小于改重量的标记一下,然后把没有标记的按照顺序放到另一个数组,然后判断是否满足两两相同. #include<bits/ ...

  3. Deep Learning in a Nutshell: History and Training

    Deep Learning in a Nutshell: History and Training This series of blog posts aims to provide an intui ...

  4. CF #296 (Div. 1) B. Clique Problem 贪心(构造)

    B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  5. Codeforces #270 D. Design Tutorial: Inverse the Problem

    http://codeforces.com/contest/472/problem/D D. Design Tutorial: Inverse the Problem time limit per t ...

  6. [codeforces 528]B. Clique Problem

    [codeforces 528]B. Clique Problem 试题描述 The clique problem is one of the most well-known NP-complete ...

  7. UVa 10154 - Weights and Measures

    UVa 10154 - Weights and Measures I know, up on top you are seeing great sights,  But down at the bot ...

  8. poj 1679 http://poj.org/problem?id=1679

    http://poj.org/problem?id=1679 The Unique MST Time Limit: 1000MS   Memory Limit: 10000K Total Submis ...

  9. Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉

    Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

随机推荐

  1. ZOJ2971 Give Me the Number 【模拟】

    这道题目使用Map. 然后一次性遍历下来即可. QAQ 注意初始化的时候小心点不要错.. Source Code: //#pragma comment(linker, "/STACK:167 ...

  2. bresenham算法的FPGA的实现1

    接着上一篇的 计算实现给出屏幕上任意两个点,求出这两个点之间直线上的所有的点.http://www.cnblogs.com/sepeng/p/4042464.html 这种直接算法的确是被鄙视了 强大 ...

  3. QT 静态编译后中文可能会出现乱码

    QT 静态编译后中文可能会出现乱码.这是因为处理文字编码的 libqcncodecs 库是以 plugin 形式存放在 QT 静态编译目录/plugs/codecs/libqcncodecs.a 文件 ...

  4. 基于visual Studio2013解决算法导论之023队列实现(基于数组)

     题目 基于数组的队列 解决代码及点评 #include <stdio.h> #include <stdlib.h> #include <time.h> #i ...

  5. MapReduce调度与执行原理之任务调度(续)

    前言 :本文旨在理清在Hadoop中一个MapReduce作业(Job)在提交到框架后的整个生命周期过程,权作总结和日后参考,如有问题,请不吝赐教.本文不涉及Hadoop的架构设计,如有兴趣请参考相关 ...

  6. UNIX环境高级编程——进程管理和通信(总结)

    进程管理与通信 进程的管理 进程和程序的区别: 进程: 程序的一次执行过程   动态过程,进程的状态属性会发生变化 程序:存放在磁盘上的指令.数据的有序集合  是个文件,可直观看到 程序program ...

  7. 《Java并发编程实战》第十四章 构建自己定义的同步工具 读书笔记

    一.状态依赖性的管理 有界缓存实现的基类 @ ThreadSafe public abstract class BaseBoundedBuffer<E> { @GuardeBy( &quo ...

  8. Delphi发送邮件...

    ///首先在控件栏定位到:Indy Clients加入控件IdSMTP ///再定位到:Indy Misc加入控件IdMessage ///发送邮件函数 procedure TForm1.SendMa ...

  9. iconv 文件编码转换

    iconv 文件编码转换 http://www.cnblogs.com/xuxm2007/archive/2010/11/09/1872379.html 查看iconv的支持的编码: $ iconv  ...

  10. Netty开发实现高性能的RPC服务器

    Netty开发实现高性能的RPC服务器 RPC(Remote Procedure Call Protocol)远程过程调用协议,它是一种通过网络,从远程计算机程序上请求服务,而不必了解底层网络技术的协 ...