公式
A - Required Length 解説
by
A - Required Length 解説
by
mechanicalpenciI
問題文に従って、文字列 \(P\) の長さが \(L\) 以上であるかを判定すれば良いです。
c++ の std::string であれば、メンバ関数 std::size() 、Python の str 型 であれば組み込み関数 len() など、多くの文字列型には文字列の長さを求める関数が標準で用意されているため、それを用いて判定を行うことができます。
これと if 文を組み合わせることによってこの問題を解くことができます。
c++ の実装例:
#include <bits/stdc++.h>
using namespace std;
int main() {
string p;
int l;
cin>>p;
cin>>l;
if(p.size()>=l)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
Python の実装例
p=input()
l=int(input())
if len(p)>=l:
print("Yes")
else:
print("No")
投稿日時:
最終更新:
