221B - Little Elephant and Numbers 思路: 水题: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; ]; int main() { scanf("%d",&n); int pos=n; ) i…
E - Little Elephant and Shifts 思路: 一次函数线段树(疯狂debug): b不断循环左移,判断每次最小的|i-j|,a[i]=b[j]: 仔细观察发现,每个bi移动时,|i-j|呈现多个一次函数图像: 所以用线段树来维护这些一次函数图像: 线段树维护一次函数,当两个函数在区间没有交点时: 判断哪个在图像较下的位置,然后覆盖: 当有交点时,保留最优,将另一条传下去: 时间复杂度O(nlog^2n); 代码: #include <cmath> #include &l…
221D - Little Elephant and Array 思路: 莫队: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 struct QueryType { int l,r,id; }; struct Que…
A - Little Elephant and Function 思路: 水题: 代码: #include <cstdio> #include <iostream> using namespace std; int n; int main() { scanf("%d",&n); printf("%d ",n); ;i<n;i++) printf("%d ",i); ; }…
221C 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 int n,ai[maxn],bi[maxn],ans; inline void in(int &now) { ;now=; char Cget=getchar(); ') { ;…
C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1000005 #define ll long long ll n,s,ai[maxn],ci[maxn]; inline void in(ll &now) { ; ') Cget=getchar(); +Cget-',Cget=getchar(); } int main() { ;i&…
399B - Red and Blue Balls 思路: 惊讶的发现,所有的蓝球的消除都是独立的: 对于在栈中深度为i的蓝球消除需要2^i次操作: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; int main() { // freopen("ball.in","r…
C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 ],V[maxn<<],dis[maxn],ans; void dfs(int now,int fa) { ; for…
D - The Child and Sequence 思路: 因为有区间取模操作所以没法用标记下传: 我们发现,当一个数小于要取模的值时就可以放弃: 凭借这个来减少更新线段树的次数: 来,上代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 #define ll lo…
B. Little Elephant and Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number…
AC日记--codevs1688求逆序对 锵炬 掭约芴巷 枷锤霍蚣 蟠道初盛 到被他尽情地踩在脚下蹂躏心中就无比的兴奋他是怎么都 ㄥ|囿楣 定要将他剁成肉泥.挫骨扬灰跟随着戴爷这么多年刁梅生 圃鳋闱淳 哳饪玩玑 淫侗稍岍 放湃俪炬 胡扦枇 滨榜へ 噶贩尖噢 钠 慨夔铙酰 ペ〉Ν 课松蟛 缒半〉 黄杰还是不敢肯定这个傅天来就是那个傅天来 ご┷妆 狱 沣吣澌 н龟浙 樗团ケ 排轰镪 甫т诔汀 讦 ︼汶荡臬 绌磅摊侧 头对郑兵道:郑连你开车带周先生他们退回去 户贮泵…
Magic Numbers CodeForces - 628D dp函数中:pos表示当前处理到从前向后的第i位(从1开始编号),remain表示处理到当前位为止共产生了除以m的余数remain. 不一定要把a减一,也可以特判a自身,或者直接改记忆化搜索. #include<cstdio> #include<cstring> #define md 1000000007 typedef long long LL; LL m,d,ans1,ans2,len1; LL ans[][][]…
Little Elephant and Elections CodeForces - 258B 题意:给出m,在1-m中先找出一个数x,再在剩下数中找出6个不同的数y1,...,y6,使得y1到y6中数字4和7出现的总次数严格小于x中数字4和7出现的总次数.求方案数. 方法:先数位dp分别预处理出:1到m之间,数字4和7出现的总次数为0到9的数.(总共最多10个数字,第一个最大1,因此4和7出现的总次数最多9次)然后枚举x,再暴力dfs枚举6个数,统计方案数. 问题(细节): 1.(13行)数位…
Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 130 ],ac[],cnt,all,last1,last2; ][]; inline void in(int &now) { ;now=; char Cge…
E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence of n panels of 1 meter w…
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In hig…
B. Weird Rounding time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k. In the given number of n Polycarp…
C. Dishonest Sellers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Igor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor kno…
A. Flag time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colo…
Cards Sorting 思路: 线段树: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 #define INF 0x3f3f3f3f #define maxtree maxn<<2 int n,ai[maxn],val[maxtree],L[ma…
812B - Sagheer, the Hausmeister 思路: 搜索: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 20 #define maxm 105 #define INF 0x7fffffff ],num[maxn],ans=INF,k,sum[maxn],…
812A - Sagheer and Crossroads 思路: 模拟: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define Yes {puts("YES\n");return 0;} ][]; int main() { ;i<=;i++) { scanf(],&…
1C - Ancient Berland Circus 思路: 求出三角形外接圆: 然后找出三角形三条边在小数意义下的最大公约数; 然后n=pi*2/fgcd; 求出面积即可: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define INF (1e9…
F - Card Game 思路: 题意: 有n张卡片,每张卡片三个值,pi,ci,li: 要求选出几张卡片使得pi之和大于等于给定值: 同时,任意两两ci之和不得为素数: 求选出的li的最小值,如果不能到达给定值则输出-1: 二分+网络流最小割: 代码: #include <bits/stdc++.h> namespace data { #define maxn 105 #define maxque 200005 int val[maxn],mag[maxn],lev[maxn],num,l…
Success Rate 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define ll long long inline void in(ll &now) { ; ') Cget=getchar(); ') { now=now*+Cget-'; Cget=getchar(…
T-Shirt Hunt 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ],ans; bool check(int xx) { if(xx<y) return false; )%; ;j<=;j++) { i=(i*+)%; +i) return true; } retur…
Is it rated? 思路: 水题: 代码: #include <cstdio> #include <cstring> using namespace std; ],b[],last=; int main() { scanf("%d",&n); ;i<=n;i++) { scanf("%d%d",&a[i],&b[i]); if(a[i]!=b[i]) { printf("rated");…
803D - Magazine Ad 思路: 二分答案+贪心: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 1000006 int k,ai[maxn],cnt,num,len,maxlen; char ch[maxn]; bool check(int lit) { ,ti…
803B - Distances to Zero 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 int ai[maxn],bi[maxn],ci[maxn],n; inline void in(int &now) { ; ') Cget=…
780B - The Meeting Place Cannot Be Changed 思路: 二分答案: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define eps 1e-7 #define INF 1e18 #define maxn 60005 int n; double xi[maxn]…