GCJ 2008 Round 1A Minimum Scalar Product】的更多相关文章

https://code.google.com/codejam/contest/32016/dashboard 题目大意: GCJ(google code jam)上的水题.下周二有比赛,来熟悉熟悉. 有两个向量V1=(x1,x2--xn)和v2=(y1,y2--yn),允许任意交换v1和v2各自的分量顺序,请计算v1和v2的内积x1y1+--xnyn的最小值 思路: 不同于OJ的地方在于有大和小的数据之分,且都是用文件来完成.需要自己下载测试数据,输出的数据用文件保存并且上传. 主函数最前面加…
链接:传送门 题意:给两个向量 v1 = { x1 , x2 , x3 , x4 .... } , v2 = { y1 , y2 , y3 , y4 ...... } 允许任意交换 v1 和 v2 各自向量的分量顺序,计算 v1,v2 内积 ( x1 * y1 + x2 * y2 .... )的最小值 思路:根据样例可大胆猜测内积最小值应该为 v1 的最小值 × v2 的最大值 , v1 的次小值 × v2 的次大值 ...... 也就是需要排两次序即复杂度为 O( nlogn )是可以通过大数…
Problem A. Minimum Scalar Product   This contest is open for practice. You can try every problem as many times as you like, though we won't keep track of which problems you solve. Read the Quick-Start Guide to get started. Problem You are given two v…
今天准备熟悉一下codejam的在线编程,为google的笔试做准备,因此按照codejam上对新手的建议,先用了一个简单的题目来弄清楚流程.记录一下需要注意的地方.   1.输入输出 输入输出重定位即可,拿Minimum Scalar Product这个例子示例如下: #include <iostream>#include <vector>#include <algorithm>#include <functional>#include <cstdi…
题意: 给定两组各n个数,可任意调整同一组数之中数字的顺序,求 sum xi*yi i=1..n的最小值. Small: n<=8 abs xy,yi<=1000 Large: n<=800 abs xi,yi <= 100000 假如两个数字之和为固定,那么两数字之积最大当且仅当两两数字尽量接近. 所以,直觉告诉我们——将x升序排列,y降序排列,所得对应积最大. 因为顺序可以任意调整,所以我们完全可以固定x的数字顺序,仅仅思考y的数字顺序. 验证: 当n=2时: 当仅有两个数的时…
题目描述: 请输出(3+√5)^n整数部分最后3位.如果结果不超过2位,请补足前导0. 分析: 我们最容易想到的方法肯定是直接计算这个表达式的值,但是这样的精度是不够的.朴素的算法没有办法得到答案.但是我们根据分析可以发现这个问题不用求出√5的值也可以得到答案. 我们可以发现,将(3+√5)^n这个式子展开后就是An+Bn√5的形式.同样的,我们将(3-√5)^n这个式子展开后就是An-Bn√5. 因此,(3+√5)^n+(3-√5)^n=2An是一个整数,其中0<(3-√5)^n <1,是解…
Problem C. Numbers This contest is open for practice. You can try every problem as many times as you like, though we won't keep track of which problems you solve. Read the Quick-Start Guide to get started. Small input 15 points Solve C-small   Large…
题目链接:https://code.google.com/codejam/contest/32016/dashboard#s=p0 Minimum Scalar Product This contest is open for practice. You can try every problem as many times as you like, though we won't keep track of which problems you solve. Read the Quick-St…
Problem Introduction The dot product of two sequences \(a_1,a_2,\cdots,a_n\) and \(b_1,b_2,\cdots,b_n\) of the same length is equal to \(\sum\limits_{i=1}^na_ib_i=a_1b_1+a_2b_2+\cdots+a_nb_n\) Problem Description Task.The goal is,given two sequences…
[Problem Description] Problem On the game show The Last Word, the host begins a round by showing the contestant a string S of uppercase English letters. The contestant has a whiteboard which is initially blank. The host will then present the contesta…