https://vjudge.net/contest/175596#overview A.设第i次出现的位置左右端点分别为Li,Ri 初始化L0 = 0,则有ans = sum{ (L[i] - L[i-1]) * (n + 1 - Ri) } #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; ]; long…
https://vjudge.net/contest/174962#overview A.我们发现重点在于x,y只要累加就ok了 在每个x上只有上下两种状态,所以可以记忆化搜索 f[0/1][i]表示 x = i 时向下/上走,那需要移动多少才能走出去 #include <cstdio> #include <algorithm> using namespace std; ; typedef long long ll; ll a[maxn], f[][maxn]; ][maxn],…
https://vjudge.net/contest/174020 A.100条双向边,每个点最少连2个边 所以最多100个点,点的标号需要离散化 然后要求恰好经过n条路径 快速幂,乘法过程就是floyed就行了 #include <algorithm> #include <cstring> #include <cstdio> using namespace std; ; ]; struct matrix { ][]; matrix() { memset(c, 0x3f…
https://vjudge.net/contest/173780 A.假设 Pt = i,则由Ppi = i得 Ppt = t = Pi 所以就有 if Pt = i then Pi = t #include <cstdio> #include <algorithm> using namespace std; ]; int main() { scanf("%d", &n); ) puts("-1"); else { ;i <=…
https://vjudge.net/contest/173277#overview A.平方差公式后变为 n = (x + y)(x - y) 令 t = x - y ,变成 n = (t + 2x) * t,要 x 最小 O(sqrt(n)) 枚举 n 的因数即可 #include <cstdio> typedef long long ll; ll n, m, k, t; int main() { scanf("%lld", &n); while(n --) {…
https://vjudge.net/contest/172464 后来补题发现这场做的可真他妈傻逼 A.签到傻逼题,自己分情况 #include <cstdio> #include <vector> #include <algorithm> using std::vector; using std::sort; typedef long long ll; int n, m; ll a[], b[]; ll sa, sb, dis, tmp, qaq; , t2 = -…
https://vjudge.net/contest/171368#overview A.一个签到题,用叉积来判断一个点在一条线的哪个方向 可以二分,数据范围允许暴力 #include <cstdio> struct point { int x, y; }a[]; ], y[], c[]; int _cross(const point &A, const point &B) { return A.x * B.y - A.y * B.x; } int main() { ], &a…
D.What a Mess 给n个数,求其中能满足 a[i] % a[j] == 0 的数对之和 n = 1W,max_ai = 100W 不是很大,所以就直接筛就可以了 计算可得最高复杂度 < 1kW ...考场上写了这个解法,结果把 j += i 写成了 j ++ ... 我还以为是单个测试点case太多...多么痛的领悟... #include <bits/stdc++.h> using namespace std; ], b[]; int main() { scanf("…
leecode刷题(16)-- 字符串转换整数 字符串转换整数 描述: 请你来实现一个 atoi 函数,使其能将字符串转换成整数. 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止. 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号:假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数. 该字符串除了有效的整数部分之后也可能会存在多余的字符,这些字符可以被忽略,它们对于函数不应该造成影…
整理几个经常使用GUID转换成16位字符串或19位唯一字符串方法: /// <summary> /// 依据GUID获取16位的唯一字符串 /// Author : 付义方 /// </summary> /// <param name=\"guid\"></param> /// <returns></returns> public static string GuidTo16String() { long i =…