codejam环境熟悉—Minimum Scalar Product
今天准备熟悉一下codejam的在线编程,为google的笔试做准备,因此按照codejam上对新手的建议,先用了一个简单的题目来弄清楚流程。记录一下需要注意的地方。
1.输入输出
输入输出重定位即可,拿Minimum Scalar Product这个例子示例如下:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std; int main()
{
freopen("A-large-practice.in","r",stdin);
freopen("output.in","w",stdout); int caseNum;
int curVectorLen;
typedef long long longType;
longType curTotal;
cin>>caseNum;
for(int i=0;i<caseNum;++i)
{
cin>>curVectorLen; vector<int> vec1(curVectorLen,0);
vector<int> vec2(curVectorLen,0); for(int j=0;j<curVectorLen;j++)
{
cin>>vec1[j];
} for(int j=0;j<curVectorLen;j++)
{
cin>>vec2[j];
} sort(vec1.begin(),vec1.end());
sort(vec2.begin(),vec2.end()); curTotal=0LL;
for(int j=0;j<curVectorLen;++j)
{
curTotal+=(longType)vec1[j]*vec2[curVectorLen-1-j];
} cout<<"Case #"<<i+1<<": "<<curTotal<<endl; } return 0;
}
可知,平时的OJ环境默认输出现在转到了文件读取和写入。转换的关键代码如下:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std; int main()
{
freopen("A-large-practice.in","r",stdin);
freopen("output.in","w",stdout); //正常的cin和cout
return 0;
}
2.关于Minimum Scalar Product
注意溢出问题就好了。两个int类型乘的时候注意强制类型转换一下。
codejam环境熟悉—Minimum Scalar Product的更多相关文章
- [Google Code Jam (Round 1A 2008) ] A. Minimum Scalar Product
Problem A. Minimum Scalar Product This contest is open for practice. You can try every problem as ...
- GCJ 2008 Round 1A Minimum Scalar Product
https://code.google.com/codejam/contest/32016/dashboard 题目大意: GCJ(google code jam)上的水题.下周二有比赛,来熟悉熟悉. ...
- GCJ——Minimum Scalar Product(2008 Round1 AA)
题意: 给定两组各n个数,可任意调整同一组数之中数字的顺序,求 sum xi*yi i=1..n的最小值. Small: n<=8 abs xy,yi<=1000 Large: n< ...
- GCJ 2008 Round 1A Minimum Scalar Product( 水 )
链接:传送门 题意:给两个向量 v1 = { x1 , x2 , x3 , x4 .... } , v2 = { y1 , y2 , y3 , y4 ...... } 允许任意交换 v1 和 v2 各 ...
- GCJ:2008 Round1AA-Minimum Scalar Product(有序数组倒序乘积和最小)
题目链接:https://code.google.com/codejam/contest/32016/dashboard#s=p0 Minimum Scalar Product This contes ...
- [UCSD白板题] Minimum Dot Product
Problem Introduction The dot product of two sequences \(a_1,a_2,\cdots,a_n\) and \(b_1,b_2,\cdots,b_ ...
- 20165304实验一java开发环境熟悉
实验报告封面 一.实验报告封面 课程:Java程序设计 班级:1653班 姓名:李松杨 学号:20165304 指导教师:娄嘉鹏 实验日期:2018年4月2日 实验时间:13:45 - 15:25 实 ...
- intellij idea 初步环境熟悉
刚进来天渔项目组,连开发环境都是新的,学习至上 so 从eclipse过度过来还是有段时间的,期间虽然懵懂,但是也要坚持不耻下问 好了一下是idea的官网http://confluence.jetbr ...
- minimum viable product
w https://en.wikipedia.org/wiki/Minimum_viable_product
随机推荐
- CListView虚拟列表
首先说下虚拟列表出现的原因: 数据量比较小的时候,对于CListView控件可以直接使用InsertItem并配合SetItemText函数来插入并修改数据.这样操作很直接. 但是,如果数据量比较大了 ...
- BZOJ 1257 余数之和sum
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1257 题意:计算sigama(m%i)(1<=i<=n). 思路: 这样就简 ...
- 第7篇 ORACLE EBS DEMO虚拟机环境的安装
ERP信息系统的实施不仅要求懂得道理方面的知识,更要侧重于应用实践.为了有一个稳定的测试环境.初学者可以自己搭建一个EBS DEMO环境.本节介绍EBS DEMO环境虚拟机的安装.一. 安装前的准备( ...
- 一、导入、导出远程Oracle数据库
一.导入.导出远程Oracle数据库 其语法实示例如下: imp/exp [username[/password[@service]]] 其中service是服务实例名,关于如何创建服务实 ...
- 转载 近期微博吐槽言论存档,涉及“性能优化”、C++陋习等
http://blog.csdn.net/solstice/article/details/9923615 近期微吐槽博言论存档,涉及“性能优化”.C++陋习等 写C++程序的几个陋习:class 名 ...
- How to install Node.js on Linux
How to install Node.js on Linux Posted on November 13, 2015 by Dan Nanni Leave a comment Question: H ...
- java线程安全理解
java线程安全理解 如果你的代码所在的进程中有多个线程在同时运行,而这些线程可能会同时运行这段代码.如果每次运行结果和单线程运行的结果是一样的,而且其他的变量的值也和预期的是一样的,就是线程安全的. ...
- OpenStack(0) - Table of Contents
1. Keystone OpenStack Identity Service2. Starting OpenStack Image Service3. Starting OpenStack Compu ...
- java多线程模拟停车系统
import java.util.Random; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent ...
- jquery中html()/text()/val()区别
html就是你可以添加<span></span><li></li>的标记text只能写文本如果写了上面的标记则会以文本形式输出,就是输出标签体的内容va ...