divisors 294 uva

UVA10812 Beat the Spread! 题解

[题目链接](https://www.luogu.com.cn/problem/UVA10812) ## 思路 大家应该都知道绝对值是什么吧? 那么,我们不妨直接设 $a\gt b$,这样就省去了一次分类讨论的麻烦,大大降低了程序的复杂度。即可得到此二元一次含参方程组: $$ \begin{case ......
题解 Spread 10812 Beat UVA

B. Longest Divisors Interval

[link](https://codeforces.com/contest/1855/problem/B) 需要思考一下 如果这个题能做,那么肯定有一种比较可行的做法。 如果$[l,r]$是可行的,那么就意味着$[1,r-l+1]$是可行的 这是显然的,显然后者的每一个数在前者中必然有对应的倍数,所 ......
Divisors Interval Longest

[ABC142D] Disjoint Set of Common Divisors

首先我们知道,若一个数是另外两个数的公共因数,那么它肯定能整除另外两个数的最大公约数。 所以我们可以**枚举最大公约数的质因数**,再把这个质因数在最大公约数中除完,并且答案加一。 注意,要用 `long long` 不然 `int` 溢出之后还在循环,就会导致超时。 ```cpp #include ......
Disjoint Divisors Common 142D ABC

UVA114 Simulation Wizardry

# UVA114 Simulation Wizardry [题目传送门](https://www.luogu.com.cn/problem/UVA114) 此题为模拟类型,必须认真读题,绝不能漏掉任何一个细节。 ## 分析 解释代码中的主要部分: 1. 结构体定义:`struct POINT` 用于 ......
Simulation Wizardry UVA 114

UVA11732 "strcmp()" Anyone?

# UVA11732 "strcmp()" Anyone? [题目传送门](https://www.luogu.com.cn/problem/UVA11732) 一个我认为比较有趣的问题…… ## 题意 给出 $n$ 个字符串,两两比较字典序大小,求出所需比较的总次数并输出。 ## 分析 使用 tr ......
quot Anyone strcmp 11732 UVA

UVA12462 Rectangle

# UVA12462 Rectangle [题目传送门](https://www.luogu.com.cn/problem/UVA12462) ##### 可以说是广告印刷的加强版。 ## 题目大意 有 $n$ 个矩形依次相邻,$m$ 种颜色。第 $i$ 个矩形高度 $h_i$,宽度为 $1$,颜色 ......
Rectangle 12462 UVA

UVA11538 Chess Queen

# UVA11538 Chess Queen [题目传送门](https://www.luogu.com.cn/problem/UVA11538) 挺有意思的一个题目。 ## 题目大意 给定一个棋盘,在棋盘上放两个皇后(一白一黑),求使得两个皇后相互攻击(在一行、一列或对角线)的方案数。 ## 分析 ......
11538 Chess Queen UVA

UVA333 题解

## 大意: 给定一个字符串 $s$ 判断 $s$ 是否符合要求。 1. 由数字,`-` 和大写英文数字 `X`,空格组成,`X` 代表 $10$ 且只能在最后出现。 2. 依次相加前面的数字的总和可以被 $11$ 整除,也就是前缀和,而且刚好 $s$ 只有 $10$ 个数字。 ## 坑点: 1. ......
题解 UVA 333

Codeforces 1855B:Longest Divisors Interval 最长的连续约数区间

# [1855B.Longest Divisors Interval](https://codeforces.com/contest/1855/problem/B "Codeforces 1855B") ## Description: - 对于一个整数 $n$ $(1\leq n \leq 10^{ ......
约数 区间 Codeforces Divisors Interval

UVA 12170

从另一个网站上的我的博客里转的。感觉放在一起比较好。时间久远,而且是英文(流泪)。 # [Easy Climb](https://www.luogu.com.cn/problem/UVA12170) ## Step 1 If $x_i,d\le 100$. Then define $dp_{i,j} ......
12170 UVA

Longest Divisors Interval

Smiling & Weeping 总有一个人, 一直住在心底, 却消失在生活里。 Given a positive integer n, find the maximum size of an interval [l,r] of positive integers such that, for e ......
Divisors Interval Longest

CF1855B Longest Divisors Interval 题解

原题链接:https://codeforces.com/contest/1855/problem/B 题意:给定一个正整数 n, 找到满足该条件的区间 [l, r] 的长度的最大值:对于任意 l <= i <= r,n 均为 i 的倍数(多组数据)。 思路:如果 n 是奇数,答案显然是 1,因为任意 ......
题解 Divisors Interval Longest 1855B

CF1855B Longest Divisors Interval 题解

## 题意: 给定一个数 $n$,求一个连续区间 $[l,r]$ 使得 $n$ 是区间内每个数的倍数,最大化这个区间的长度(多组数据)。 ## 思路: 逆向思考一波,( 如果一个数 $x$ 不是 $n$ 的因数,那么 $x$ 的倍数不能在区间内。 举个例子,比如 $ n $ 是13,3不是13的因数 ......
题解 Divisors Interval Longest 1855B

UVA10702 Travelling Salesman 题解

UVA10702 Travelling Salesman 题解 题面: 有个旅行的商人,他每到一个的新城市,便卖掉所有东西再购买新东西,从而获得利润。从某城市 A 到某城市 B 有固定利润(B 到 A 的利润可能不同)。已知城市可以重复到达,从 S 点出发,经过 T 个城市,有 E 个城市能作为终点 ......
题解 Travelling Salesman 10702 UVA

2017-12-21-UVA-11275

redirect_from: /_posts/2017-12-21-UVA-11275/ title: 3D Triangles tags: - 算法竞赛 - [三维几何模板](https://wu-kan.cn/_posts/2019-01-27-%E8%AE%A1%E7%AE%97%E5%87% ......
11275 2017 UVA 12 21

UVA??? 考试 Exam

本来这篇题解是想在中考前写的,但是直到考前都没调出来,原因是 `pow()` 的精度感人。 由于 $x\equiv0\pmod{a\cdot b}$,令 $c=\dfrac{x}{ab}$,答案即 $abc\le n$ 的**无序**三元组 $(a,b,c)$ 数量。 考虑把无序转成有序,即 $a\ ......
Exam UVA

UVA10791 最小公倍数的最小和 Minimum Sum LCM 题解

### 前言 长沙市一中8机房0714模拟测1。 [传送门](https://www.luogu.com.cn/problem/UVA10791) [blog](https://www.luogu.com.cn/blog/JJL0610666/solution-uva10791) # 思路 本题思路 ......

AtCoder Beginner Contest 294

# A - Filter ```cpp #include using namespace std; #define int long long int32_t main() { ios::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nul ......
Beginner AtCoder Contest 294

UVA210 双端队列模拟并行程序

#include<iostream> #include<algorithm> #include<string> #include<sstream> #include<vector> #include<queue> #include<cstring> using namespace std; cons ......
队列 程序 UVA 210

[LeetCode] 1071. Greatest Common Divisor of Strings

For two strings s and t, we say "t divides s" if and only if s = t + ... + t (i.e., t is concatenated with itself one or more times). Given two string ......
LeetCode Greatest Divisor Strings Common

UVA12222 Mountain Road 山路 题解 dp

UVA12222 山路 题意: - - 一个山路只有一条车道,因此不能有两辆方向相反的车同时在车道内。同时,为了保证安全,车道内不能超车,且同向行驶的车间距必须大于10分钟。现在给你n辆车,三个参数依次表示行驶方向,到达时刻,行驶时间。问如何安排能使最后一个通过的车通过时的时刻最小,输出这个值。 分 ......
题解 山路 Mountain 12222 Road

UVA11090 Going in Cycle!!题解

## 题目大意 给定一个N个点M条边的带权有向图,求平均值最小的回路。 ## 解法 看到这种题目,~~喜欢打暴力的我~~一下就想到:遍历整个图,找到每一个环,然后算出它们的平均值,最后比较出最小值。然而,呃...,会T飞... **既然我们不能暴力找最小值,那还有什么别的办法吗?** 我们只需要输出 ......
题解 11090 Going Cycle UVA

UVA12716 GCD等于XOR GCD XOR

UVA12716 GCD等于XOR GCD XOR 一道数学题。 首先,我们可以知道,a-b>=gcd(a,b)=c; 其次,a-b<=a xor b=c; 综上,可得a-b=c,即a-b=a xor b. 由于范围不大,直接枚举。 第一层枚举c(因为c较少),第二层枚举a,(b=a-c) 再判断c ......
GCD XOR 12716 UVA

[数论]Divisor and Gcd

## Divisor and Gcd ### 1、算术基本定理:n的质因数分解唯一 一些常见结论: 1.素数无限 2.$\lim_{n\rightarrow+\infty}n\prod\dfrac{n}{\frac{n}{\ln{n}}}$(Π(n)表示 ab|c$ 3.$a|bc,(a,b) = ......
数论 Divisor and Gcd

AtCoder Beginner Contest 294 E

# [AtCoder Beginner Contest 294](https://atcoder.jp/contests/abc294) ## E - 2xN Grid ### Problem Statement 题意:给你$2$行长度为$L$的矩阵。告诉你格子里面的数字,以$vi$ $li$的形式 ......
Beginner AtCoder Contest 294

UVA1401 Remember the Word

## 思路 首先有一个比较朴素的 DP 就是记 $f_i$ 为 $s$ 的从第 $i$ 个字符开始到字符串结尾的划分方案数,记模板串的集合为 $T$,$s$ 从第 $i$ 个字符开始到字符串结尾的子串为 $s(i)$,那么不难写出方程: $$ f_i = \sum f_{i + \operatorn ......
Remember 1401 Word UVA the

Uva--10305 Ordering Tasks(拓扑排序/dfs)

**记录** 15:42 2023-5-26 https://onlinejudge.org/external/103/p10305.pdf reference:《算法竞赛入门经典第二版》例题6-15 拓扑排序,存在有向环的图没有解。不包含有向环的有向图称为有向无环图(Directed Acycli ......
拓扑 Ordering 10305 Tasks Uva

UVA10902 Pick-up Sticks 题解

## Description 按顺序给出 $n$ 个棍子两个端点的坐标。如果后来的棍子与前边的棍子相交,则说后面的把前面的挡住了。问最后有多少个棍子没被挡住。 $n\leq 10^5$,且**答案不超过 $1000$**。 ## Solution 叉积基本运用。 1. 定义:$\overrighta ......
题解 Pick-up Sticks 10902 Pick

[ABC294G] Distance Queries on a Tree 题解

## Description 有一个节点数为 $N$ 的树。边 $i$ 连接 $u_i$ 和 $v_i$,边的权值为 $w_i$。 $Q$ 次询问,询问一共有两种。 ```1 i w``` :改变第 $i$ 条边的权值为 $w$。 ```2 u v``` :输出 $u$ 到 $v$ 的路径距离。 数 ......
题解 Distance Queries 294G Tree

UVA1514 Piece it together 题解

图论题还是在于建图 ## 题意 给定一个长度为 $n \times m$ 的网格图,有的地方是白方块,有的是黑方块,有的啥也没用。 给你如下四种 $L$ 形方块,询问是否存在方法,让这些方块正好就是给出的图的形状。 $ L $ 形方块如下 ![](https://cdn.luogu.com.cn/u ......
题解 together Piece 1514 UVA