8. 字符串转换整数(atoi) 直接模拟 class Solution { public int myAtoi(String s) { int ans = 0; int coefficient = 1; boolean hasFirst = false; for(char c : s.toChar ...
分类:
其他好文 时间:
2021-01-22 12:04:19
阅读次数:
0
const int MAXN = 200000 + 10; const int MAXM = 2000000 + 10; int n, m; vi G[MAXN]; int vis[MAXN]; int fa[MAXN]; int ans[MAXN]; struct Query { int x, y ...
分类:
编程语言 时间:
2021-01-16 12:11:10
阅读次数:
0
题目 1 class Solution { 2 public: 3 vector<double>ans; 4 vector<double> averageOfLevels(TreeNode* root) { 5 if(!root) return ans; 6 queue<TreeNode*>q; 7 ...
分类:
其他好文 时间:
2021-01-13 10:58:14
阅读次数:
0
给定给 \(n\) 个点,以及 \(m\) 条线段,选择 \(s\) 条线段,使得至少被一个线段覆盖的点的坐标从小到大排序后,第 \(k\) 大最小,没有则输出 \(-1\)。 \(n, m, s, k \leq 1500\)。 二分答案 \(ans\),判断是否存在一个方案使小于等于 \(ans\ ...
分类:
其他好文 时间:
2021-01-07 12:42:20
阅读次数:
0
例题:HDU4135 HDU2841,HDU1695,HDU3501 HDU4135例题博客 利用容斥原理,先求不互质的个数 ans,最后结果 n?ans。 先将 m 分解质因子。存到 p数组里。 假如 m 有 2,3,5质因子,那么2, 3, 5的倍数与 m 都不互质,但是会有重复。用容斥原理算出 ...
分类:
其他好文 时间:
2020-12-30 11:02:57
阅读次数:
0
import randomimport mathimport fractionsq=[]ans=[]def c1(q,ans) symble = random.choice(['+','-','*','/']) if symble == '+': n1 = random.randint(0,20) ...
分类:
其他好文 时间:
2020-12-04 10:49:38
阅读次数:
6
1 import random#导入随机库 2 from fractions import Fraction#导入分数运算 3 ##整数运算 4 def c1(q, ans): 5 operator = random.choice(['+', '-', '*', '/']) # 生成运算符 6 if ...
分类:
其他好文 时间:
2020-12-03 12:26:32
阅读次数:
16
四则运算 1 import random#确保随机取数 2 from fractions import Fraction#确保能使用分数表示真分数 3 4 5 ##两个整数的四则运算 6 def c1(q, ans): 7 symbol = random.choice(['+', '-', '*', ...
分类:
其他好文 时间:
2020-12-03 12:20:32
阅读次数:
6
T2 第一二个测试点直接 \(O(nm)\) 暴力就可以了吧。但是需要注意 1e4 * 1e4 要卡常, T 掉的大概吧 max 函数手写一下,写成 #define max(a,b) (a>b?a:b)就可以了 for(int i=1;i<=q;++i){ x=read();ans=0; for(i ...
分类:
其他好文 时间:
2020-11-17 12:35:39
阅读次数:
8
PSP表格: 改进思路: 小学不只是有整数的运算,还有分数的运算,在此加入分数的四则运算训练。 代码改进: 1 import random 2 from fractions import Fraction 3 ##两个整数的四则运算 4 def c1(q, ans): 5 symbol = rand ...
分类:
其他好文 时间:
2020-11-11 16:01:54
阅读次数:
7