CCF-CSP 202012-5 星际旅行 80分

原题链接:CCF-CSP 202012-5 星际旅行 80分
在这里插入图片描述
参考博客:CCF-CSP-202012-5 星际旅行 80分暴力题解

玄学。。

#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
const int N=1e5+10;
const ll mod=1000000007;

struct node
{
    ll x,y,z;
}node[N];

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        node[i].x=0;
        node[i].y=0;
        node[i].z=0;
    }
    while(m--)
    {
        ll op,l,r;
        cin>>op>>l>>r;
        if(op==1)
        {
            ll a,b,c;
            cin>>a>>b>>c;
            for(int i=l;i<=r;i++)
            {
                node[i].x=(node[i].x+a)%mod;
                node[i].y=(node[i].y+b)%mod;
                node[i].z=(node[i].z+c)%mod;
            }
        }
        else if(op==2)
        {
            ll k; cin>>k;
            for(int i=l;i<=r;i++)
            {
                node[i].x=(node[i].x*k)%mod;
                node[i].y=(node[i].y*k)%mod;
                node[i].z=(node[i].z*k)%mod;
            }
        }
        else if(op==3)
        {
            for(int i=l;i<=r;i++)
            {
                ll a=node[i].x;
                ll b=node[i].y;
                ll c=node[i].z;
                node[i].x=b;
                node[i].y=c;
                node[i].z=a;
            }
        }
        else if(op==4)
        {
            ll a=0,b=0,c=0;
            for(int i=l;i<=r;i++)
            {
                a=(a+node[i].x);
                b=(b+node[i].y);
                c=(c+node[i].z);
            }
            a%=mod; b%=mod; c%=mod;
            ll sum=((a*a)%mod+(b*b)%mod+(c*c)%mod)%mod;
            cout<<sum<<endl;
        }
    }
    return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值