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\n");
    else
    if(x==0&&y==1&&z==0&&p==0&&q==0)
        printf("YES\n");
    else
    if(x==0&&y==0&&z==1&&p==0&&q==0)
        printf("YES\n");
    else
    if(x==0&&y==0&&z==0&&p==1&&q==0)
        printf("YES\n");
    else
    if(x==0&&y==0&&z==0&&p==0&&q==1)
        printf("YES\n");
    else
        printf("NO\n");
    //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\n");
    else
    if(x==0&&y==1&&z==0&&p==0&&q==0)
        printf("YES\n");
    else
    if(x==0&&y==0&&z==1&&p==0&&q==0)
        printf("YES\n");
    else
    if(x==0&&y==0&&z==0&&p==1&&q==0)
        printf("YES\n");
    else
    if(x==0&&y==0&&z==0&&p==0&&q==1)
        printf("YES\n");
    else
        printf("NO\n");
   // 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\n",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\n",e);
    for(i=0;i<e;i++)
    {
        if(i==0)
            printf("%lld",ans[i]);
        else
            printf(" %lld",ans[i]);
    }
    return 0;
}

A

There are $$$n$$$ houses in a row. They are numbered from $$$1$$$ to $$$n$$$ in order from left to right. Initially you are in the house $$$1$$$.

You have to perform $$$k$$$ moves to other house. In one move you go from your current house to some other house. You can't stay where you are (i.e., in each move the new house differs from the current house). If you go from the house $$$x$$$ to the house $$$y$$$, the total distance you walked increases by $$$|x-y|$$$ units of distance, where $$$|a|$$$ is the absolute value of $$$a$$$. It is possible to visit the same house multiple times (but you can't visit the same house in sequence).

Your goal is to walk exactly $$$s$$$ units of distance in total.

If it is impossible, print "NO". Otherwise print "YES" and any of the ways to do that. Remember that you should do exactly $$$k$$$ moves.

Input

The first line of the input contains three integers $$$n$$$, $$$k$$$, $$$s$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le k \le 2 \cdot 10^5$$$, $$$1 \le s \le 10^{18}$$$) — the number of houses, the number of moves and the total distance you want to walk.

Output

If you cannot perform $$$k$$$ moves with total walking distance equal to $$$s$$$, print "NO".

Otherwise print "YES" on the first line and then print exactly $$$k$$$ integers $$$h_i$$$ ($$$1 \le h_i \le n$$$) on the second line, where $$$h_i$$$ is the house you visit on the $$$i$$$-th move.

For each $$$j$$$ from $$$1$$$ to $$$k-1$$$ the following condition should be satisfied: $$$h_j \ne h_{j + 1}$$$. Also $$$h_1 \ne 1$$$ should be satisfied.

Sample Input

Input

10 2 15

Output

YES
10 4 

Input

10 9 45

Output

YES
10 1 10 1 2 1 2 1 6 

Input

10 9 81

Output

YES
10 1 10 1 10 1 10 1 10 

Input

10 9 82

Output

NO

题意:给出3个数  n,k,s   n代表有n个房子 编号为1~10  每次最多走k步  要求走s步  问可不可以走刚好s步  如果可以输出每一步到哪

分析:每次最多走(n-1)步最少走1步  所以  必须满足 k<=s<=k(n-1)

代码再写~~

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个矩形  可以翻转  问可不可以 按从高到低的顺序排列

思路:分别判断后面的一个如果长大于宽(宽代表高)并且小于前面的宽就交换 最后判断符不符合题意就行

不知道为什么不对 过段时间再看

//此代码没有ac
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#define max(a,b)   (a>b?a:b)
#define min(a,b)   (a<b?a:b)
#define swap(a,b)  (a=a+b,b=a-b,a=a-b)
#define memset(a,v)  memset(a,v,sizeof(a))
using namespace std;
const int MAX=1e6+10;
typedef long long ll;
ll ans[MAX];
struct R
{
    ll a;
    ll b;
}r[MAX];
int main()
{
    ll n,t,i;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld%lld",&r[i].b,&r[i].a);
    }
    if(r[0].a<r[0].b)
        swap(r[0].a,r[0].b);
    for(i=1;i<n;i++)
    {
        if(r[i].a>r[i].b&&r[i].b<=r[i-1].a)
            swap(r[i].a,r[i].b);
    }
    for(i=1;i<n;i++)
    {
        if(r[i].a>r[i-1].a)
            break;
    }
    if(i>=n)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

 下面为题解:模拟   第一次取最大的,后面每次取的时候先拿最大的和前面一个比较,<=就存进去,如果不行就拿小的看是<=前面那个存进去,否则输出no

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#define max(a,b)   (a>b?a:b)
#define min(a,b)   (a<b?a:b)
#define swap(a,b)  (a=a+b,b=a-b,a=a-b)
#define memset(a,v)  memset(a,v,sizeof(a))
using namespace std;
const int MAX=1e6+10;
typedef long long ll;
struct R
{
    ll a;
    ll b;
    ll ans;
}r[MAX];
int main()
{
    ll n,t,i;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%lld%lld",&r[i].b,&r[i].a);
    r[0].ans=max(r[0].a,r[0].b);
    for(i=1;i<n;i++)
    {
        if(max(r[i].a,r[i].b)<=r[i-1].ans)
            r[i].ans=max(r[i].a,r[i].b);
        else
            if(min(r[i].a,r[i].b)<=r[i-1].ans)
               r[i].ans=min(r[i].a,r[i].b);
            else
                break;
    }
    if(i>=n)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/ZCY19990813/article/details/81394713