题目链接: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. Ubuntu14.04+cuda 7.5+cudnn_v4+tensorflow安装

    系统环境:Ubuntu14.04 64位.Windows7 64位 双系统 CUDA 版本: 7.5 总结一下,我的安装建议是: 一定要下一份CUDA官方的安装文档,按照它的步骤一步步慢慢来,不可偷懒 ...

  2. cisco 2950 3550 3750 系列交换机密码破解

    破解密码原则:只删除密码 ,不破坏配置#本文中的#号表示注释的意思#第一步. 连接交换机的console口到终端#第二步. 按住交换机面板上的mode键的同时 插入电源,直到sys灯不闪,常亮再松开m ...

  3. Qt::ConnectionType(信号与槽的传递方式)

    Qt::AutoConnection 自动连接:(默认值)如果信号在接收者所依附的线程内发射,则等同于直接连接.如果发射信号的线程和接受者所依附的线程不同,则等同于队列连接. Qt::DirectCo ...

  4. laravel5.3初体验

    composer中已经推出了laravel5.3版本的安装依赖. 看到很多诱人的更新,今天决定尝试一下. 背景 操作系统:windows7 php:5.5.37 composer:1.1.3 1.首先 ...

  5. arm的编译器里已经有C标准库的lib包了,android为啥还要自己再实现呢

    arm的编译器里已经有C标准库的lib包了,android为啥还要自己再实现呢 google自己搞的bionic libc来替代glibc想来是有原因的,本来glibc也是lgpl,应该也没有版权问题 ...

  6. gre tunnel

    http://searchenterprisewan.techtarget.com/tip/GRE-tunnel-vs-IPsec-tunnel-What-is-the-difference Enca ...

  7. ignite客户端找不到服务端的时候如何设置退出

    ignite启动客户端时需要有服务端支持: Ignition.setClientMode(true); Ignition.start("ignite.xml"); 这里有个问题,当 ...

  8. CSS中如何把Span标签设置为固定宽度

    一.形如<span>ABC</span>独立行设置SPAN为固定宽度方法如下: span {width:60px; text-align:center; display:blo ...

  9. Hibernate 系列教程13-继承-鉴别器与内连接相结合

    Employee public class Employee { private Long id; private String name; HourlyEmployee public class H ...

  10. PHP5.4 for Apache, php 5.4.0安装过程、方法、配置 ; Apache2.2支持php5.4的配置方法

    那我们如何选择下载哪个版本的PHP呢?如果你是在windows下使用Apache+PHP的,请选择VC6版本:如果你是在windows下使用IIS+PHP的,请选择VC9版本. 二.如何选择PHP5. ...