数论基础
整除/gcd设a,b两个整数,如果存在整数$c$使得$a=bc$,则称$b$整除$a$,又称$a$是$b$的倍数,$b$是$a$的因子,记作$a|b$.设两个整数a,b,且$b\ne 0$,则存在唯一的整数$q$和$r$使得$$ a = qb + r, 0 \le r < |b|$$
整数相关性质性质1:$$ a | c, b | c \Rightarrow ab | c$$性质2:$$ a | b, b | c \Rightarrow a | c$$性质3:设$m \ne 0$,则$$ a | b \Rightarrow ma | mb$$性质4:$$ 若a | b, b | a \Rightarrow a = \pm b$$
素数/合数应该没人不知道什么是素数pass
不知道该叫什么定理合数 $m$ 的最小的不等于 1 的正因子$p$一定是素数,且$p \le \sqrt{m}$.
伯特兰-切比雪夫定理设整数$n > 3$,至少存在一个素数$p$满足$n < p < 2 * n ...
Atcoder Beginner Contest 133
自己把题目翻译一遍就当,考研翻译训练了()
A T or T题意我们有$N$个人要去旅行,通过乘坐火车或者出租车进行出游,坐火车我们每个人要出$A$元(日元),做出租车我们总共会花费$B$元。请问,我们的旅费最少是多少?
思路直接计算两种出行方式的总花费,输出最小值
code123456789101112131415161718192021222324252627#include<bits/stdc++.h>using namespace std;#define int long longint read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch ...
Atcoder Beginner Contest 132
A Fifty-Fifty12345678910111213141516171819202122232425262728293031323334353637#include<bits/stdc++.h>using namespace std;#define int long longint read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } ...
Atcoder Beginner Contest 131
A Securit12345678910111213141516171819202122232425262728293031#include<bits/stdc++.h>#define int long longint read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f;}signed main() ...
Atcoder Beginner Contest 130(A-F)
A Rounding1234567891011121314151617181920212223242526#include<bits/stdc++.h>using namespace std;#define int long longint read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f;}sig ...
Atcoder Beginner Contest 315(A-F)
A tcdr123456789101112131415#include<bits/stdc++.h>using namespace std;int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); string s; cin >> s; for(int i = 0; i < s.size(); i++) { if(s[i] == 'a' || s[i] == 'e' || s[i] == 'o' || s[i] == 'u' || s[i] == 'i') continue; cout << s[i]; } return 0;}
B The Middle Day12345678910111213141516171819202122232425#include<bits/stdc++.h>using namespace std;i ...
Codeforces Round 894 (Div. 3)
A Gift Carpet模拟,按列遍历一个一个选
12345678910111213141516171819202122232425262728293031323334#include<bits/stdc++.h>using namespace std;const string s = "vika";void solve(){ int n, m; cin >> n >> m; vector<string> g(m); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { char c; cin >> c; g[j] += c; } } int ans = 0; for(int i = 0; i < m && ans ...
Atcoder Beginner Contest 314
A 3.14code1234567891011#include<bits/stdc++.h>using namespace std;int main(){ string s = "1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679"; int n; cin >> n; cout << "3." << s.substr(0,n); return 0;}
B Roulette找到目标,排序输出
123456789101112131415161718192021222324252627282930313233343536373839404142#include<bits/stdc++.h>using namespace std;int c[110], b[110][40];int main(){ int n; cin ...
HDU-4578 Transformation
TransformationYuanfang is puzzled with the question below:There are n integers, a1, a2, …, an. The initial values of them are 0. There are four kinds of operations.Operation 1: Add c to each number between ax and ay inclusive. In other words, do transformation ak<—ak+c, k = x,x+1,…,y.Operation 2: Multiply c to each number between ax and ay inclusive. In other words, do transformation ak<—ak×c, k = x,x+1,…,y.Operation 3: Change the numbers between ax and ay to c, inclusive. In oth ...
HDU-4614 Vases and Flowers
Vases and Flowers Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase. She randomly choose the vase A and try to put a flower in the vase. If the there is no flower in the vase, she will put a flower in it, otherwise she skip this vase. And then she will try put in the vase A+1, A+2, …, N-1, until there is no flower left or she has tried the vase N-1. ...