心路历程

辣鸡T3卡我1.5h题意,要不是最后nlh跟我解释了一下大样例估计这次是真凉透了。。

A P4994 终于结束的起点

打出暴力来发现跑的过最大数据??

保险起见还是去oeis了一波,然后被告知第一个满足条件的位置不会超过\(2n +2\)

赢了

#include<bits/stdc++.h>
#define Pair pair<int, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
const int MAXN = 1e7 + 10;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int f[MAXN] = {0, 1};
int main() {
int M = read();
for(int i = 2; i; i++) {
f[i] = (f[i - 1] + f[i - 2]) % M;
if(f[i - 1] == 0 && f[i] == 1) {printf("%d\n", i - 1); break;}
}
return 0;
}

B P4995 跳跳!

为啥\(n \leqslant 300\)啊。。出题人这么放烟雾弹真的好么。。。

直接排序之后每次在没跳过的最大的和没跳过的最小的之间跳

开始的时候跳的最大的

#include<bits/stdc++.h>
#define Pair pair<int, int>
#define MP make_pair
#define fi first
#define se second
#define LL long long
using namespace std;
const int MAXN = 1e6 + 10;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N;
LL a[MAXN];
int main() {
N = read();
for(int i = 1; i <= N; i++) a[i] = read();
sort(a + 1, a + N + 1, greater<int>());
LL ans = a[1] * a[1], l = 1, r = N, opt = 0;
for(int i = 1; i <= N - 1; i++, opt ^= 1) {
ans += abs((a[l] - a[r]) * (a[l] - a[r]));
if(!opt) l++;
else r--;
}
cout << ans;
return 0;
}

B P4996 咕咕咕

看不懂题其实也不能完全怪出题人吧。。还是自己太菜了。。

直接爆搜+记忆化就能骗到\(40\)分(莫名奇妙wa掉两个点)

交上去的时候已经\(11:47\)了。。吃饭的时候发现可以把\(1\)的个数相同的数一起算,他们的系数都是一样的。

然后就做完了。。

时间复杂度:\(O(2^n)\)

好像可以直接用组合数算系数?

#include<cstdio>
#include<map>
#include<iostream>
#define Pair pair<int, int>
#define MP make_pair
#define fi first
#define se second
#define LL long long
using namespace std;
const int MAXN = 3e6 + 10, mod = 998244353;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, M, Lim, ans, ou[MAXN], in[MAXN];
int mp[1 << 22];
void add(int &x, int y) {
if(x + y < 0) x = x + y;
else x = (x + y >= mod ? x + y - mod : x + y);
}
int mul(int x, int y) {
return 1ll * x * y % mod;
}
int trans(string x) {
int ou = 0;
for(int k = 0; k < N; k++) if(x[k] == '1') ou |= 1 << k;
return ou;
}
int g(int x) {
return __builtin_popcount(x);
}
int dfs(int sta) {
if(ou[g(sta)]) return ou[g(sta)];
for(int i = sta + 1; i <= Lim; i++)
if((i & sta) == sta) add(ou[g(sta)], dfs(i));
return ou[g(sta)];
}
int dfs2(int sta) {
if(in[g(sta)]) return in[g(sta)];
for(int i = 0; i < sta; i++)
if((i & sta) == i) add(in[g(sta)], dfs2(i));
return in[g(sta)];
}
int main() {
N = read(); M = read(); Lim = (1 << N) - 1;
for(int i = 1; i <= M; i++) {
string s; int val;
cin >> s; val = read() % mod;
mp[trans(s)] = val;
}
in[0] = 1; ou[g(Lim)] = 1;
dfs(0); dfs2(Lim);
for(int i = 0; i <= Lim; i++) add(ans, mul(mp[i], mul(ou[g(i)], in[g(i)])));
cout << ans;
}

D

没时间写暴力了。

puts("-1 -1")骗了10分。。

