前言

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. 搜索引擎RAG召回效果评测MTEB介绍与使用入门

    RAG 评测数据集建设尚处于初期阶段,缺乏针对特定领域和场景的专业数据集.市面上常见的 MS-Marco 和 BEIR 数据集覆盖范围有限,且在实际使用场景中效果可能与评测表现不符.目前最权威的检索榜 ...

  2. SyntaxError: invalid property id(就是不支持ES6) (浏览器不支持对象...展开)

    SyntaxError: invalid property id(就是不支持ES6) (浏览器不支持对象...展开) 火狐55以后支持

  3. [好文推荐] 如何保护价值上千万的Node.js源代码? - 主要是ncc

    如何保护价值上千万的Node.js源代码? https://zhuanlan.zhihu.com/p/84386456 一个强大的JS混淆器. github.com/javascript-obfusc ...

  4. 跨域测试代码 - console 里面直接就可以测试

    跨域测试代码 - console 里面直接就可以测试 var xhr = new XMLHttpRequest(); xhr.open("GET", "https://w ...

  5. vue peek 解决了 vue-template 加载 相对目录 ./components 组件内容 vscode

    点击组件跳转,vue-helper 带@的能跳转,相对目录的不能跳转.vue peek 解决了这个问题.

  6. 一个简单的HTTP服务器的实现

    我们继续我们的HTTP服务器的实现(使用别的代码来实现), 这个HTTP服务器的实现,我们主要就是关注TCP服务器中的recv还有send的处理. 首先,看一下HTTP,我们在用浏览器访问我们的TCP ...

  7. 关于easyExcel导出文字合并居中和服务器导出失败踩了一天的坑

    参考:https://blog.csdn.net/hanyi_/article/details/118117484,https://blog.csdn.net/sunyuhua_keyboard/ar ...

  8. Performance Improvements in .NET 8 -- Native AOT & VM & GC & Mono【翻译】

    原生 AOT 原生 AOT 在 .NET 7 中发布.它使 .NET 程序在构建时被编译成一个完全由原生代码组成的自包含可执行文件或库:在执行时不需要 JIT 来编译任何东西,实际上,编译的程序中没有 ...

  9. 【牛客小白月赛51 F平均题】数论,前缀和

    import java.io.IOException; import java.util.Scanner; public class Main { static int MOD = 100000000 ...

  10. Android 开发Day5

    展示项目 这是我的项目结构,补录的