Codeforces 653A C#写算法题
2016-04-13 14:28
288 查看
前言
就是想用c#实现一个网络流算法,但是怕有问题,又懒得手写测试(喂)。。。所以就想在codeforces上过点模板题试试。。但是从没有交过c#的题,这次就写个水题试一试。。感觉c#写题好麻烦。。
题意
给你n个数,问你存在不存在3个连续的数思路
hash一下,然后遍历所有hash值,连续3个不为0就yes实现
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DTATest { class Program { static List<int> array = new List<int>(1005); static void Main(string[] args) { for (int i = 0; i <= 1004; i++) array.Add(0); int n =Int32.Parse(Console.ReadLine()); String str = Console.ReadLine(); var input = str.Split(' '); foreach (var iter in input) { array[Int32.Parse(iter)]++; } bool flag = false; for (int i = 0; i < 1000;i++ ) { if (array[i] > 0 && array[i + 1] > 0 && array[i + 2] > 0) { Console.WriteLine("Yes"); flag = true; break; } } if (!flag) Console.WriteLine("No"); Console.Read(); } } }
相关文章推荐
- C#控件及常用属性整理【详细版】
- C#常见设置方法
- C#浮点数保留两位小数的方法
- C#默认以管理员身份运行程序
- C#枚举硬件设备(升级版)
- C# 访问USB(HID)设备
- C#按日期年月日分別寫入記錄
- C#版 Socket编程(最简单的Socket通信功能)
- C# Socket编程 同步以及异步通信
- C# 读取数据表没有主键的问题
- Skyline创建三维管线两种方式(C#)
- [译]C#编码约定
- C#基础总结
- 用Open XML SDK 获取PPT标题和内容(C#)
- 转:C# 读取EXCEL文件的三种经典方法
- C#学习笔记---方法
- 地球坐标-火星坐标-百度坐标及之间的转换算法 C#
- c#学习已经停止了
- c# int数组与string数组一样定义
- C#编码标准