心路历程

辣鸡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分。。

最新文章

  1. 使用PowerShell来修改文件访问,创建,修改时间属性
  2. gRPC+etcd的优势分析
  3. ASPNET_MVC学习中的疑问
  4. python文件I/O(转)
  5. Ajax在调用含有SoapHeader的webservice方法
  6. datepicker自定义 -- iOS
  7. ThreadLocal的设计与使用(原理篇)
  8. 面向连接的Socket Server的简单实现(简明易懂)
  9. Android桌面悬浮清内存app概述
  10. BZOJ 1032 [JSOI2007]祖码Zuma
  11. Java输出当前的日期(年月日时分秒毫秒)
  12. Hyperledger Fabric 1.0 从零开始(七)——启动Fabric多节点集群
  13. Java8 按照类属性去重
  14. Doctype的作用?严格模式与混合模式,如何触发者这两种模式,区分它们有何意义?
  15. wsl 子系统 用户目录位置
  16. 9. http协议_响应状态码_页面渲染流程_路由_中间件
  17. 【18/12/31】hashcat源码粗读 --- sha256部分
  18. logstash常用插件解析
  19. 从注册表清理 IE10,IE11 用户代理字符串(UserAgent)中的垃圾信息
  20. day 019 常用模块

热门文章

  1. miniui中表单验证规则总结
  2. c++11 enable_shared_from_this
  3. sap server笔记
  4. 主流服务器虚拟化技术简单使用——Hyper-V(一)
  5. EntityFrameworkCore 数据库生成与迁移
  6. diff与patch
  7. 微信小程序回到顶部的两种方式
  8. vue html页面打印功能vue-print
  9. 07-oracle多表查询
  10. (转)shell变量及扩展