前言

T1传送门T2传送门T3传送门T4传送门T5传送门T6传送门

T6放弃,T4博客在这里

考场310的菜鸡瑟瑟发抖


洛谷 6101 [EER2]出言不逊

分析

设字符串长度为\(Len\)

每次显然我会挑长度最大的复制一倍,那么最大的复制一倍后还是最大的

设最大的长度为\(x\),那么显然要满足一个不等式

\(Len+\sum_{j=1}^{k}2^jx\geq L\)

\(k\)也就是答案,那不就是暴力吗

(唯一比较坑的就是\(\text{unsigned long long}\))


代码

#include <cstdio>
#include <cctype>
#define rr register
using namespace std;
int cnt[62],len,ans; unsigned long long L,big;
signed main(){
rr char c=getchar();
while (!isalnum(c)) c=getchar();
while (isalnum(c)){
if (isdigit(c)) ++cnt[c^48];
else if (islower(c)) ++cnt[c-87];
else ++cnt[c-29];
c=getchar(),++len;
}
scanf("%llu",&L);
for (rr int i=0;i<62;++i) big=big<cnt[i]?cnt[i]:big;
while (L>len){
++ans;
if (L<big) break;//变成负数会溢出
L-=big,big<<=1;
}
return !printf("%d",ans);
}

洛谷 6102 [EER2]谔运算

分析

考虑怎样能对答案产生贡献

首先位运算显然可以拆位算

可以统计\(cnt[x]\)表示二进制第\(x\)位为1的数的个数

\(\text{xor}\)为1当且仅当一个为0一个为1

那么分类讨论

若\(\text{or}=1,\text{and}=0\)

\(\text{or}\)考虑容斥,用总答案减去不合法的

\(n^2-(n-cnt_x)^2=(n*2-cnt_x)*cnt_x\)

\(\text{and}=0\),同样的道理

\(n^2-cnt_x^2=(n+cnt_x)*(n-cnt_x)\)

若\(\text{or}=0,\text{and}=1\)

\((n-cnt_x)^2+cnt_x^2\)

两种答案加起来,再拆开式子就是代码所示


代码

#include <cstdio>
#include <cctype>
#define rr register
using namespace std;
typedef unsigned uit;
uit n,cnt[32],ans;
inline uit iut(){
rr uit ans=0; rr char c=getchar();
while (!isdigit(c)) c=getchar();
while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
return ans;
}
signed main(){
n=iut();
for (rr uit i=1;i<=n;++i)
for (rr uit t=0,x=iut();x;x>>=1)
cnt[t++]+=x&1;
for (rr uit i=0,t=1;i<32;++i,t<<=1)
ans+=t*cnt[i]*(n-cnt[i])*2*(cnt[i]*n-cnt[i]*cnt[i]+n*n);
return !printf("%u",ans);
}

洛谷 6103 [EER2] 直接自然溢出啥事没有

分析

按照题意dp可以获零分的高分

为什么呢

考虑函数变成值有两种方式

所以要去重

但是不算哪个呢

当然是不算函数变成值啦

WA多次


代码

#include <cstdio>
#include <cctype>
#define rr register
using namespace std;
typedef unsigned long long ull;
ull f[10011][5],n;
signed main(){
scanf("%llu",&n);
f[0][0]=f[1][0]=f[1][2]=1;
for (rr int i=2;i<=n;++i){
f[i][1]=f[i-2][0];
f[i][2]=f[i][1]+f[i-1][4];
f[i][3]=f[i-2][3]+f[i-2][1]+(i>4)*f[i-4][1];
f[i][4]=f[i][3]+f[i-2][4];
for (rr int j=0;j<i;++j)
f[i][0]+=f[j][0]*f[i-j][2];
}
return !printf("%llu",f[n][0]);
}

洛谷 6105 [Ynoi2010] iepsmCmq

分析

分类讨论,如果\(C<i+j<2C\),显然只需要取最大值和次大值加起来

