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) %...
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];
}
...
牛客小白月赛5 - j - 时间time
链接:https://www.nowcoder.com/acm/contest/135/J
来源:牛客网
Apojacsleam是一个喜欢特殊时刻的人。
他定义了一个时刻,若电子表显示ab:ba(24小时制),则该时刻为“回文时刻”(可以有前导零)。例如00:00就是回文时刻。
给定一个时刻,求此时刻的上一个和下一个回文时刻。
J题附加:00:00就是...
牛客小白月赛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]内的元素之和?...
牛客小白月赛5 - G - 异或(xor)【找规律】
链接:https://www.nowcoder.com/acm/contest/135/G
从前,Apojacsleam家的水族箱里,养了一群热带鱼。
在这几条热带鱼里,Apojacsleam特别喜欢一条叫做TbGx(请勿人肉)的热带鱼,所以每次都让她第一个吃食物。对于每一条鱼,Apojacsleam都有一个顺序,鱼会按照这个顺序排序,越靠前的地位越高。
吃饱喝足是要睡觉的...
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...
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,...
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...
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...
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[...
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...
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],...
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]...
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()
{...
UVA - 10129 -Play on Words【欧拉路】/补
(来自:《算法竞赛入门经典》)题意:输入n(n≤100000)个单词,是否可以把所有这些单词排成一个序列,使得每个单词的第一个字母和上一个单词的最后一个字母和上一个单词的第一个字母相同(例如acm,malform,mouse)。每个单词最多包含1000个小写字母。输入中可以有重复的单词。
【分析】
把字母看作结点,单词看成有向边,则问题有解,当且仅当图中有欧拉路径。前面讲过,有向图存在欧拉道路...
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...
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, ...
Python自带队列模块Queue的使用(1)
Python自带的队列模块有4种队列:
FIFO:first in first out 先进先出
LIFO:last in first out 后进先出,类似于栈的数据结构
proiority:优先队列
deque: 双端队列
这一部分,先介绍FIFO模式的队列,后三种队列会在后续的文章种介绍
设置队列长度、进队列与出队列
from queue import Queue
...
Python自带队列模块Queue的使用(2)
LIFO队列,是一个先进后出的队列,类似于栈的数据结构
导入模块
from queue import LifoQueue
查看源码会发现LifoQueue是继承了Queue队列,所以使用创建对象时用法跟Queue一样
lq = LifoQueue(maxsize=0)
先进后出
from queue import LifoQueue
lq = LifoQueue(maxsiz...
今日推荐
周排行