acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 资讯
  • 竞赛
  • 讨论
  • 团队
  • 商城
登录
注册
题目详情提交记录(0)
  • 最简题解(玩笑)

    如下 仅供娱乐

    userId_undefined
    Smile(!…:…!)
    时空双修者出道萌新快乐小狗贪心·贪心尝试者秩序白银递归·套娃学徒
    317阅读
    16回复
    27点赞
  • <兔农>题解

    代码如下

    userId_undefined
    LEC
    176阅读
    9回复
    23点赞
  • 答案(包正确)

    #include <iostream> #include <vector> #include <unordered_map> using namespace std; typedef long long ll; ll p; struct Matrix { ll a[3][3]; Matrix() { for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) a[i][j] = 0; } Matrix operator*(const Matrix& other) const { Matrix res; for (int i = 0; i < 3; ++i) for (int k = 0; k < 3; ++k) if (a[i][k]) for (int j = 0; j < 3; ++j) res.a[i][j] = (res.a[i][j] + a[i][k] * other.a[k][j]) % p; return res; } }; Matrix mat_pow(Matrix base, ll exp) { Matrix res; for (int i = 0; i < 3; ++i) res.a[i][i] = 1; while (exp) { if (exp & 1) res = res * base; base = base * base; exp >>= 1; } return res; } int main() { ll n, k; cin >> n >> k >> p; if (n == 1 || n == 2) { cout << 1 % p << endl; return 0; } }

    userId_undefined
    11岁爱玩DJI和MC(可约飞)
    空间掌握者字符串·魔法使I/O·IO入门者格式·格式排版员分支·分支解题者数组·数组操作员
    13阅读
    0回复
    2点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页