Codeforces 270c Magical Boxes
来源:互联网 发布:首席数据官 能力描述 编辑:程序博客网 时间:2024/03/29 21:49
http://codeforces.com/contest/270/problem/C
每个箱子边长为2的幂,4个小箱子可以放入一个大箱子,给出每种箱子的边长和个数,求将它们全部装下的箱子的最小边长。
一步步推,现将手头上小箱子装入大箱子。
A magical box v can be put inside a magical box u, if side length of v is strictly less than the side length of u. In particular,
哪怕只有1个,大箱子也要比它大。
用pow要快的多。。。
#include <iostream>#include<cstdio>#include<algorithm>#include<cmath>#include<cstdlib>using namespace std;#define N 100005struct po{ int k,a;}b[N];bool cmp(const struct po &x,const struct po &y){ return x.k<y.k;}int main(){ int n; scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d%d",&b[i].k,&b[i].a); sort(b+1,b+n+1,cmp); int num=b[1].a; for (int i=2;i<=n;i++) { num=ceil( (double)num/pow(4.0,b[i].k-b[i-1].k) ); if (num<b[i].a) num=b[i].a; } double n1=num; int ans; if (num==1) ans=b[n].k+1; else ans=b[n].k+ceil(log(n1)/log(4.0)); printf("%d\n",ans); return 0;}
- Codeforces 270c Magical Boxes
- CODEFORCES 270C Magical Boxes <<小箱子装大箱子>>
- Codeforces 270C Magical Boxes【排序+进制处理】
- Codeforces #165 div2 C. Magical Boxes
- A. Magical Boxes
- codeforces 903C. Boxes Packing
- Codeforce -269 - A. Magical Boxes
- CodeForces 390C Inna and Candy Boxes
- codeforces 390c Inna and Candy Boxes
- codeforces 551 C GukiZ hates Boxes
- codeforces 390C Inna and Candy Boxes
- 【24.67%】【codeforces 551C】 GukiZ hates Boxes
- Codeforces 821 C. Okabe and Boxes
- Codeforces 821C-Okabe and Boxes
- Codeforces 821C Okabe and Boxes 题解
- codeforces 420 div2 C Okabe and Boxes
- Codeforces#420 C. Okabe and Boxes
- 【Codeforces 821C. Okabe and Boxes】
- 塔式起吊机是怎么安装的?
- Java关键字final、static使用总结
- C/C++拾遗录--关于一个C语言小程序的分析
- 中文分词
- istringstream
- Codeforces 270c Magical Boxes
- java 多态
- [C++] next_permutation的函数 与 copy() 函数的用法
- OpenCV Hog+SVM 学习
- 读《Effectove MySQL之SQL语句最优化》的感想
- js eval
- [心灵] 我对这个世界充满了想象力和好奇心
- Java中使用ResourceBundle访问资源文件(properties文件)
- linux 安装ATI显卡驱动时问题