• Codeforces Round 940 (Div. 2) C. How Does the Rook Move?


    在这里插入图片描述
    //dp删除后,可以堆成新的N*N.

    #include
    using namespace std;
    #define int long long 
    const int mod=1e9+7;
    const int n=1e6+11;
    int a,b,c,d[n],l,r; 
    signed main()
    {
    	ios::sync_with_stdio(false);
    	cin>>a;
    	d[1]=1;
    	d[0]=1;
    	for(int i=2;i<=3e5;i++)
    	{
    		d[i]=(d[i-1]+(d[i-2]*(i-1)*2)%mod)%mod;
    	}
    	while(a--)
    	{
    		cin>>b>>c;
    		for(int i=1;i<=c;i++)
    		{
    			cin>>l>>r;
    			if(l==r)
    			{
    				b--;
    			}
    			else
    			{
    				b-=2;
    			}
    		}
    		cout<
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
  • 相关阅读:
    代码信息化:软件业“第二次工业革命”的契机
    使用MySQL,请善用 JSON 这张牌
    Java 可变参数及集合工具类(Collections)
    拍照扫描怎么弄?你可以试一下这两个方法
    刷题12.2
    初步了解nodejs语法和web模块
    Keil5退出仿真调试卡死的解决办法
    TypeScript 笔记:String 字符串
    【Spring Boot 】JPA 的基本使用
    使用transformers过程中出现的bug
  • 原文地址:https://blog.csdn.net/qq_73671385/article/details/138086558