360网站排名优化,网站建设解说词,聚美优品网站建设导向,wordpress链接数据库文件夹codechef是真敢给分#xff0c;上把刚注册#xff0c;这把就div2了#xff0c;再加上一周没打过还是有点不适应的#xff0c;好在最后还是能够顺利上分 今天的封面是P3R的设置菜单 我抠出来做我自己的游戏主页了#xff08;
A - Convert string
题意
在01串里面可以翻转…codechef是真敢给分上把刚注册这把就div2了再加上一周没打过还是有点不适应的好在最后还是能够顺利上分 今天的封面是P3R的设置菜单 我抠出来做我自己的游戏主页了
A - Convert string
题意
在01串里面可以翻转k次问从1到n有多少个k有机会使01串所有元素相同
思路
暴力遍历求解即可一开始下标打错了wa了一发
代码
#include bits/stdc.h
using namespace std;
typedef long long ll;
typedef double db;
typedef pairint,int pii;
typedef pairll,ll pll;void solve()
{int n;scanf(%d,n);string s;cins;int one0,zero0;for(int i0;in;i){if(s[i]1){one;}else{zero;}}int cnt0;for(int k1;kn;k){//全变1if(kzero and (k-zero)%20){
// printf(%d ,k);cnt;continue;}//全变0if(kone and (k-one)%20){
// printf(%d ,k);cnt;continue;}}
// printf(\n);printf(%d\n,cnt);
}int main()
{int T1;scanf(%d,T);while(T--){solve();}return 0;
}B - Ball Game
题意
好多小球冲家速度各不相同中间撞上了就会融合成一个速度取最大值的新小球问最后一共有多少个小球到终点
思路
所谓的融合其实就是大球吃小球维护个pq然后大小比较无效化就行
代码
#include iostream
#include algorithm
#include map
#include cstring
#include string
#include vector
#include cctype
#include cmath
#include queue
#include set
using namespace std;
typedef long long LL;
typedef pairLL, int PLL;
#define qwq ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define tcase \LL t read(); \while (t--)LL read()
{LL sum 0, fl 1;int ch getchar();for (; !isdigit(ch); ch getchar())if (ch -)fl -1;for (; isdigit(ch); ch getchar())sum sum * 10 ch - 0;return sum * fl;
}
const int N 1e6 10;
struct node
{LL d, v;bool operator(const node T) const{return d T.d;}
} a[N];struct node2
{LL x, y;bool operator(const node2 T) const{return x * T.y T.x * y;}
};void solve()
{LL n read();for (int i 1; i n;i)a[i].d read();for (int i 1; i n;i)a[i].v read();sort(a 1, a 1 n);priority_queuenode2 pq;for (int i 1; i n;i){node2 nowt {a[i].d,a[i].v};while(pq.size()nowtpq.top())pq.pop();pq.push(nowt);}printf(%lld\n, pq.size());
}int main()
{tcasesolve();return 0;
}
C - Sequence Search
题意 X 1 0 ; X_1 0; X10; X 2 A ; X_2 A; X2A; X 3 B ; X_3 B; X3B; X i X i − 1 X i − 2 X i − 3 ; X_i X_{i-1}X_{i-2}X_{i-3}; XiXi−1Xi−2Xi−3; 一直A和B求数组中第k小的数
思路
简单枚举一下很容易可以发现规律
0,A,B,AB,2B,A2B,3B,A3B,4B,A4B,5B,A5B,6B,A6B,7B,A7B,8B,A8B,9B,A9B,10B,A10B,11B,A11B,12B,A12B,13B,A13B,14B然后现在还要排序很容易想到比较时一个很重要的印象因素就是A是B的几倍然后再枚举下找下规律就行了
0,B,A,2B,AB,3B,A2B,4B,A3B,5B A/B1
0,B,2B,A,3B,AB,4B A/B2代码
#include bits/stdc.h
using namespace std;
typedef long long ll;
typedef double db;
typedef pairint,int pii;
typedef pairll,ll pll;//0,A,B,AB,2B,A2B,3B,A3B,4B,A4B,5B,A5B,6B,A6B,7B,A7B,8B,A8B,9B,A9B,10B,A10B,11B,A11B,12B,A12B,13B,A13B,14B,A14B,15B,A15B,16B,A16B,17B,A17B,18B,A18B,19B,A19B,20B,A20B,21B,A21B,22B,A22B,23B,A23B,24B,A24B,25B,A25B,26B,A26B,27B,A27B,28B,A28B,29B,A29B,30B,A30B,31B,A31B,32B,A32B,33B,A33B,34B,A34B,35B,A35B,36B,A36B,37B,A37B,38B,A38B,39B,A39B,40B,A40B,41B,A41B,42B,A42B,43B,A43B,44B,A44B,45B,A45B,46B,A46B,47B,A47B,48B,A48B,49B,A49B,50B,A50B,51B,A51B,52B,A52B,53B,A53B,54B,A54B,55B,A55B,56B,A56B,57B,A57B,58B,A58B,59B,A59B,60B,A60B,61B,A61B,62B,A62B,63B,A63B,64B,A64B,65B,A65B,66B,A66B,67B,A67B,68B,A68B,69B,A69B,70B,A70B,71B,A71B,72B,A72B,73B,A73B,74B,A74
//0,B,A,2B,AB,3B,A2B,4B,A3B,5B A/B1
//0,B,2B,A,3B,AB,4B A/B2
void solve()
{ll A,B,K;scanf(%lld%lld%lld,A,B,K);int timeA/B;int start3time;if(Kstart-1){printf(%lld\n,A);return ;}if(K1){printf(%lld\n,0);return ;}if(Kstart){printf(%lld\n,(K-1)*B);return ;}K-start;K;if(K%21){printf(%lld\n,((K1)/2time)*B);return ;}else{printf(%lld\n,(K/2)*BA);return ;}
}int main()
{int T1;scanf(%d,T);while(T--){solve();}return 0;
}D - Shooting (Easy)
题意
射飞镖以一个点为中心点距离为得分求两个人在每个点作为中心点情况得分的差值
思路
前缀和维护即可
代码
#include iostream
#include algorithm
#include map
#include cstring
#include string
#include vector
#include cctype
#include cmath
#include queue
#include set
using namespace std;
typedef long long LL;
typedef pairLL, int PLL;
#define qwq ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define tcase \LL t read(); \while (t--)LL read()
{LL sum 0, fl 1;int ch getchar();for (; !isdigit(ch); ch getchar())if (ch -)fl -1;for (; isdigit(ch); ch getchar())sum sum * 10 ch - 0;return sum * fl;
}
const int N 1e6 10;
LL d[N];
LL s1[N], s2[N];void solve()
{LL sum1 0, sum2 0;LL n read(),m read();n m;for (int i 1; i m;i)d[i] read();for (int i 1; i m;i){s1[i] s1[i - 1] 1;s2[i] s2[i - 1] 1;if(d[i]1){s1[i];sum1 i - 1;}else if(d[i]2){s2[i];sum2 i - 1;}else if(d[i]3){s1[i];s2[i];sum1 i - 1;sum2 i - 1;}// printf(%lld %lld\n, s1[i], s2[i]);}//printf(%lld %lld\n, s1[m], s2[m]);printf(%lld , llabs(sum1 - sum2));// printf(de %lld %lld\n, sum1, sum2);for (int i 2; i m;i){sum1 s1[i - 1];sum1 - s1[m] - s1[i - 1];// printf(add:%lld sub:%lld\n, s1[i - 1], s1[m] - s1[i - 1]);sum2 s2[i - 1];sum2 - s2[m] - s2[i - 1];// printf(add:%lld sub:%lld\n, s2[i - 1], s2[m] - s2[i - 1]);printf(%lld , llabs(sum1 - sum2));// printf(de %lld %lld\n, sum1 , sum2);}printf(\n);
}int main()
{tcasesolve();return 0;
}