码迷,mamicode.com
首页 > 其他好文 > 详细

UVA10763:Foreign Exchange&&UVA10340: All in All(水题)

时间:2015-02-04 00:26:12      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:

10763:水题不解释直接贴代码。

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define eps 1e-9
typedef long long ll;
using namespace std;
int n;
int d[500100];
int main()
{
    int xx,yy;
    while(scanf("%d",&n)!=EOF&&n!=0)
    {
        memset(d,0,sizeof(d));
        for(int i=0;i<n;i++)
        {
            scanf("%d%d",&xx,&yy);
            d[xx]--;
            d[yy]++;
        }
        bool ff=false;
        for(int i=1;i<=500000;i++)
        {
            if(d[i])
            {
                printf("NO\n");
                ff=true;
                break;
            }
        }
        if(!ff) printf("YES\n");
    }
    return 0;
}

10340:判断a串是不是b串的子串。水题。

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define eps 1e-9
typedef long long ll;
using namespace std;
char a[1000001],b[1000001];
int main()
{
    while(scanf("%s%s",a,b)!=EOF)
    {
        int t=0;
        int l1=strlen(a);
        int l2=strlen(b);
        for(int i=0;i<l2;i++)
        {
            if(a[t]==b[i])
            {
                t++;
            }
            if(t==l1) break;
        }
        if(t==l1) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

 

UVA10763:Foreign Exchange&&UVA10340: All in All(水题)

标签:

原文地址:http://www.cnblogs.com/zhangmingcheng/p/4271354.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!