CodeForces 548B Mike and Fun (模拟)】的更多相关文章

题意:给定一个n*m的矩阵,都是01矩阵,然后每次一个询问,改变一个格的值,然后问你最大有数是多少. 析:就是按他说的模拟,要预处理,只要把每行的最大值记下来,当改变时,再更新这一行的最大值. 代码如下: #include<bits/stdc++.h> using namespace std; const int maxn = 500 + 5; int a[maxn][maxn]; int num[maxn]; int main(){ int n, m, q, x, y; while(cin…
传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m g…
hdu4135 求[L,R]范围内与N互质的数的个数. 分别求[1,L]和[1,R]和n互质的个数,求差. 利用容斥原理求解. 二进制枚举每一种质数的组合,奇加偶减. #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int fac[N], cnt; void factor(int n) { cnt = ; int limit = sqrt(n); ; i <= limit; ++i) { ) fa…
codeforces 547E Mike and Friends 题意 题解 代码 #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define rep(i, a, b) for(int i=(a); i<(b); i++) #define per(i, a, b) for(int i=(b)…
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #include <map> #include <queue>…
codeforces 689 Mike and Shortcuts(最短路) 原题 任意两点的距离是序号差,那么相邻点之间建边即可,同时加上题目提供的边 跑一遍dijkstra可得1点到每个点的最短路,时间复杂度是O(mlogm) #include <cstdio> #include <iostream> #include <cstring> #include <queue> #include <vector> using namespace s…
C. Mike and gcd problem time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful…
http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column n…
Mike and Cellphone 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/E Description While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old…
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开始,如果可以完成任务,那么输出id总和,否则输出-1. 思路:简单的模拟,注意如果不能完成任务,那么ser数组是不能更新的. #include <cstdio> #include <algorithm> #include <iostream> #include <cs…