USACO1.3.4 Combination Lock
为了防止有重复的数字,我开了个三维数组来标记,爆内存,又用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的更多相关文章
- 洛谷 P2693 [USACO1.3]号码锁 Combination Lock
P2693 [USACO1.3]号码锁 Combination Lock 题目描述 农夫约翰的奶牛不停地从他的农场中逃出来,导致了很多损害.为了防止它们再逃出来,他买了一只很大的号码锁以防止奶牛们打开 ...
- Combination Lock
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a Micr ...
- hihocoder #1058 Combination Lock
传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a ...
- 贪心 Codeforces Round #301 (Div. 2) A. Combination Lock
题目传送门 /* 贪心水题:累加到目标数字的距离,两头找取最小值 */ #include <cstdio> #include <iostream> #include <a ...
- 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 ...
- Hiho----微软笔试题《Combination Lock》
Combination Lock 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You ...
- CF #301 A :Combination Lock(简单循环)
A :Combination Lock 题意就是有一个密码箱,密码是n位数,现在有一个当前箱子上显示密码A和正确密码B,求有A到B一共至少需要滚动几次: 简单循环:
- hihocoder-第六十一周 Combination Lock
题目1 : Combination Lock 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview roo ...
- A - Combination Lock
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Scroog ...
随机推荐
- Git add和commit步骤分析
修改后或者添加新的文件,执行add命令后,首先它会先存入本地库的暂存区, add可以上传很多个文件,然后执行commit命令后,都会被提交到默认的分支 Master分支上.只有文件更改和文件新建,都可 ...
- differences between null pointer and void pointer.
These are two different concepts, you cannot compare them. What the difference between the skunk and ...
- diff and patch
A patch captures the changes of two different files (oldfile and newfile). Given the oldfile and the ...
- 在centos中部署jenkins
在centos中部署jenkins,需要的环境:安装jdk,Apache-tomcat 这两步我前面文章里已写,再次忽略 到官网下载最新的jenkins 我这里的是 jenkins.war 把该文件 ...
- 关于video.js
网址:http://www.cnblogs.com/webenh/p/5815741.html
- PHP之Zip扩展,解压缩文件,ZipArchive类
<?php $zip = new ZipArchive();//新建一个对象 /* $zip->open这个方法第一个参数表示处理的zip文件名. 第二个参数表示处理模式,ZipArchi ...
- python--windows下安装BeautifulSoup
python有很多内置的模块可以不安装使用,用起来非常方便,但是也有一些挺有用的非内置的模块不能直接使用,需要话费点力气手动安装. 进入python安装目录下的Scripts目录,查看是否有pip工具 ...
- 关于WIFI DIRECT功能的
http://processors.wiki.ti.com/index.php/WiFi_Direct_Configuration_Scripts#p2p_find https://wire ...
- 【sort】 基数排序
下面这段问答摘自csdn: 把基数排序说成桶排序应该是没有太大问题的.总的说来,应该把这一类归为分配排序,由于分配排序的一些缺陷,主要是时间代价很差,改进成为桶式排序(bucket sort),而桶排 ...
- LightOJ 1058 平行四边形的判断定理
题目大意:给你n个点,求这n个点最多能组成多少个平行四边形. 题目思路:这道题卡时间,而且卡内存.你要尽可能的想办法优化. 平行四边形的判定定理: 两组对边分别平行的四边形是平行四边形(定义判定法): ...