CodeForces
文章平均质量分 55
CodeForces
西伯利亚松鼠
退役ACMer,退役MOer
展开
-
Codeforces Round #259 (Div. 1) D. Little Pony and Elements of Harmony FWT
D. Little Pony and Elements of Harmony solution ei[u]=∑vei−1[v]∗b[f(u,v)].e_i[u]=\sum_{v}e_{i-1}[v]*b[f(u,v)].ei[u]=v∑ei−1[v]∗b[f(u,v)]. 设 cnt[u⊕v]=b[f(u⊕v)]cnt[u⊕v]=b[f(u⊕v)]cnt[u⊕v]=b[f(u⊕v)],有: ei[u]=∑vei−1[v]∗cnt[u⊕v].e_i[u]=\sum_{v}e_{i-1}[v]*cnt[原创 2021-08-04 16:23:26 · 166 阅读 · 0 评论 -
Codeforces Round #198 (Div. 2) E. Iahub and Permutations DP
E. Iahub and Permutations solution n个数,ans个填−1的位置,res个已有数字且该数字原位置为−1的位置(万能)n个数,ans个填-1的位置,res个已有数字且该数字原位置为-1的位置(万能)n个数,ans个填−1的位置,res个已有数字且该数字原位置为−1的位置(万能) 传统错排:dp[i]=(i−1)(dp[i−1]+dp[i−2])传统错排:dp[i] = (i -1)(dp[i-1]+dp[i-2])传统错排:dp[i]=(i−1)(dp[i−1]+dp[i−原创 2021-05-03 22:54:55 · 753 阅读 · 1 评论 -
Codeforces Global Round 14 D. Phoenix and Socks 思维
D. Phoenix and Socks solution 除去相同颜色的已配对袜子,剩余袜子遍历颜色考虑: 当前l总大于r总且a[i][0]>1,则只需一次把l变成r的费用当前l_总大于r_总且a[i][0]>1,则只需一次把l变成r的费用当前l总大于r总且a[i][0]>1,则只需一次把l变成r的费用 当前r总大于l总且a[i][1]>1,则只需一次把r变成l的费用当前r_总大于l_总且a[i][1]>1,则只需一次把r变成l的费用当前r总大于l总且a[i][1原创 2021-05-03 18:53:57 · 827 阅读 · 0 评论 -
Educational Codeforces Round 104 div2 B. Cat Cycle
Educational Codeforces Round 104 div2 B. Cat Cycle input output code //Siberian Squirrel //#include<bits/stdc++.h> #include<unordered_map> #include<algorithm> #include<iostream> #include<cstring> #原创 2021-04-05 23:28:58 · 780 阅读 · 0 评论 -
2018 Yandex.Algorithm - Qualification Round C. Beautiful Tables 数学
C. Beautiful Tables code /*Siberian Squirrel*/ /*Cute JinFish*/ #include<bits/stdc++.h> using namespace std; typedef long long ll; const double PI = acos(-1), eps = 1e-8; /*const int MOD = 998244353, r = 119, k = 23, g = 3; const int MOD = 100453580原创 2021-03-26 15:19:06 · 1214 阅读 · 0 评论 -
Codeforces Global Round 1 C. Meaningless Operations 数学
C. Meaningless Operations code /*Siberian Squirrel*/ /*Cute JinFish*/ #include<bits/stdc++.h> using namespace std; typedef long long ll; const double PI = acos(-1), eps = 1e-8; /*const int MOD = 998244353, r = 119, k = 23, g = 3; const int MOD = 100原创 2021-03-26 14:46:51 · 807 阅读 · 0 评论 -
Mail.Ru Cup 2018 Round 2 C. Lucky Days 数学
C. Lucky Days code /*Siberian Squirrel*/ /*Cute JinFish*/ #include<bits/stdc++.h> using namespace std; typedef long long ll; const double PI = acos(-1), eps = 1e-8; /*const int MOD = 998244353, r = 119, k = 23, g = 3; const int MOD = 1004535809, r =原创 2021-03-25 14:30:20 · 716 阅读 · 0 评论 -
Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3) D. Barcelonian Distance
D. Barcelonian Distance solution 考虑五种情况,A,B两点与直线的交点两两组合,以及不经过直线的距离 code /*Siberian Squirrel*/ /*Cute JinFish*/ #include<bits/stdc++.h> using namespace std; typedef long long ll; const double PI = acos(-1), eps = 1e-8; /*const int MOD = 998244353,原创 2021-03-23 21:20:52 · 621 阅读 · 0 评论 -
Avito Cool Challenge 2018 E. Missing Numbers 数学
E. Missing Numbers solution 已知a1,a2,a3,a4,...,an−1,an,前缀和sum2[i]均为平方数,a_1,a_2,a_3,a_4,...,a_{n-1},a_n,前缀和sum^2[i]均为平方数,a1,a2,a3,a4,...,an−1,an,前缀和sum2[i]均为平方数, {sum[2k+1]=sum2[2k]+xsum[2k+2]=sum2[2k+1]+y\begin{cases}sum[2k+1]=\sqrt{sum^2[2k] + x} \\原创 2021-03-22 20:40:08 · 647 阅读 · 0 评论 -
Educational Codeforces Round 57 (Rated for Div. 2) C. Polygon for the Angle 数学
C. Polygon for the Angle solution 1<ang<180,预处理1至360边形的单位角度即可1<ang<180,预处理1至360边形的单位角度即可1<ang<180,预处理1至360边形的单位角度即可 code /*Siberian Squirrel*/ /*Cute JinFish*/ #include<bits/stdc++.h> using namespace std; typedef long long ll; co原创 2021-03-22 16:43:08 · 676 阅读 · 0 评论 -
Codeforces Round #460 (Div. 2) E. Congruence Equation 数学
E. Congruence Equation solution {i∗ai%p=b,i<p−1,(t−k)∗at%p=b,i≥p−1,i=(p−1)k+t.\begin{cases} i*a^i\%p=b,i<p-1, \\(t-k)*a^{t}\%p=b,i≥p-1,i=(p-1)k+t. \end{cases}{i∗ai%p=b,i<p−1,(t−k)∗at%p=b,i≥p−1,i=(p−1)k+t. 分别枚举 i,t.i,t.i,t. code /*Siberian Squirr原创 2021-03-22 16:26:46 · 634 阅读 · 0 评论 -
The 2018 ICPC Asia Nanjing Regional D - Country Meow 模拟退火
D - Country Meow solution 最小球覆盖 code /*Siberian Squirrel*/ /*Cute KiloFish*/ #include<bits/stdc++.h> #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; typedef long long ll; const double PI = acos(-1); const double原创 2021-03-19 18:55:30 · 655 阅读 · 0 评论 -
Codeforces Round #485 (Div. 1) B. Petr and Permutations 思维
B. Petr and Permutations input 5 2 4 5 1 3 output Petr code //Siberian Squirrel #include<bits/stdc++.h> #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define ACM_LOCAL using namespace std; typedef long long ll; const int INF = 0x3原创 2021-03-03 18:17:48 · 106 阅读 · 1 评论 -
Codeforces Round #481 (Div. 3) E. Bus Video System 思维
E. Bus Video System input 4 10 2 4 1 2 output 2 code //Siberian Squirrel #include<bits/stdc++.h> #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define ACM_LOCAL using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f原创 2021-03-03 16:23:22 · 659 阅读 · 1 评论 -
Avito Cool Challenge 2018 C. Colorful Bricks 组合数学
C. Bargain input output code原创 2021-03-03 15:52:47 · 658 阅读 · 0 评论 -
Educational Codeforces Round 83 (Rated for Div. 2) D. Count the Arrays 组合数学
D. Count the Arrays input output code原创 2021-03-03 14:45:29 · 92 阅读 · 0 评论 -
Codeforces Round #677 (Div. 3) E. Two Round Dances 组合数学
E. Two Round Dances input 20 output 12164510040883200 code //Siberian Squirrel #include<bits/stdc++.h> #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) //#define ACM_LOCAL using namespace std; typedef long long ll; const int N = 2e5原创 2021-03-01 19:33:25 · 622 阅读 · 0 评论 -
Codeforces Round #593 (Div. 2) B. Alice and the List of Presents 组合数学
B. Alice and the List of Presents input 1 3 output 7 code //Siberian Squirrel #include<bits/stdc++.h> #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) //#define ACM_LOCAL using namespace std; typedef long long ll; const int N = 2e5 +原创 2021-03-01 19:10:33 · 627 阅读 · 0 评论 -
Hello 2020 C. New Year and Permutation 组合数学
C. New Year and Permutation input 2020 437122297 output 265955509 code #include<bits/stdc++.h> using namespace std; typedef long long ll; const double PI = acos(-1); const int INF = 0x3f3f3f3f; const int N = 3e5+10; const int MOD =1e9 + 7; // int n,原创 2021-03-01 19:07:38 · 732 阅读 · 0 评论 -
Educational Codeforces Round 98 (Rated for Div. 2) D. Radio Towers 组合数学
D. Radio Towers input 200000 output 202370013 code #include<bits/stdc++.h> using namespace std; typedef long long ll; const double PI = acos(-1); const int INF = 0x3f3f3f3f; const int N = 3e5+10; const int MOD = 998244353; // int n, m, f[N]; ll temp原创 2021-03-01 19:01:48 · 631 阅读 · 0 评论 -
CodeForces - 1288C Two Arrays 组合数学
Two Arrays input 723 9 ouput 157557417 code #include<bits/stdc++.h> using namespace std; typedef long long ll; const double PI = acos(-1); const int INF = 0x3f3f3f3f; const int N = 3e5+10; const int MOD = 1e9 + 7; // int n, m, f[N]; ll temp; // ll q原创 2021-03-01 18:33:53 · 689 阅读 · 0 评论 -
Codeforces Round #701 (Div. 2) B. Replace and Keep Sorted 思维
B. Replace and Keep Sorted input 6 5 10 2 4 6 7 8 9 1 4 1 2 3 5 1 6 5 5 output 8 9 7 6 9 code //Siberian Squirrel //#include<bits/stdc++.h> #include<unordered_map> #include<algorithm> #include<iostream> #include<cstring> #inc原创 2021-02-22 08:48:59 · 738 阅读 · 0 评论 -
Educational Codeforces Round 104 (Rated for Div. 2) D. Pythagorean Triples 数学
D. Pythagorean Triples input 3 3 6 9 output 0 1 1 solution c2=a2+b2 (i)c^2=a^2+b^2~(i)c2=a2+b2 (i) c=a2−b (ii)c=a^2-b~(ii)c=a2−b (ii) =>c2−b=b2+b=>c^2-b=b^2+b=>c2−b=b2+b =>c=b+1=>c=b+1=>c=b+1 =>b=a2−12,c=a2+12=>原创 2021-02-21 17:48:01 · 648 阅读 · 0 评论 -
Codeforces Round #703 (Div. 2) B. Eastern Exhibition 思维
Codeforces Round #703 (Div. 2) B. Eastern Exhibition input 6 3 0 0 2 0 1 2 4 1 0 0 2 2 3 3 1 4 0 0 0 1 1 0 1 1 2 0 0 1 1 2 0 0 2 0 2 0 0 0 0 output 1 4 4 4 3 1 solution 分别找x,y方向上的中位数分别找x,y方向上的中位数分别找x,y方向上的中位数 code //Siberian Squirrel //#include<bits/st原创 2021-02-20 16:43:47 · 670 阅读 · 0 评论 -
Codeforces Round #701 (Div. 2) C. Floor and Mod codeforces 思维 + 数学
input 9 3 4 2 100 4 3 50 3 12 4 69 420 12345 6789 123456 789 12345678 9 output 1 0 2 3 5 141 53384 160909 36 solution 要想使x/i=x%i,有x/i=x%i=i−1,从1开始遍历即可,对于i最小符合的值为(i∗(i+2),i+1),只需比较x,y中哪个“较小”即可,详情见代码要想使x/i=x\%i,有x/i=x\%i=i-1,从1开始遍历即可,对于i最小符合的值为(i*(i+2),i+1),原创 2021-02-13 18:07:37 · 830 阅读 · 1 评论