• 8 3 个人赛


    c

    One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.

    But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name.

    It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita".

    Names are case sensitive.

    Input

    The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem.

    Output

    Print "YES", if problem is from this contest, and "NO" otherwise.

    Examples

    Input

    Alex_and_broken_contest

    Output

    NO

    Input

    NikitaAndString

    Output

    YES

    Input

    Danil_and_Olya

    Output

    NO

    题意:他的朋友只能出现一个  且只能出现一次

    今天下午刚学了string的用法 本来很高兴的写完了  交上去啦  wrong answer。。。。

    //此代码没有ac
    #include <algorithm>
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <vector>
    using namespace std;
    typedef long long ll;
    ll ans[1000];
    int main()
    {
        string s;
        string s1="Danil";
        string s2="Olya";
        string s3="Slava";
        string s4="Ann";
        string s5="Nikita";
        ll x=0,y=0,z=0,p=0,q=0;
        cin>>s;
        if(s.find(s1)!=-1)
            x++;
        if(s.find(s2)!=-1)
            y++;
        if(s.find(s3)!=-1)
            z++;
        if(s.find(s4)!=-1)
            p++;
        if(s.find(s5)!=-1)
            q++;
        if(x==1&&y==0&&z==0&&p==0&&q==0)
            printf("YES
    ");
        else
        if(x==0&&y==1&&z==0&&p==0&&q==0)
            printf("YES
    ");
        else
        if(x==0&&y==0&&z==1&&p==0&&q==0)
            printf("YES
    ");
        else
        if(x==0&&y==0&&z==0&&p==1&&q==0)
            printf("YES
    ");
        else
        if(x==0&&y==0&&z==0&&p==0&&q==1)
            printf("YES
    ");
        else
            printf("NO
    ");
        //count<<s1<<" "<<s2<<" "<<s3<<" "<<s4<<" "<<s5<<" "<<endl;
        //count<<x<<" "<<y<<" "<<z<<" "<<p<<" "<<q<<endl;
        return 0;
    }

    然后好一番试样例  输出  突然发现问题了  。。。 我的程序只能找一次  即使++ 也不会变成2  果断换方法  虽然笨  但是对了

    #include <algorithm>
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <vector>
    using namespace std;
    typedef long long ll;
    char s[1000];
    int main()
    {
        ll i,n;
        memset(s,0,sizeof(s));
        gets(s);
        n=strlen(s);
        ll x=0,y=0,z=0,p=0,q=0;
        for(i=0;i<n;i++)
        {
            if(s[i]=='D'&&s[i+1]=='a'&&s[i+2]=='n'&&s[i+3]=='i'&&s[i+4]=='l')
                x++;
            if(s[i]=='O'&&s[i+1]=='l'&&s[i+2]=='y'&&s[i+3]=='a')
                y++;
            if(s[i]=='S'&&s[i+1]=='l'&&s[i+2]=='a'&&s[i+3]=='v'&&s[i+4]=='a')
                z++;
            if(s[i]=='A'&&s[i+1]=='n'&&s[i+2]=='n')
                p++;
            if(s[i]=='N'&&s[i+1]=='i'&&s[i+2]=='k'&&s[i+3]=='i'&&s[i+4]=='t'&&s[i+5]=='a')
                q++;
        }
        if(x==1&&y==0&&z==0&&p==0&&q==0)
            printf("YES
    ");
        else
        if(x==0&&y==1&&z==0&&p==0&&q==0)
            printf("YES
    ");
        else
        if(x==0&&y==0&&z==1&&p==0&&q==0)
            printf("YES
    ");
        else
        if(x==0&&y==0&&z==0&&p==1&&q==0)
            printf("YES
    ");
        else
        if(x==0&&y==0&&z==0&&p==0&&q==1)
            printf("YES
    ");
        else
            printf("NO
    ");
       // printf("%lld %lld %lld %lld %lld",x,y,z,p,q);
        return 0;
    }

    然后知道啦可以再找到的赋值1 。。

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cmath>
    #include<map>
    #include<queue>
    #include<stack>
    #include<cstring>
    #include<vector>
    using namespace std;
    typedef long long LL;
    const int MAXN=2e5+10;
    int main()
    {
        int g=0,e=0;
        string s;
        cin>>s;
    
    
        if(s.find("Nikita")!=-1) e++;
        if(s.find("Danil")!=-1)  e++;
        if(s.find("Olya")!=-1)   e++;
        if(s.find("Ann")!=-1)    e++;
        if(s.find("Slava")!=-1)  e++;
    
    
        int t;
        t=s.find("Danil");
        if(t!=-1)
        {
            s[t]='1';
            if(s.find("Danil")==-1)
                g++;
        }
        t=s.find("Olya");
        if(t!=-1)
        {
            s[t]='1';
            if(s.find("Olya")==-1)
                g++;
        }
        t=s.find("Slava");
        if(t!=-1)
        {
            s[t]='1';
            if(s.find("Slava")==-1)
                g++;
        }
        t=s.find("Ann");
        if(t!=-1)
        {
            s[t]='1';
            if(s.find("Ann")==-1)
                g++;
        }
        t=s.find("Nikita");
        if(t!=-1)
        {
            s[t]='1';
            if(s.find("Nikita")==-1)
                g++;
        }
    
    
        if(g==1&&e==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
        return 0;
    }

    D

    Even if the world is full of counterfeits, I still regard it as wonderful.

    Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.

    The phoenix has a rather long lifespan, and reincarnates itself once every a! years. Here a! denotes the factorial of integer a, that is, a! = 1 × 2 × ... × a. Specifically, 0! = 1.

    Koyomi doesn't care much about this, but before he gets into another mess with oddities, he is interested in the number of times the phoenix will reincarnate in a timespan of b! years, that is, . Note that when b ≥ a this value is always integer.

    As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the answer in decimal representation. And you're here to provide Koyomi with this knowledge.

    Input

    The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 1018).

    Output

    Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.

    Sample Input

    Input

    2 4

    Output

    2

    Input

    0 10
    

    Output

    0

    Input

    107 109

    Output

    2

    Hint

    In the first example, the last digit of is 2;

    In the second example, the last digit of is 0;

    In the third example, the last digit of is 2.

    只要有一个10  就为0   举个例子  1024的最后一位是0  因为他其中有个10

    #include <algorithm>
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <vector>
    using namespace std;
    typedef long long ll;
    ll ans[1000];
    int main()
    {
        ll a,b,i,c=1;
        scanf("%lld%lld",&a,&b);
        if(b-a>=10)
            c=0;
        else
        {
            for(i=a+1;i<=b;i++)
                c=(c*(i%10))%10;
        }
        c=c%10;
        printf("%lld
    ",c);
        return 0;
    }

     B

    Description

    Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map.

    Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Slava doesn't know the number of tanks and their positions, because he flies very high, but he can drop a bomb in any cell. All tanks in this cell will be damaged.

    If a tank takes damage for the first time, it instantly moves to one of the neighboring cells (a tank in the cell n can only move to the cell n - 1, a tank in the cell 1 can only move to the cell 2). If a tank takes damage for the second time, it's counted as destroyed and never moves again. The tanks move only when they are damaged for the first time, they do not move by themselves.

    Help Slava to destroy all tanks using as few bombs as possible.

    Input

    The first line contains a single integer n (2 ≤ n ≤ 100 000) — the size of the map.

    Output

    In the first line print m — the minimum number of bombs Slava needs to destroy all tanks.

    In the second line print m integers k1, k2, ..., km. The number ki means that the i-th bomb should be dropped at the cell ki.

    If there are multiple answers, you can print any of them.

    Sample Input

    Input

    2

    Output

    3
    2 1 2 

    Input

    3

    Output

    4
    2 1 3 2 

    题意:有一个n*1的地图 每一个格子都有一个坦克  每次炸坦克都会移动  每个坦克都有两条命  问要炸几次 怎么炸的才把坦克都炸完

    思路:偶数先都炸一次  再炸奇数

    #include <algorithm>
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <vector>
    using namespace std;
    const int MAX=1e6+10;
    typedef long long ll;
    ll ans[MAX];
    int main()
    {
        ll n,e=0,i;
        scanf("%lld",&n);
        for(i=1;i<=n;i++)
        {
            if(i%2==0)
                ans[e++]=i;
        }
        for(i=1;i<=n;i++)
        {
            if(i%2!=0)
                ans[e++]=i;
        }
        for(i=1;i<=n;i++)
        {
            if(i%2==0)
                ans[e++]=i;
        }
        printf("%lld
    ",e);
        for(i=0;i<e;i++)
        {
            if(i==0)
                printf("%lld",ans[i]);
            else
                printf(" %lld",ans[i]);
        }
        return 0;
    }
    

     

    E

    There are $$$n$$$ rectangles in a row. You can either turn each rectangle by $$$90$$$ degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also can turn all or none of them. You can not change the order of the rectangles.

    Find out if there is a way to make the rectangles go in order of non-ascending height. In other words, after all the turns, a height of every rectangle has to be not greater than the height of the previous rectangle (if it is such).

    Input

    The first line contains a single integer $$$n$$$ ($$$1 leq n leq 10^5$$$) — the number of rectangles.

    Each of the next $$$n$$$ lines contains two integers $$$w_i$$$ and $$$h_i$$$ ($$$1 leq w_i, h_i leq 10^9$$$) — the width and the height of the $$$i$$$-th rectangle.

    Output

    Print "YES" (without quotes) if there is a way to make the rectangles go in order of non-ascending height, otherwise print "NO".

    You can print each letter in any case (upper or lower).

    Sample Input

    Input

    3
    3 4
    4 6
    3 5

    Output

    YES
    

    Input

    2
    3 4
    5 5
    

    Output

    NO
    

    Hint

    In the first test, you can rotate the second and the third rectangles so that the heights will be [4, 4, 3].

    In the second test, there is no way the second rectangle will be not higher than the first one.

    题意:n个矩形  可以翻转  问可不可以 按从高到低的顺序排列

     

    #include <algorithm>
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstdlib>
    #include <deque>
    using namespace std;
    typedef long long ll;
    struct A
    {
        ll w;
        ll h;
    }a[101000];
    int main()
    {
        ll n,i,m,t;
        cin>>n;
        cin>>a[0].w>>a[0].h;
        if(a[0].h<a[0].w)
        {
            t=a[0].h;
            a[0].h=a[0].w;
            a[0].w=t;
        }
        ll p=a[0].h;
        for(i=1;i<n;i++)
            cin>>a[i].w>>a[i].h;
        for(i=1;i<n;i++)
        {
            if(a[i].w<=p&&a[i].h<=p)
            {
                p=max(a[i].w,a[i].h);
            }
            else
                if(a[i].w<=p)
                  p=a[i].w;
            else
                if(a[i].h<=p)
                p=a[i].h;
            else
                break;
    
        }
        if(i>=n)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
        return 0;
    }
  • 相关阅读:
    :Spring + axis2 开发 webservice
    log file parallel write 和 log buffer space p1 p2 p3
    log file sync p1 p2 p3
    :Apache FTPClient操作“卡死”问题的分析和解决
    :Apache FTPClient操作“卡死”问题的分析和解决
    org.apache.catalina.LifecycleException: Failed to start component
    一个简单的Tk界面(可以录入和查询)
    函数调用子函数,注意子函数的位置
    Perl 采集磁盘信息
    Perl 使用Frame(放置其他控件的地方)
  • 原文地址:https://www.cnblogs.com/zcy19990813/p/9702719.html
Copyright © 2020-2023  润新知