【牛】华华教月月做数学
链接:https://ac.nowcoder.com/acm/contest/3800/A
来源:牛客网

题目描述
找到了心仪的小姐姐月月后,华华很高兴的和她聊着天。然而月月的作业很多,不能继续陪华华聊天了。华华为了尽快和月月继续聊天,就提出帮她做一部分作业。
月月的其中一项作业是:给定正整数A、B、P,求A^B\mod PA
B
modP的值。华华觉得这实在是毫无意义,所以决定写一个程序来做。但是华华并不会写程序,所以这个任务就交给你了。
因为月月的作业很多,所以有T组询问。
输入描述:
第一行一个正整数T表示测试数据组数。
接下来T行,每行三个正整数A、B、P,含义如上文。
输出描述:
输出T行,每行一个非负整数表示答案。
示例1
输入
复制
2
2 5 10
57284938291657 827493857294857 384729583748273
输出
复制
2
18924650048745
备注:
1\le T\le10^31≤T≤10
3
,1\le A,B,P\le10^{18}1≤A,B,P≤10
18

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <ext/rope>
#include <bits/stdc++.h> using namespace std;#define gt(x) x = read()
#define int unsigned long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define x first
//#define y second//int dx[4] = {0, 1, 0, -1};
//int dy[4] = {1, 0, -1, 0}; typedef __int128 INT;
typedef pair<double, int> PDI;
typedef unsigned long long ULL;inline int read(int out = 0)
{char c;while((c=getchar()) < 48 || c > 57);while(c >= 48 && c <= 57) out=out*10+c-48,c=getchar();return out;
}const int N = 2010 + 10;
const int M = 3e6 + 10;
const int mod = 2333;
const int PP = 13331;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);int qmi(int a, int b, int p){INT x = a %= p;INT res = 1;while(b){if (b & 1)   res = res * x % p;x = x * x % p;b >>= 1;}return (int)res % p;
}signed main(){int T;cin >> T;while(T --){int a, b, p;cin >> a >> b >> p;cout << qmi(a, b, p) % p << endl;}return 0;
}

【网】签到题I
链接:https://ac.nowcoder.com/acm/contest/3800/C
来源:牛客网

题目描述
众所周知,给定一个可重集,求它的第 k 小的数字是一个很难的问题,那么现在就来考考你
输入描述:
第一行两个整数 n,k,表示这个可重集的大小以及询问的 k

第二行一共 n 个非负整数,表示这个可重集中所有的数字
输出描述:
一行一个整数,表示这个可重集的第 k 小的数字是什么
示例1
输入
复制
3 1
3 1 2
输出
复制
1
备注:
数据范围
1 \le k \le n \le 10^51≤k≤n≤10
5

所有的数字不超过 10^510
5

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <ext/rope>
#include <bits/stdc++.h> using namespace std;#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define x first
//#define y second//int dx[4] = {0, 1, 0, -1};
//int dy[4] = {1, 0, -1, 0}; //typedef __int128 INT;
typedef pair<double, int> PDI;
typedef unsigned long long ULL;inline int read(int out = 0)
{char c;while((c=getchar()) < 48 || c > 57);while(c >= 48 && c <= 57) out=out*10+c-48,c=getchar();return out;
}const int N = 1e5 + 10;
const int M = 3e6 + 10;
const int mod = 2333;
const int PP = 13331;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);int a[N];signed main(){int n, k;scanf("%lld%lld", &n, &k);for (int i = 1; i <= n; i ++){scanf("%lld", &a[i]);}sort(a + 1, a + 1 + n);cout << a[k] << endl;return 0;
}

【祝】Rinne Loves Study
链接:https://ac.nowcoder.com/acm/contest/3800/D
来源:牛客网

目描述
Rinne 喜欢使用一种奇怪的方法背单词,现在这些单词被放在了一个 n \times mn×m 的格子里。由于背单词是一个令人烦躁的事情,所以她决定每天只背同一行或者同一列的单词。她一共会背 T 次单词,为了方便巩固,她现在想知道:对于每个单词,最后一次背是什么时候呢?
她这么可爱当然会算啦!但是她想考考你。
输入描述:
第一行三个整数 n,m,T。
接下来 T 行,第 i+1 行描述第 i 天干了什么,每行的格式如下:
1 x:说明她在这一天背了第 x 行的单词;
2 y说明她在这一天背了第 y 列的单词。
输入的所有量的具体意义请参考「题目描述」。
输出描述:
输出一个 n \times mn×m 的矩阵 a,a_{i,j}a
i,j

