QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572958#9310. Permutation Counting 41457WA 0ms3584kbC++141.3kb2024-09-18 16:56:072024-09-18 16:56:07

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 16:56:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-09-18 16:56:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define NO cout<<"No"<<endl
#define YES cout<<"Yes"<<endl
#define all(a) a.begin(),a.end()
#define endl '\n'
#define pb push_back
#define mo 1000000007
#define MO 998244353

const int N = 2e5+1;
const int M = 2e3+1;

const ll maxn = 1e6+10, mod = 1e9+7;
ll Jc[maxn];
void calJc()    //求maxn以内的数的阶乘
{
    Jc[0] = Jc[1] = 1;
    for(ll i = 2; i < maxn; i++)
        Jc[i] = Jc[i - 1] * i % mod;
}
void exgcd(ll a, ll b, ll &x, ll &y)    //拓展欧几里得算法
{
    if(!b) x = 1, y = 0;
    else
    {
        exgcd(b, a % b, y, x);
        y -= x * (a / b);
    }
}
ll niYuan(ll a)   //求a对b取模的逆元
{
    ll x, y;
    exgcd(a, mod, x, y);
    return (x + mod) % mod;
}
ll C(ll n, ll r)    //计算C(n, r)
{
    return Jc[n] * niYuan(Jc[r]) % mod
        * niYuan(Jc[n - r]) % mod;
}
ll A(ll n, ll r)
{
    return Jc[n] * niYuan(Jc[n-r])%mod;
}

void solve()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int l,r;
		cin>>l>>r;
		if((r-l+1)>=n)
		{
			ans+=A((r-l+1),n);
		}
	}
	cout<<ans%2<<endl;
}

signed main()
{
	int _=1;
	cin>>_;
	while(_--)
	{
		solve();
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

4
5
1 2
1 5
1 2
1 2
2 2
5
1 1
2 4
2 3
5 5
3 4
5
3 5
1 2
3 4
3 5
3 3
5
1 5
1 4
4 5
5 5
1 2

output:

0
0
0
0

result:

wrong answer 2nd words differ - expected: '1', found: '0'