首页 > 代码库 > UVA10763:Foreign Exchange&&UVA10340: All in All(水题)

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

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

#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>#include <math.h>#include <queue>#define eps 1e-9typedef 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-9typedef 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(水题)