题目链接:1.3.4

为了防止有重复的数字,我开了个三维数组来标记,爆内存,又用vector标记,爆内存...

不得不感慨这份代码.

/*
ID:wang9621
PROG:combo
LANG:C++
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
int n;
bool close(int a,int b)
{
if(abs(a-b)<=||abs(a-b)>=(n-)) return true;
return false;
}
bool judge(int m1,int m2,int m3,int n1,int n2,int n3)
{
return close(m1,n1)&&close(m2,n2)&&close(m3,n3);
}
int main()
{
freopen("combo.in","r",stdin);
freopen("combo.out","w",stdout);
scanf("%d",&n);
int a,b,c;
int e,f,g;
cin>>a>>b>>c;
cin>>e>>f>>g;
int count = ;
for(int i = ; i<=n; i++)
for(int j = ; j<=n; j++)
for(int k = ; k<=n; k++)
if(judge(i,j,k,a,b,c)||
judge(i,j,k,e,f,g))
count++;
printf("%d\n",count);
return ;
}

USACO1.3.4 Combination Lock的更多相关文章

  1. 洛谷 P2693 [USACO1.3]号码锁 Combination Lock

    P2693 [USACO1.3]号码锁 Combination Lock 题目描述 农夫约翰的奶牛不停地从他的农场中逃出来,导致了很多损害.为了防止它们再逃出来,他买了一只很大的号码锁以防止奶牛们打开 ...

  2. Combination Lock

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a Micr ...

  3. hihocoder #1058 Combination Lock

    传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a ...

  4. 贪心 Codeforces Round #301 (Div. 2) A. Combination Lock

    题目传送门 /* 贪心水题:累加到目标数字的距离,两头找取最小值 */ #include <cstdio> #include <iostream> #include <a ...

  5. Codeforces Round #301 (Div. 2) A. Combination Lock 暴力

    A. Combination Lock Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/p ...

  6. Hiho----微软笔试题《Combination Lock》

    Combination Lock 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You ...

  7. CF #301 A :Combination Lock(简单循环)

    A :Combination Lock 题意就是有一个密码箱,密码是n位数,现在有一个当前箱子上显示密码A和正确密码B,求有A到B一共至少需要滚动几次: 简单循环:

  8. hihocoder-第六十一周 Combination Lock

    题目1 : Combination Lock 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview roo ...

  9. A - Combination Lock

    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description Scroog ...

随机推荐

  1. Git 开发新的功能分支

    软件开发中,总有无穷无尽的新的功能要不断的添加进来.添加一个新功能时,你肯定不希望因为一些实验性质的代码把主分支搞乱了, 所以每添加一个新功能,最好新建一个feature分支,在上面开发,完成后,合并 ...

  2. UI篇—UITableview

    一.基本介绍 在众多移动应⽤用中,能看到各式各样的表格数据 . 在iOS中,要实现表格数据展示,最常用的做法就是使用UITableView,UITableView继承自UIScrollView,因此支 ...

  3. 昨天上架出现问题,you binary is not optimized for iphone5.。。。。

    这个时候只需要加一个lanuch image 就可以了

  4. 缩放系列(二):所有子控件也随着缩放、手势缩放、多点触控layout

    下面是一个功能强大的改造的例子: 可以实现以下需求: 1.两个手指进行缩放布局 2.所有子控件也随着缩放, 3.子控件该有的功能不能丢失(像button有可被点击的功能,缩放后不能丢失该功能) 运行效 ...

  5. hibernate ——关联关系

    1.一对一单向外键关联 <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC ...

  6. white-space详解

    white-space共有5种属性normal,nowrap,pre,pre-wrap,pre-line 网上的解释多半过于详细冗长,先做个简化处理,以便查询 normal    忽略空白  过长换行 ...

  7. 8.4 sikuli 集成进eclipse 报错:Unsupported major.minor version 51.0

    8.3中的问题Win32Util.dll: Can't load 32-bit .dll on a AMD 64 bit platform  解决之后,执行还是会有报错:Unsupported maj ...

  8. UVA - 10635 最长公共子序列

    input n,p,q 2<=n<=250 1<=p,q<=n*n 1 a1 a2 a3 ... ap 1<ai<n*n,ai!=aj 1 b1 b2 b3 ... ...

  9. 无线手柄+步进电机——控制方向

    今天测试了一下无线手柄控制电机转向的改变 1: #include <PS2X_lib.h> //for v1.6 2: #include <Stepper.h> 3:  4: ...

  10. Struts2 请求数据的自动封装 及 自定义转换器类

    请求数据自动封装: 实现原理:使用了参数拦截器.struts-default.xml中 <interceptor name="params" class="com. ...