A. Regular Bracket Sequence(思维)

A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, "", "(())" and "()()" are regular bracket sequences; "))" and ")((" are bracket sequences (but not regular ones), and "(a)" and "(1)+(1)" are not bracket sequences at all.

You have a number of strings; each string is a bracket sequence of length 2

. So, overall you have ???1 strings "((", ???2 strings "()", ???3 strings ")(" and ???4 strings "))". You want to write all these strings in some order, one after another; after that, you will get a long bracket sequence of length 2(???1+???2+???3+???4)

. You wonder: is it possible to choose some order of the strings you have such that you will get a regular bracket sequence? Note that you may not remove any characters or strings, and you may not add anything either.

Input

The input consists of four lines, ?

-th of them contains one integer ???? (0≤????≤109

).

Output

Print one integer: 1

if it is possible to form a regular bracket sequence by choosing the correct order of the given strings, 0

otherwise.

Examples

Input

Copy

3
1
4
3

Output

Copy

1

Input

Copy

0
0
0
0

Output

Copy

1

Input

Copy

1
2
3
4

Output

Copy

0

Note

In the first example it is possible to construct a string "(())()(()((()()()())))", which is a regular bracket sequence.

In the second example it is possible to construct a string "", which is a regular bracket sequence.

题解:a,b,c,d代表4种类型。b类型为万能类型,不用考虑。我们肯定要保证a与d相等,如果a或d为0的话则不能出现c类型。

#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    if(a==d)
    {
        if(a==0)
        {
            if(c==0)
                cout<<"1"<<endl;
            else
                cout<<"0"<<endl;
        }
        else
            cout<<"1"<<endl;
    }
    else
        cout<<"0"<<endl;
    return 0;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值