FOJ 1001 Duplicate Pair (位图算法)
来源:互联网 发布:后窗知乎 编辑:程序博客网 时间:2024/03/29 21:47
FOJ 1001 Duplicate Pair (位图算法)
Problem 1001 Duplicate Pair
Accept: 5374 Submit: 25613
Time Limit: 1000 mSec Memory Limit : 65536 KB
Problem Description
An array of length n, with address from 1 to n inclusive, contains entries from the set {1,2,...,n-1} and there's exactly two elements with the same value. Your task is to find out the value.
Input
Input contains several cases.
Each case includes a number n (1<n<=10^6), which is followed by n integers.
The input is ended up with the end of file.
Each case includes a number n (1<n<=10^6), which is followed by n integers.
The input is ended up with the end of file.
Output
Your must output the value for each case, one per line.
Sample Input
21 141 2 3 2
Sample Output
12
,证明之前已经有这个数了,把他打印出来就OK了。
#include<stdio.h>int a[1000010];int main(){ int n; while(~scanf("%d",&n)) { int j; for(int i=0; i<n; i++) { a[i]=0; } for(int i=0; i<n; i++) { scanf("%d",&j); if(a[j]==0) { a[j]=1; } else { printf("%d\n",j); } } } return 0;}但是这个题有个大坑啊,我陷在里面好久了,整整交了10次还是错,前一次是因为我用了俩层循环超时了,后面的几次全是Runtime Error这个错误,很是尴尬啊,我想了老长时间才发现的,原来是数组太大得开在外面,为啥呢,因为开在外面是全局的数组,计算机为其开辟的内存空间更大。这样就不会出现内存访问违规这个运行错误了。
0 0
- FOJ 1001 Duplicate Pair (位图算法)
- FOJ-1001-Duplicate Pair
- FZU 1001 Duplicate Pair(简单题目)
- Problem 1001 Duplicate Pair
- FZU 1001 Duplicate Pair
- fzu 1001 Duplicate Pair
- FZU 1001 Duplicate Pair
- Problem 1001 Duplicate Pair
- Problem 1001Duplicate Pair
- Duplicate Pair
- Duplicate Pair
- Duplicate Pair(异或操作)
- FOJ 1408 位图
- Foj 1408 位图
- FOJ 1001之位图数据结构对程序的优化
- 位图bitmap算法(java)
- 位图bitmap算法(java)
- 算法思想——单调队列(Foj志愿者问题)
- [置顶] 将博客搬至CSDN
- 基于IMOOC强力django+杀手级xadmin 打造上线标准的在线教育平台课程的学习(13)——xadmin介绍
- Android案例-用户登录记住密码
- 修改环境变量
- git ssh生成
- FOJ 1001 Duplicate Pair (位图算法)
- 20170402"尚学堂杯"哈尔滨理工大学第七届程序设计竞赛ABCDFG题解
- tensorflow的基本用法(三)
- Android ADB工具详解
- Activity加载模式
- 盒子模型和css属性
- Emacs使用笔记
- Android集成QQ登录
- 漫步数理统计十二——随机变量的期望