zoukankan      html  css  js  c++  java
  • UVa 10340

    题目

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1281


    题意

    问字符串a能否是字符串b的子序列

    思路

    明显,计数对的上就行

    感想

    因为忘了break错了一次 

    代码

    #include <algorithm>
    #include <cassert>
    #include <cmath>
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <map>
    #include <queue>
    #include <set>
    #include <string>
    #include <tuple>
    #define LOCAL_DEBUG
    using namespace std;
    typedef pair<int, int> MyPair;
    
    int main() {
    #ifdef LOCAL_DEBUG
        freopen("C:\Users\Iris\source\repos\ACM\ACM\input.txt", "r", stdin);
        //freopen("C:\Users\Iris\source\repos\ACM\ACM\output.txt", "w", stdout);
    #endif // LOCAL_DEBUG
        int T;
        string a, b;
        for (int ti = 1;cin>>a>>b; ti++) {
            int sza = 0, szb = 0;
            for (sza = 0, szb = 0; sza < a.size() && szb < b.size(); sza++, szb++) {
                while (szb < b.size() && a[sza] != b[szb]) { szb++; }
                if (szb >= b.size())break;
            }
            if (sza == a.size())puts("Yes");
            else puts("No");
        }
    
        return 0;
    }
    View Code
  • 相关阅读:
    五、MongoDB的索引
    四、MongoDB的查询
    各模块启动
    HBase1.2.6 javaapi查看rowkey 所在分区等信息
    HBase1.2.6 预分区后,数据不进入预定分区的一个 bug
    SparkStreaming程序设计
    SparkSQL程序设计
    Spark SQL概述
    常用RDD
    spark程序设计
  • 原文地址:https://www.cnblogs.com/xuesu/p/10463059.html
Copyright © 2011-2022 走看看