快速幂【模板】

O(logn): #include<bits/stdc++.h> using namespace std; int pow_mod(int a, int n, int m) { if(n == 0) return 1; int x = pow_mod(a, n/2, m); long long ans = (long long)x * x % m; ...
分类: 其他 发布时间: 08-05 22:37 阅读次数: 0

HDU - 1061 - 快速幂

#include<bits/stdc++.h> using namespace std; const int Mod = 1e5; int pow_mod(long long a, long long n, int m) { long long ans = 1; while(n){ if(n & 1){ ans = (ans * a) %...
分类: 其他 发布时间: 08-05 22:37 阅读次数: 0

CodeForces - 890A - ACM ICPC【水题】

#include<iostream> #include<cstdio> using namespace std; int main() { int a[6], ans = 0; for (int i = 0; i < 6; i++){ cin >> a[i]; ans += a[i]; } ...
分类: 其他 发布时间: 08-05 22:36 阅读次数: 0

牛客小白月赛5 - j - 时间time

链接:https://www.nowcoder.com/acm/contest/135/J 来源:牛客网    Apojacsleam是一个喜欢特殊时刻的人。         他定义了一个时刻,若电子表显示ab:ba(24小时制),则该时刻为“回文时刻”(可以有前导零)。例如00:00就是回文时刻。         给定一个时刻,求此时刻的上一个和下一个回文时刻。 J题附加:00:00就是...
分类: 其他 发布时间: 08-05 22:36 阅读次数: 0

牛客小白月赛5 -I- 区间 (interval)【差分数组】

链接:https://www.nowcoder.com/acm/contest/135/I 来源:牛客网 Apojacsleam喜欢数组。     他现在有一个n个元素的数组a,而他要对a[L]-a[R]进行M次操作:         操作一:将a[L]-a[R]内的元素都加上P         操作二:将a[L]-a[R]内的元素都减去P     最后询问a[l]-a[r]内的元素之和?...
分类: 其他 发布时间: 08-05 22:36 阅读次数: 0

牛客小白月赛5 - G - 异或(xor)【找规律】

链接:https://www.nowcoder.com/acm/contest/135/G   从前,Apojacsleam家的水族箱里,养了一群热带鱼。     在这几条热带鱼里,Apojacsleam特别喜欢一条叫做TbGx(请勿人肉)的热带鱼,所以每次都让她第一个吃食物。对于每一条鱼,Apojacsleam都有一个顺序,鱼会按照这个顺序排序,越靠前的地位越高。    吃饱喝足是要睡觉的...
分类: 其他 发布时间: 08-05 22:36 阅读次数: 0

LOJ - #6277数列分块入门 1

输出格式 对于每次询问,输出一行一个数字表示答案。 样例 样例输入 4 1 2 2 3 0 1 3 1 1 0 1 0 0 1 2 2 1 0 2 0 样例输出 2 5 #include<bits/stdc++.h> using namespace std; const int maxn = 5e4 + 5; int blo, n, opt, l, r, c...
分类: 其他 发布时间: 08-05 22:35 阅读次数: 0

LOJ - #6278. 数列分块入门 2

输出格式 对于每次询问,输出一行一个数字表示答案。 样例 样例输入 4 1 2 2 3 0 1 3 1 1 1 3 2 1 1 4 1 1 2 3 2 样例输出 3 0 2 #include<bits/stdc++.h> using namespace std; const int maxn = 5e4 + 5; int blo, n, opt, l, r,...
分类: 其他 发布时间: 08-05 22:35 阅读次数: 0

LOJ - #6279. 数列分块入门 3

题目链接:#6279. 数列分块入门 3 #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int blo, n, opt, l, r, c, a[maxn], pos[maxn], atag[maxn]; set<int>st[maxn]; int add(int l, int...
分类: 其他 发布时间: 08-05 22:35 阅读次数: 0

LOJ - #6280. 数列分块入门 4

题目链接:https://loj.ac/problem/6280 #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn = 5e4 + 5; int blo, n, opt, l, r, c, pos[maxn]; ll atag[maxn], sum[maxn], a[ma...
分类: 其他 发布时间: 08-05 22:35 阅读次数: 0