洛谷11月月赛题解(A-C)的更多相关文章

  1. 「P4996」「洛谷11月月赛」 咕咕咕(数论

    题目描述 小 F 是一个能鸽善鹉的同学,他经常把事情拖到最后一天才去做,导致他的某些日子总是非常匆忙. 比如,时间回溯到了 2018 年 11 月 3 日.小 F 望着自己的任务清单: 看 iG 夺冠 ...

  2. 「P4994」「洛谷11月月赛」 终于结束的起点(枚举

    题目背景 终于结束的起点终于写下句点终于我们告别终于我们又回到原点…… 一个个 OIer 的竞赛生涯总是从一场 NOIp 开始,大多也在一场 NOIp 中结束,好似一次次轮回在不断上演.如果这次 NO ...

  3. 「LuoguP4995」「洛谷11月月赛」 跳跳!(贪心

    题目描述 你是一只小跳蛙,你特别擅长在各种地方跳来跳去. 这一天,你和朋友小 F 一起出去玩耍的时候,遇到了一堆高矮不同的石头,其中第 ii 块的石头高度为 h_ihi​,地面的高度是 h_0 = 0 ...

  4. 洛谷11月月赛(284pts rank85)

    https://www.luogu.org/contestnew/show/12006 我是比赛完后在去写的 这是我第一次打洛谷月赛,之前一次是比赛完才去看而且写了第一题就没写后面的了 284分,太水 ...

  5. 洛谷 11 月月赛 I Div.2 A [Kubic] Addition 题解

    Content 你有一个长度为 \(n\) 的序列 \(a\).你可以执行 \(n-1\) 次操作,每次操作中你可以选择一个位置 \(i\),并删除 \(a_i\) 和 \(a_{i+1}\),再在原 ...

  6. 洛谷11月月赛round.1

    太感动了#2 thwfhk 240 (801ms) 100 100 40   又一张明信片,话说10月的怎么还没收到   P2246 SAC#1 - Hello World(升级版) 题目背景 一天, ...

  7. 洛谷11月月赛round.2

    P3414 SAC#1 - 组合数 题目背景 本题由世界上最蒟蒻最辣鸡最撒比的SOL提供. 寂月城网站是完美信息教室的官网.地址:http://191.101.11.174/mgzd . 题目描述 辣 ...

  8. NOIP模拟赛(洛谷11月月赛)

    T1  终于结束的起点 题解:枚举啊... 斐波那契数 第46个爆int,第92个爆long long.... 发现结果一般是m的几倍左右....不用担心T. #include<iostream ...

  9. 【LGR-065】洛谷11月月赛 III Div.2

    临近$CSP$...... 下午打了一发月赛,感觉很爽. 非常菜的我只做了前两题......然而听说前两题人均过...... 写法不优秀被卡到$#1067$...... T1:基础字符串练习题: 前缀 ...

随机推荐

  1. php 返回数组中指定多列的方法

    php array_column 方法可以返回数组中指定的一列,但不能返回多列,本文将介绍array_column方法的使用,并用代码演示返回数组中指定多列的方法. 1.array_column说明 ...

  2. js 的常用方法和对象

    每日分享: 加油!你一定可以!你是最牛逼的!!!-------------------------------------------------------------------------- - ...

  3. 04. prosition 的值都有哪些,其最本质的区别在哪里?

    4.prosition 的值都有哪些,其最本质的区别在哪里? position:relative 相对定位 position:fixed 相对浏览器定位 position:absolute 绝对定位 ...

  4. python全栈开发学习_day1_计算机五大组成部分及操作系统

    一.计算机五大组成部分: 1)五大组成: 1.控制器(指挥系统,用于控制其他计算机硬件的工作) 2.运算器(用于数学运算及逻辑运算) 3.存储器(寄存器,高速缓存,内存,磁盘(机械,固态),磁带) 4 ...

  5. koa的中间件compose

    用到的知识点: 1.bind函数 2.函数递归调用自身 3.promise 'use strict' /** * Expose compositor. */ module.exports = comp ...

  6. Monkey基本使用(转载)

    什么是 Monkey Monkey 是一个 Android 自动化测试小工具.主要用于Android 的压力测试, 主要目的就是为了测试app 是否会Crash. Monkey 特点 顾名思义,Mon ...

  7. vue 2.0创建新项目

    参考链接  https://segmentfault.com/a/1190000011275993 背景在安装完node的基础上,机器什么都没安装参考上述链接 一.下载vue $ cnpm insta ...

  8. How do I use screen on the Linux systems?

    Scope The screen utility provides a way to run a command on a Linux system, detach from it, and then ...

  9. 使用express、react、webpack打包、socket.io、mongodb、ant.design、less、es6实现聊天室

    拿到一个项目,我们应该如何去完成这个项目呢. 是直接上手? 还是先进行分析,然后再去解决呢?毫无疑问,如果直接上手解决,那么可能会因为知道目标所在,而导致出现各种问题. 所以,我们应该系统的分析这个项 ...

  10. web测试工具总结

     纯粹的手工测试早已不满足如今的项目需求,各种测试工具的应用早已成为普遍趋势.如何选取合适的工具来完成对应的测试工作?本文将针对Web测试,列举 一些推荐的测试工具,并加以简单介绍. (每个工具的实际 ...