否则\(0<i+j<C\)那么用一个\(\text{STL::multiset}\)

特别注意找到的答案需要判断与之前的配对答案关系


代码

#include <cstdio>
#include <cctype>
#include <set>
#define rr register
using namespace std;
int mod,tot,Q; multiset<int>uk,S;
multiset<int>::iterator it;
inline signed iut(){
rr int ans=0,f=1; rr char c=getchar();
while (!isdigit(c)) f=(c=='-')?-f:f,c=getchar();
while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
return ans*f;
}
inline void print(int ans){
if (ans>9) print(ans/10);
putchar(ans%10+48);
}
inline signed max(int a,int b){return a>b?a:b;}
inline signed Get(int x,bool nx){
if (x==-1) return -1;
it=uk.lower_bound(mod-x);
if (it==uk.begin()) return -1; --it;
if (nx&&*it==x&&uk.count(x)==1)
return it==uk.begin()?-1:*--it;
else return *it;
}
inline void Add(int x){
if (++tot==1) {uk.insert(x); return;}
rr int fi=Get(x,0),se=Get(fi,1),th=Get(se,1);
if (fi!=-1&&se<x){
if (se!=-1&&fi==th) S.erase(S.find(fi+se));
S.insert(x+fi);
}
uk.insert(x);
}
inline void Del(int x){
uk.erase(uk.find(x)),--tot;
if (!tot) return;
rr int fi=Get(x,0),se=Get(fi,1),th=Get(se,1);
if (fi!=-1&&se<x){
if (se!=-1&&fi==th) S.insert(fi+se);
S.erase(S.find(x+fi));
}
}
inline signed query(){
rr int ans=S.empty()?0:(*--S.end());
it=--uk.end();
if (uk.count(*it)>1) ans=max(ans,*it*2%mod);
else {
rr int t=*it; --it;
ans=max(ans,(*it+t)%mod);
}
return ans;
}
signed main(){
Q=iut(),mod=iut();
for (rr int opt,x,lans=0;Q;putchar(10),--Q){
opt=iut(),x=(iut()^lans)%mod;
if (opt==1) Add(x); else Del(x);
if (tot>1) print(lans=query());
else putchar(69),putchar(69),lans=0;
}
return 0;
}

