Codeforces 653A C#写算法题
来源:互联网 发布:淘宝模特招聘58同城 编辑:程序博客网 时间:2024/06/15 09:23
前言
- 就是想用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(); } }}
0 0
- Codeforces 653A C#写算法题
- C#实现A*算法
- A*算法--C#版
- 一步一步写算法(之 A*算法)
- 一步一步写算法(之 A*算法)
- 一步一步写算法(之 A*算法)
- 一步一步写算法(之 A*算法)
- Codeforces(653A)
- CodeForces 653A【水】
- Codeforces 650A Watchmen(数学,算法优化)
- CodeForces 601A (dijkstra算法)
- 算法之路四:codeforces 1A
- 算法之路四:codeforces 4A
- 算法之路四:codeforces 71A
- A Star 算法 C# 实现
- A*算法的C#实现
- C# A*寻路算法
- A*算法写的最好的
- CDH安装报错Hive must also be configured with YARN.
- android 事件分发 拦截 (onInterceptTouchEvent dispatchTouchEvent onTouchEvent)
- 枚举enum
- codis 的dashboard服务无法启动 提示pid已经运行
- Anaconda和Pycharm安装和配置教程
- Codeforces 653A C#写算法题
- 持续集成回顾暨点滴分享[3] – 单元测试,摸索ing!
- centos6.4下scikit-learn安装经历
- 机器学习实用测试数据集
- C/C++中正反斜杠和转义字符
- 机器学习初学者入门学习资料
- 转载/配置Ehcache
- 使用Jmeter进行http接口测试
- JAVA Forward和Redirect的区别