LOJ-#6281. 数列分块入门 5

题目链接:https://ajax.loj.ac/problem/6281 #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn = 5e4 + 5; int blo, opt, l, r, c, a[maxn], flag[maxn], pos[maxn], n, sum[...
分类: 其他 发布时间: 08-05 22:34 阅读次数: 0

LOJ - #6282. 数列分块入门 6

题目链接:https://ajax.loj.ac/problem/6282 #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn = 1e5 + 5; int blo, opt, l, r, c, n, m; int pos[maxn], a[maxn], st[maxn*2...
分类: 其他 发布时间: 08-05 22:34 阅读次数: 0

LOJ - #6283. 数列分块入门 7

题目链接: https://ajax.loj.ac/problem/6283 #include<bits/stdc++.h> #define ll long long #define mod 10007 using namespace std; const int maxn = 1e5 + 5; int blo, opt, l, r, c, n, m; int pos[maxn],...
分类: 其他 发布时间: 08-05 22:34 阅读次数: 0

LOJ - #6284. 数列分块入门 8

题目链接:https://ajax.loj.ac/problem/6284 #include<bits/stdc++.h> using namespace std; const int maxn = 1e5+5; int a[maxn], pos[maxn], blo, n, tag[maxn], l, r, c; void reset(int x) { if(tag[x]...
分类: 其他 发布时间: 08-05 22:34 阅读次数: 0

HDU - 1285 -确定比赛名次【拓扑排序】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1285 #include<bits/stdc++.h> using namespace std; const int maxn = 515; int mp[maxn][maxn]; int _in[maxn]; int ans[maxn]; int N, M; void init() {...
分类: 其他 发布时间: 08-05 22:33 阅读次数: 0

UVA - 10129 -Play on Words【欧拉路】/补

(来自:《算法竞赛入门经典》)题意:输入n(n≤100000)个单词,是否可以把所有这些单词排成一个序列,使得每个单词的第一个字母和上一个单词的最后一个字母和上一个单词的第一个字母相同(例如acm,malform,mouse)。每个单词最多包含1000个小写字母。输入中可以有重复的单词。 【分析】 把字母看作结点,单词看成有向边,则问题有解,当且仅当图中有欧拉路径。前面讲过,有向图存在欧拉道路...
分类: 其他 发布时间: 08-05 22:33 阅读次数: 0

POJ - 2230 - Watchcow【欧拉回路】/补

#include<iostream> #include<cstdio> #include<vector> using namespace std; const int maxn = 1e4+10; const int maxm = 4e4+10; int n, m; struct Edge{ int to,flag; }e; vector<Edg...
分类: 其他 发布时间: 08-05 22:33 阅读次数: 0

Codeforces - 617E - XOR and Favorite Number【莫队】

#include<bits/stdc++.h> using namespace std; const int maxn = 1<<20; struct node { int l, r, id; }Q[maxn]; int pos[maxn], a[maxn]; long long ans[maxn], flag[maxn]; bool cmp(node a, ...
分类: 其他 发布时间: 08-05 22:33 阅读次数: 0

Python自带队列模块Queue的使用(1)

Python自带的队列模块有4种队列: FIFO:first in first out  先进先出 LIFO:last in first out   后进先出,类似于栈的数据结构 proiority:优先队列 deque:   双端队列 这一部分,先介绍FIFO模式的队列,后三种队列会在后续的文章种介绍 设置队列长度、进队列与出队列 from queue import Queue ...
分类: 其他 发布时间: 08-05 22:32 阅读次数: 0

Python自带队列模块Queue的使用(2)

LIFO队列,是一个先进后出的队列,类似于栈的数据结构 导入模块 from queue import  LifoQueue 查看源码会发现LifoQueue是继承了Queue队列,所以使用创建对象时用法跟Queue一样 lq = LifoQueue(maxsize=0) 先进后出 from queue import LifoQueue lq = LifoQueue(maxsiz...
分类: 其他 发布时间: 08-05 22:32 阅读次数: 0