Problem B: Ternarian Weights
大致题意:使用三进制砝码采取相应的措施衡量出给定的数字
主要思路:三进制,如果 大于 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的更多相关文章
- HNU 13073 Ternarian Weights 解题报告
本题大意: 用天平对一物品进行称重,现有重量不同的砝码,砝码的重量分别为:1,3,9,27,..,3^n.(n<20) 天平的右侧放砝码,左侧放物品或物品和砝码,使得左右两边的重量相等. 现有一 ...
- Problem F Free Weights
二分答案. 思路:对于二分给定的mid,即当前允许移动的最大重量,我们可以把小于改重量的标记一下,然后把没有标记的按照顺序放到另一个数组,然后判断是否满足两两相同. #include<bits/ ...
- 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 ...
- 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 ...
- 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 ...
- [codeforces 528]B. Clique Problem
[codeforces 528]B. Clique Problem 试题描述 The clique problem is one of the most well-known NP-complete ...
- 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 ...
- 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 ...
- Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
随机推荐
- QuartusII 中使用Modelsim对子程序进行仿真
QuartusII 中使用Modelsim对子程序进行仿真 如果采用RTL级仿真那么就没有任何问题,但是如果对子程序采用门级仿真就会出错 解决办法:在Project Navigator中右键需要进行门 ...
- 【.Net基础拾遗】品味OO继承
0X1 引言 提起面向对象,每个人都有不同的见解.但提的最多的无非就是:对象.封装.继承.多态.差不多就是这些元素构成了面向对象设计开发的基本逻辑.面向对象编程,“对象”指的是什么?这里的" ...
- JAVA平台上的网络爬虫脚本语言 CrawlScript
JAVA平台上的网络爬虫脚本语言 CrawlScript 网络爬虫即自动获取网页信息的一种程序,有很多JAVA.C++的网络爬虫类库,但是在这些类库的基础上开发十分繁琐,需要大量的代码才可以完成一 个 ...
- hdu 4063 Aircraft(计算几何+最短路)
不说了...说多了都是泪...从昨天下午一直wa到现在,直到刚刚才让人帮我找到所谓的“bug”,其实也算不上bug... 这个题的思路就是:找出平面上的所有点:所有圆的交点以及所有圆的圆心.然后依次判 ...
- 更换Winform 皮肤(下)----完全GDI+绘制
skin皮肤和DLL程序及文件:下载 链接:http://www.cnblogs.com/DebugLZQ/archive/2013/04/15/3021659.html
- 我的Python成长之路---第二天---Python基础(8)---2016年1月9日(晴)
数据类型之字典 一.字典简介 字典dict(dictionary),在其他语言中也成为map,使用键-值(key-value)的形式存储和展现,具有极快的查找速度. 字典的定义 d = {'key': ...
- char s[]字串和char *s字串有什麼区别?
C語言有兩種字串宣告方式char s[]和char *s,兩者有什麼差異呢? Introduction char s[] = "Hello World"; (只是用字符串常量初始化 ...
- Tri_integral Summer Training 9 总结
比赛链接 A B C D H I J K 多灾多难的 Summer Training 9,前一天挂了一场比赛,结果题一半不能做,于是打了一个小时就放弃了.之后的两场Summer Training 9一 ...
- centos7安装codeblocks教程
author:lidabo 装了好多次系统,每次装的时候都有要在网上各种查,太麻烦了.所以决定记录一下,以后用到的时候会方便一些.当然,本文来源于网络,取百家之长,最重要的是本人已验证过,说明对本系统 ...
- linux下shutdown无法关闭tomcat进程的解决方式
1.问题 笔者在linux下发现使用tomcat6.0.41自带的./shutdown.sh常常无法停止进程,导致各种问题的发生,令笔者相当反感! 2.解决方式一: 查找到全部的tomcat进程 $ ...