【LGR-069】洛谷 2 月月赛 II & EE Round 2的更多相关文章

  1. 【LGR-061】洛谷10月月赛 II & X Round 4 Div.1&Div 2

    X Round的题目质量还是一如既往的高 然而每次周末我都要写作业没法用心打233主要是被陈指导放了鸽子 占坑代填(最近坑开的有点多)

  2. 【CSGRound2】逐梦者的初心(洛谷11月月赛 II & CSG Round 2 T3)

    题目描述# 给你一个长度为\(n\)的字符串\(S\). 有\(m\)个操作,保证\(m≤n\). 你还有一个字符串\(T\),刚开始为空. 共有两种操作. 第一种操作: 在字符串\(T\)的末尾加上 ...

  3. 【LGR-054】洛谷10月月赛II

    [LGR-054]洛谷10月月赛II luogu 成功咕掉Codeforces Round #517的后果就是,我\(\mbox{T4}\)依旧没有写出来.\(\mbox{GG}\) . 浏览器 \( ...

  4. 洛谷10月月赛II题解

    [咻咻咻] (https://www.luogu.org/contestnew/show/11616) 令人窒息的洛谷月赛,即将参加NOIp的我竟然只会一道题(也可以说一道也不会),最终145的我只能 ...

  5. 【LGR-052】洛谷9月月赛II(加赛)

    题解: 没打... ab题满世界都过了应该没什么意思 c题是个比较有意思的思维题(先看了题解才会的...) 我们考虑这么一件事情 没钥匙的人出门后 门一定是开着的 他进来的时候,门一定是开着的 其他时 ...

  6. 洛谷9月月赛II 赛后瞎写

    看错比赛时间了....结果发现的时候已经开始了半个小时,并且当时正准备睡午觉qwq 于是就水了个t1就 去睡 跑了 T2 写着写着然后看了一发评讲被辣鸡思路给绕了进去最后发现自己宛若一个智障 类似桶的 ...

  7. 洛谷 4933 洛谷10月月赛II T2 大师

    [题解] f[i][j]表示最后一个数为h[i],公差为j的等差数列的个数.n方枚举最后一个数和倒数第二个数转移即可.注意公差可能为负数,需要移动为正数再作为下标. #include<cstdi ...

  8. 洛谷 4932 洛谷10月月赛II T1 浏览器

    [题解] x xor y的结果在二进制下有奇数个1,等价于x与y在二进制下的1的个数之和为奇数,因为x xor y减少的1的个数一定是偶数(两个数这一位都为1,xor的结果为0,减少了2个1) 那么答 ...

  9. 洛谷10月月赛II

    #A: P4924 [1007]魔法少女小Scarlet 这道题考了矩阵旋转 其实很考验推公式的能力和代码能力 这里有个小技巧 可以设(x, y)为原点,然后去推公式,然后实际操作中横坐标加上x,纵坐 ...

  10. [LGR-054]洛谷10月月赛II

    浏览器 结论popcnt(x^y)和popcnt(x)+popcnt(y)的奇偶性相同. 然后就是popcnt为奇数的乘为偶数的.预处理一下\(2^{16}\)次方以内的popcnt,直接\(O(1) ...

随机推荐

  1. flutter——android报错Manifest merger failed : Attribute application@allowBackup value=(false)

    与这个https://www.cnblogs.com/MaiJiangDou/p/13848658.html 报错类似. 报错: Manifest merger failed : Attribute ...

  2. HTML学习---day01

    1.head标签 <!DOCTYPE html> <!--文档声明H5 html--> <html lang="en"> <head> ...

  3. MongoDB的安装及启动

    下载地址 https://www.mongodb.com/try/download/community 安装步骤 自定义安装目录 配置环境 下面是你安装后的mongodb的目录 在电脑的环境变量Pat ...

  4. 在写dockerfile时替换国内源

    众所周知,Debian是linux发行版中官方源最难用的一个,这个傻逼源让我再构建docker镜像时卡了很久. ​ 那么能不能替换构建dockerfile时使用的源呢?显然是可以的 ​ 在与Docke ...

  5. C++异常的基本概念与用法

    //异常的概念/*抛出异常后必须要捕获,否则终止程序(到最外层后会交给main管理,main的行为就是终止) try{}内写可能会抛出异常的代码.catch(类型){处理} 写异常类型和异常处理 抛出 ...

  6. C++ auto与循环

    C++ auto与循环 C++ auto 的介绍 typeid(p).name();可以输出auto的类型 auto 是 C++11 引入的一个关键字,用于自动类型推导.编译器会根据初始化表达式的类型 ...

  7. Java 小练习(2) 利用面向对象的编程方法 设计类Circle计算圆的面积

    1 package com.bytezero.exer; 2 /*** 3 * 4 * @Description 5 * @author Bytezero·zhenglei! Email:420498 ...

  8. 2022年RPA行业发展十大趋势,六千字长文助你看懂RPA

    2022年RPA行业发展十大趋势,六千字长文助你看懂RPA 2022年RPA行业如何发展?十大趋势助你看懂RPA行业未来 这里有2022年RPA行业发展的十大趋势,关注RPA的朋友定要收藏! 文/王吉 ...

  9. Swoft - Bean

    一.Bean 在 Swoft 中,一个 Bean 就是一个类的一个对象实例. 它(Bean)是通过容器来存放和管理整个生命周期的. 最直观的感受就是省去了频繁new的过程,节省了资源的开销. 二.Be ...

  10. window.open代理劫持

    window.open = new Proxy(window.open, { apply(target, ctx, args) { if (hasAuth(args[0])) { return tar ...