吉比特2020.8.27 编程2

#include<bits/stdc++.h>
#define mes(a, b) memset(a, b, sizeof a)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e5+10;

struct Mat{
    ll mat[5][5];
    Mat(){
        mes(mat, 0);
    }
    void init(){
        for(int i = 1; i <= 3; i++)
            mat[i][i] = 1;
    }
    Mat operator * (Mat const &p)const{
        Mat ans;
        for(int i = 1; i <= 3; i++){
            for(int j = 1; j <= 3; j++){
                for(int k = 1; k <= 3; k++){
                    ans.mat[i][j] += mat[i][k] * p.mat[k][j] % mod;
                    ans.mat[i][j] %= mod;
                 }
            }
        }
        return ans;
    }
    void print(){
        for(int i = 1; i <= 3; i++){
            for(int j = 1; j <= 3; j++){
                printf("%lld ", mat[i][j]);
            }
            printf("\n");
        }
    }
};

Mat q_pow(Mat a, ll b){
    Mat ans; ans.init();
    while(b){
        if(b & 1) ans = ans * a;
        a = a*a;
        b /= 2;
    }
    return ans;
}

int main(){
    Mat now, a;
    ll xa, xb, xc, ya, yb, yc, x, y, z, n;
    scanf("%lld%lld%lld%lld", &x, &y, &z, &n);
    scanf("%lld%lld%lld%lld%lld%lld", &xa, &ya, &xb, &yb, &xc, &yc);
    now.mat[1][1] = now.mat[2][2] = now.mat[3][3] = 1;
    now.mat[1][2] = xb; now.mat[1][3] = xc;
    now.mat[2][1] = xa; now.mat[2][3] = yc;
    now.mat[3][1] = ya; now.mat[3][2] = yb;

   
    a.mat[1][1] = x; a.mat[2][1] = y; a.mat[3][1] = z;
   
    a = q_pow(now, n) * a;
    printf("%lld %lld %lld\n", a.mat[1][1], a.mat[2][1], a.mat[3][1]);

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值