博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The Solution of UESTC 2016 Summer Training #1 Div.2 Problem A
阅读量:5242 次
发布时间:2019-06-14

本文共 1344 字,大约阅读时间需要 4 分钟。

Link

http://acm.hust.edu.cn/vjudge/contest/121539#problem/A

Description

standard input/output 

Haneen is trying to solve an easy problem given by Dr. Ibrahim in the Algorithms course. The problem is to find the lexicographically smallest Longest Common Subsequence (LCS) between two strings. Unfortunately, she got many runtime errors. After tens of wrong submissions, she asked Master Hazem about the problem and he replied:

"C strings are terminated with the null character ‘\0’. When you want to store a string of length N, the size of the array should be at leastN + 1."

Haneen didn’t get anything of what he said, and now, she is in need of your help! Given the length of the string Haneen has, determine the minimum size of an array needed to store this string.

Input

The input contains a single integer N(1 ≤ N ≤ 105), the length of the string.

Output

Print the minimum size of an array needed to store the string.

Sample Input

Input
3
Output
4
Input
7
Output
8
Input
64
Output
65

Solution

This is an easy question.The description of the problem has told us C strings usually prepare an extra space for the null character '\0'.So,just input an integer n,then output n+1.

C++ Code

#include<iostream>

using namespace std;
int main()
{
  int n;
  cin>>n;
  cout<<n+1<<endl;
  return 0;
}

转载于:https://www.cnblogs.com/cs-lyj1997/p/5712732.html

你可能感兴趣的文章
Dreamweaver cc新版本css单行显示
查看>>
【android】安卓的权限提示及版本相关
查看>>
JavaScript可否多线程? 深入理解JavaScript定时机制
查看>>
IOS基础学习
查看>>
PHP 导出 Excell
查看>>
Java基础教程——网络基础知识
查看>>
Kruskal基础最小生成树
查看>>
ubuntu 14.04 安装搜狗拼音输入法
查看>>
浅谈算法和数据结构: 一 栈和队列
查看>>
Java内部类详解
查看>>
【hdu 1429】胜利大逃亡(续)
查看>>
图论-次短路求法
查看>>
What's New for Visual C# 6.0
查看>>
ExtJs学习笔记之ComboBox组件
查看>>
关于收费软件
查看>>
getopt_long
查看>>
TensorFlow MNIST CNN 代码
查看>>
javascript之Style物
查看>>
JSON跨域解决方案收集
查看>>
SSH框架整合总结
查看>>