Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from w…
排序.把每一个长方体拆成$6$个做,然后排序做即可. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #inc…
D. Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a frien…
Kostya the Sculptor 这次cf打的又是心累啊,果然我太菜,真的该认真学习,不要随便的浪费时间啦 [题目链接]Kostya the Sculptor &题意: 给你n个长方体,你要使长方体的内切球有体积最大,有两种选择方案 ①只选1个长方体. ②选2个长方体,黏到一起,但这2个长方体黏的那一面必须完全相等.也就是长宽相等. &题解: 1个长方体遍历一遍取最小就好了. 2个的时候要第2短的和第3短的相等,才能合到一起,最小的有可能是2个最小的相加,或者是第2短的那个. 这题比…
D. Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a frien…
Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Z…
Kostya the Sculptor 题目链接:http://codeforces.com/problemset/problem/733/D 贪心 以次小边为第一关键字,最大边为第二关键字,最小边为第三关键字排序,每次只需要找次小边和最大边均相同,最小边最大的两项即可. 因为用Python遇到很多问题,切片操作a[i:j]是左闭右开区间[i,j) 代码如下: n = int(input()) a = [] ans,u,v = 0,-1,-1 for i in range(n): t = [in…
题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include<bits/stdc++.h> using namespace std; typedef unsigned long long ull; ; ull base[maxbit], n, k; void preDeal() { ] = ; ; i < maxbit; i++){ *]; } } voi…
[Codeforces 1214A]Optimal Currency Exchange(贪心) 题面 题面较长,略 分析 这个A题稍微有点思维难度,比赛的时候被孙了一下 贪心的思路是,我们换面值越小的货币越优.如有1,2,5,10,20,50,那么我们尽量用面值为1的.如果我们把原始货币换成面值为x的货币,设汇率为d,那么需要的原始货币为dx的倍数.显然dx越小,剩下的钱,即n取模dx会尽量小. 然后就可以枚举换某一种货币的数量,时间复杂度\(O(\frac{n}{d})\) 代码 #inclu…
http://codeforces.com/contest/733/problem/D 给定n个长方体,然后每个长方体都能选择任何一个面,去和其他长方体接在一起,也可以自己一个,要求使得新的长方体的最短的那条边最大. 看样例2就知道,因为10.8.7和10.8.2组合后,min =  8,是最大的. 那么怎么做呢? 可以看到,一个长方体,能产生6种不同的摆放方式,然后排序后,排序的时候把a相同的尽可能排在一起,把b相同的尽可能地排在一起.因为这样就能分组了. 把数组分成若干组,相同的组里,a和b…