表示第 i 行第 j 列这个单词最后一次被背诵是在第几天。
示例1
输入
复制
3 3 3
1 2
2 3
1 3
输出
复制
0 0 2
1 1 2
3 3 3
备注:
n \times m \leq 10^5,T \leq 10^5n×m≤10
5
,T≤10
5
标记每一行列即可

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <ext/rope>
#include <bits/stdc++.h> using namespace std;//#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define x first
//#define y second//int dx[4] = {0, 1, 0, -1};
//int dy[4] = {1, 0, -1, 0}; //typedef __int128 INT;
typedef pair<double, int> PDI;
typedef unsigned long long ULL;inline int read(int out = 0)
{char c;while((c=getchar()) < 48 || c > 57);while(c >= 48 && c <= 57) out=out*10+c-48,c=getchar();return out;
}const int N = 1e5 + 10;
const int M = 3e6 + 10;
const int mod = 1000000007;
const int PP = 13331;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);int row[N], col[N];signed main(){int n, m, q;scanf("%lld%lld%lld", &n, &m, &q);for (int i = 1; i <= q; i ++){int x, y;scanf("%lld%lld", &x, &y);if (x == 1){row[y] = i;}else if (x == 2){col[y] = i;}}for (int i = 1; i <= n; i ++){for (int j = 1; j <= m; j ++){cout << max(row[i], col[j]) << " ";}cout << endl;}return 0;
}

【大】约数
链接:https://ac.nowcoder.com/acm/contest/3800/E
来源:牛客网

Actci上课睡了一觉,下课屁颠屁颠的去找数学老师补课,问了老师一个题目:
给出两个数a,b,问a和b的全部公约数是什么?
数学老师一看这道题太简单了,不屑回答,于是就交给了你。
输入描述:
一行两个数a,b.
输出描述:
a和b的全部公约数,每个数字之间空格隔开。
示例1
输入
复制
25 37
输出
复制
1
示例2
输入
复制
25 100
输出
复制
1 5 25
备注:
对于100%的数据,1 ≤ a,b ≤ 1013
找到所有的公约数看是否相同

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <ext/rope>
#include <bits/stdc++.h> using namespace std;#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define x first
//#define y second//int dx[4] = {0, 1, 0, -1};
//int dy[4] = {1, 0, -1, 0}; //typedef __int128 INT;
typedef pair<double, int> PDI;
typedef unsigned long long ULL;inline int read(int out = 0)
{char c;while((c=getchar()) < 48 || c > 57);while(c >= 48 && c <= 57) out=out*10+c-48,c=getchar();return out;
}const int N = 2010 + 10;
const int M = 3e6 + 10;
const int mod = 2333;
const int PP = 13331;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);vector<int> get_divisors(int x){vector<int> res;for (int i = 1; i <= x / i; i ++){if (x % i == 0){res.push_back(i);if (i != x / i)   res.push_back(x / i);}}sort(res.begin(), res.end());return res;
}signed main(){int a, b;cin >> a >> b;auto res1 = get_divisors(a);auto res2 = get_divisors(b);for (auto x : res1){if (find(res2.begin(), res2.end() , x) != res2.end()){cout << x << " ";}}cout << endl;return 0;
}

或者是最大公约数的因子的乘积的任意组合

#include<iostream>
#include<set>
#define int long longusing namespace std;
typedef pair<int,int> PII;
const int N=1e6+10;int c[100];
int cnt,e[N],cot;
int tmp=1;
set<int> mset;int gcd(int a,int b)
{return b ? gcd(b,a%b) : a;
}void dfs(int u)
{if(u>cnt){mset.insert(tmp);return;}for(int j=0;j<=1;j++){if(j) tmp*=c[u];dfs(u+1);if(j) tmp/=c[u];}
}signed main()
{int a,b;cin>>a>>b;int d=gcd(a,b);for(int i=2;i*i<=d;i++){if(d%i==0){while(d%i==0){c[++cnt]=i;d/=i;}}}if(d!=1) c[++cnt]=d;dfs(1);for(int x:mset) printf("%lld ",x);
}

【家】神秘钥匙
链接:https://ac.nowcoder.com/acm/contest/3800/F
来源:牛客网

题目描述
clccle一行

