ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

哈尔滨工程大学ACM预热赛

2019-04-06 23:38:43  阅读:334  来源: 互联网

标签:预热 int long Code ACM ans include 哈尔滨工程大学 mod


https://ac.nowcoder.com/acm/contest/554#question

 

B

#include <bits/stdc++.h>
using namespace std;

int T;
int a[5][5], b[5][5];

int main() {
    scanf("%d", &T);
    while(T --){
        for(int i = 1; i <= 3; i ++) {
            for(int j = 1; j <= 3; j ++)
                scanf("%d", &a[i][j]);
        }

        for(int i = 1; i <= 3; i ++) {
            for(int j = 1; j <= 3; j ++)
                b[j][i] = a[i][j];
        }

        long long ans = b[1][1] * b[2][2] * b[3][3] +
                        b[1][2] * b[2][3] * b[3][1] +
                        b[2][1] * b[1][3] * b[3][2] -
                        b[1][3] * b[2][2] * b[3][1] -
                        b[2][3] * b[3][2] * b[1][1] -
                        b[3][3] * b[1][2] * b[2][1];

        printf("%lld\n", abs(ans * ans));
    }
    return 0;
}
View Code

还要查一下什么是伴随矩阵 线代已经学完一年了呀

C

#include <bits/stdc++.h>
using namespace std;
 
int T;
long long a, N, b;
 
long long Pow(long long a, long long b, long long mod) {
    long long ans = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            ans = (ans * a) % mod;
            b --;
        } else {
            a = (a * a) % mod;
            b /= 2;
        }
    }
    return ans % mod;
}
 
int main() {
    scanf("%d", &T);
    while(T --) {
        scanf("%lld%d%lld", &a, &N, &b);
        long long cnt = Pow(a, N, b);
        printf("%lld\n", cnt % b);
    }
    return 0;
}
View Code

一个快速幂对 b 取 mod 

H

#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e6 + 10;
int sum[maxn], a[maxn];
int T, N;

int main() {
    for(int i = 2; i <= 1e6; i ++) {
        for(int j = i; j <= 1e6; j += i)
            a[j] = !a[j];
    }

    for(int i = 1; i <= 1e6; i ++) {
        if(a[i]) sum[i] = sum[i - 1] + 1;
        else sum[i] = sum[i - 1];
    }

    scanf("%d", &T);
    while(T --) {
        int x, y;
        scanf("%d%d%d", &N, &x, &y);
        printf("%d\n", sum[y] - sum[x - 1]);
    }
    return 0;
}
View Code

先离线处理一下 然后每次查询求一下前缀和

 

 

前一阵心情很差劲呀 休息一阵之后发现真的不能停下来 脑子明显锈住了 这几天多动动脑子活过来吧!天梯赛的题目代码过两天贴上来吧 还有半个月省赛 要加油呢 明天雷火的笔试希望有好运气

就算是深夜也有人乘着阳光呢 

标签:预热,int,long,Code,ACM,ans,include,哈尔滨工程大学,mod
来源: https://www.cnblogs.com/zlrrrr/p/10663433.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有