牛客2019跨年AK场相关推荐

  1. 牛客2019跨年AK场题解(一)

    A [牛]华华教月月做数学 链接:https://ac.nowcoder.com/acm/contest/3800/A 来源:牛客网 题目描述 找到了心仪的小姐姐月月后,华华很高兴的和她聊着天.然而月 ...

  2. 牛客2019跨年AK场 E 【大】约数 (两个数的全部公约数)

    链接:https://ac.nowcoder.com/acm/contest/3800/E 题目描述 Actci上课睡了一觉,下课屁颠屁颠的去找数学老师补课,问了老师一个题目: 给出两个数a,b,问a ...

  3. 牛客2022年除夕AK场

    前言 最后一题有意思,然而并未AK,新年快乐啊各位coder! A.如意(签到+思维) 题目连接 https://ac.nowcoder.com/acm/contest/28335/A 题面 思路 如 ...

  4. 2019牛客多校第四场 I题 后缀自动机_后缀数组_求两个串de公共子串的种类数

    目录 求若干个串的公共子串个数相关变形题 对一个串建后缀自动机,另一个串在上面跑同时计数 广义后缀自动机 后缀数组 其他:POJ 3415 求两个串长度至少为k的公共子串数量 @(牛客多校第四场 I题 ...

  5. 24dian(牛客多校第三场)

    24dian(牛客多校第三场) 题意: 给你n张牌,每张牌的大小为1 ~ 13,问这些牌与加减乘除任意组合(可以使用括号),且但所有的有效解在计算过程中都涉及到分数,即非整数,能否组成答案m,如果可以 ...

  6. 2021牛客暑假多校第二场 K题—Stack (链表)

    2021牛客暑假多校第二场 K题-Stack 题意: 一个单调栈,给你第n次操作时里面数据的数量,让你给出里面塞入的会是哪些数字. 主要思想:链表模拟 (代码里面有注释) (题解一开始说的是拓扑,后来 ...

  7. 牛客多校第四场【B-Basic Gcd Problem】

    牛客多校第四场[B-Basic Gcd Problem] 题目链接:https://ac.nowcoder.com/acm/contest/5669/B 思路:先要理解公式,多看几个数据基本就会有点想 ...

  8. 牛客多校第三场 B【Classical String Problem】

    牛客多校第三场 B[Classical String Problem] 链接:https://ac.nowcoder.com/acm/contest/5668/B 来源:牛客网 题目描述 Given ...

  9. 2019年牛客多校第1场 赛后总结

    A题 :Equivalent Prefixes  题意:就是给你两个有n个不同数的串,然后保证1-p区间内任选一个区间,使得区间中最小值的下标相同,找到最大的p值  思路:我的思路是设置两个单调栈,然 ...

最新文章

  1. 二叉树线索化示意图_103-线索化二叉树思路图解
  2. DNA Sorting(排序)
  3. Delphi对象池MyObjectPool.pas
  4. C# static的用法详解
  5. 搜索引擎优化的关键字工具
  6. 对Python装饰器的个人理解方法
  7. Pentium奔腾架构/流水线及其优化
  8. TortoiseSVN 使用详细步骤(三):安装
  9. 基于ANSYS某商场旋转楼梯钢结构受力分析
  10. SEO优化师王永仙说:网页title设置及描述设置和URL优化及网站地图优化(sitemap)...
  11. 谷歌浏览器打开页面出现(任何网页包括设置)崩溃解决方法。
  12. STM32+QRCode二维码生成
  13. 解决各种中文乱码问题
  14. 获取双卡手机IMEI、IMSI
  15. 基于STM32F103RB的模拟液位检测告警系统(已实现)
  16. 如何让全链路压测落地?
  17. 一款开源且具有交互视图界面的实时 Web 日志分析工具
  18. redis事件通知(notify-keyspace-events Ex)
  19. Bootstrap后台导航
  20. 哈佛大学开放课程:《公正:该如何做是好?》1

热门文章

  1. python代码测试健康指数计算器_python编写的bmi体重指数计算器、出租车费用计算器、个税计算器、猜数字游戏...
  2. cxf webservice接口
  3. c语言入门编辑什么,萌新必看——C语言入门编辑器推荐
  4. 看MindSpore加持下,如何「炼出」首个千亿参数中文预训练语言模型?
  5. linux下硬件检测工具,Linux硬件检测工具
  6. 网易云音乐React Native体系建设与发展
  7. 计算机毕业设计-生鲜配送超市商城系统
  8. 测试IP和端口是否被封锁
  9. Ubuntu 16.04 使用校园网客户端上网
  10. 七代处理器装win7_7代cpu能装win7旗舰版吗?七代处理器 不能装win7的解决方法