骗分技巧之打表出省一

2023-10-19 06:59
文章标签 技巧 骗分 打表出

本文主要是介绍骗分技巧之打表出省一,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

目录

例题一

例题二 

例题一

P1044 [NOIP2003 普及组] 栈https://www.luogu.com.cn/problem/P1044当我们在考场上不知道卡特兰数,但我们可以骗分。

先写出以下代码:

#include<bits/stdc++.h>
using namespace std;
long long n, ans, now;
bool V[10];
void dfs(int stepu, int stepo) {if (stepu >= n and stepo >= n) {ans += (now == 0);return;}if (stepo > n or stepu > n) return;if (stepo < n and now) {now--;dfs(stepu, stepo + 1);now++;}if (stepu < n) {now++;dfs(stepu + 1, stepo);now--;}
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin >> n;dfs(0, 0);cout << ans << endl;return 0;
}

关注到题目里写着 n <= 18

必定超时,但我们可以打表

依次运行n=1~18的答案得到下表:

n答案
11
22
35
414
542
6132
7429
81430
94862
1016796
1158786
12208012
13742900
142674440
159694845
1635357670
17129644790
18477638700

得到打表程序:

#include<bits/stdc++.h>
using namespace std;
long long arr[] = {0, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700};
int main(){int n;cin >> n;cout << arr[n] << endl;return 0;
}

一提交发现:

例题二

[CSP-J 2022] 逻辑表达式[CSP-J 2022] 逻辑表达式icon-default.png?t=M85Bhttps://www.luogu.com.cn/problem/P8815?contestId=90215我考场上逻辑表达式的值会做,但后面的不会(谁叫我是XXS呢

但我也去打表了。

哈哈哈。

代码见下:

#include<bits/stdc++.h>
using namespace std;
string s;
int main() {freopen("expr.in","r",stdin);freopen("expr.out","w",stdout);cin >> s;if (s == "1") cout << "1\n0 0";else if(s == "0") cout << "0\n0 0";else if(s == "(1)") cout << "1\n0 0";else if(s == "(0)") cout << "0\n0 0";else if(s == "1&1") cout << "1\n0 0";else if(s == "1&0") cout << "0\n0 0";else if(s == "0&1") cout << "0\n1 0";else if(s == "0&0") cout << "0\n1 0";else if(s == "1|1") cout << "1\n0 1";else if(s == "1|0") cout << "1\n0 1";else if(s == "0|1") cout << "1\n0 0";else if(s == "0|0") cout << "0\n0 0";else if(s == "((1))") cout << "1\n0 0";else if(s == "((0))") cout << "0\n0 0";else if(s == "(1&1)") cout << "1\n0 0";else if(s == "(1&0)") cout << "0\n0 0";else if(s == "(0&1)") cout << "0\n1 0";else if(s == "(0&0)") cout << "0\n1 0";else if(s == "(1|1)") cout << "1\n0 1";else if(s == "(1|0)") cout << "1\n0 1";else if(s == "(0|1)") cout << "1\n0 0";else if(s == "(0|0)") cout << "0\n0 0";else if(s == "(1)&1") cout << "1\n0 0";else if(s == "(1)&0") cout << "0\n0 0";else if(s == "(0)&1") cout << "0\n1 0";else if(s == "(0)&0") cout << "0\n1 0";else if(s == "(1)|1") cout << "1\n0 1";else if(s == "(1)|0") cout << "1\n0 1";else if(s == "(0)|1") cout << "1\n0 0";else if(s == "(0)|0") cout << "0\n0 0";else if(s == "1&(1)") cout << "1\n0 0";else if(s == "1&(0)") cout << "0\n0 0";else if(s == "0&(1)") cout << "0\n1 0";else if(s == "0&(0)") cout << "0\n1 0";else if(s == "1|(1)") cout << "1\n0 1";else if(s == "1|(0)") cout << "1\n0 1";else if(s == "0|(1)") cout << "1\n0 0";else if(s == "0|(0)") cout << "0\n0 0";else if(s == "1&1|1") cout << "1\n0 1";else if(s == "1&1|0") cout << "1\n0 1";else if(s == "1&1&1") cout << "1\n0 0";else if(s == "1&1&0") cout << "0\n0 0";else if(s == "1&0|1") cout << "1\n0 0";else if(s == "1&0|0") cout << "0\n0 0";else if(s == "1&0&1") cout << "0\n1 0";else if(s == "1&0&0") cout << "0\n1 0";else if(s == "0&1|1") cout << "1\n1 0";else if(s == "0&1|0") cout << "0\n1 0";else if(s == "0&1&1") cout << "0\n2 0";else if(s == "0&1&0") cout << "0\n2 0";else if(s == "0&0|1") cout << "1\n1 0";else if(s == "0&0|0") cout << "0\n1 0";else if(s == "0&0&1") cout << "0\n2 0";else if(s == "0&0&0") cout << "0\n2 0";else if(s == "1|1|1") cout << "1\n0 1";else if(s == "1|1|0") cout << "1\n0 1";else if(s == "1|1&1") cout << "1\n0 1";else if(s == "1|1&0") cout << "1\n0 1";else if(s == "1|0|1") cout << "1\n0 1";else if(s == "1|0|0") cout << "1\n0 1";else if(s == "1|0&1") cout << "1\n1 1";else if(s == "1|0&0") cout << "1\n1 1";else if(s == "0|1|1") cout << "1\n0 1";else if(s == "0|1|0") cout << "1\n0 1";else if(s == "0|1&1") cout << "1\n0 0";else if(s == "0|1&0") cout << "0\n0 0";else if(s == "0|0|1") cout << "1\n0 0";else if(s == "0|0|0") cout << "0\n0 0";else if(s == "0|0&1") cout << "0\n1 0";else if(s == "0|0&0") cout << "0\n1 0";else if(s == "0&(1|0)|(1|1|1&0)") cout << "1\n1 2";else if(s == "(0|1&0|1|1|(1|1))&(0&1&(1|0)|0|1|0)&0") cout <<"0\n2 3";else if(s == "(((((1&(0&0|1))&(1|0|0)|1|(0&((0|(0|1)&1)|1|0))&((1|(1|1)&(1&0)&(1|1))|(1|0)|1)&((((((1|0)|0|0)&(1|((1&1&1)&(1|1))&0|0&0)|1)|1&0)&(0|0)|(0&(1|1))&1&(1|1)|0|1&0)&((0|1&0|1)&1)&(1|(1|0)&0))&(1&((1&0|1)|0&0)&((0|0)|0&0)|(1|((1|1)|1)&1&0)&1))|1|1)&((((((0&0)&(0|(0|1)|1&1)|0&0)|1)&(1|(1&0)&0))&(0|(0|0)|0)|(0|0)|0&1|((0&1|1)|0)&0)|((1|1|0&0)|(1&0&1)&(1&(1|0)|(0|1)&(1|0))|(((0&1)&0&1|(1&0)&0)|((0|1)|0)|1)|(1&1)&0)&(0&0)&(1|1))|((((0|0)|(0|0)|0)&0)&((0|(0|0)&0)|((1&(0|1&0)|1)|1)|0))&(1|0|1))|(0&((((1&0|1)&0&1|0|1)|1)|1)|((((((0&(0|0)|1)|1)|1|1)&(0|0)&1&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1&0&0|1&0)|(1|0)|(0|1)|1&1)&((0&0|1&0|(0|0)&1)|1)|(((0&1)&(1|0&1&1))&1)&(((1|(0|0)|1)|(0&1)&((1|1)|1|0))|(0|0|0)&1&0)|(1|1&1|0)&((1|1)&0)&((1&0|1)|0))&((0|1&(0&0|0&0))|(1|1)&0|1))&((0&1)&((0|0&1)|1&1&((0|(1&1)&0)&0&1)&1)|(0&1)&0)|(0|(0|0&0)&0)&(0&1|0)&(1|1))&((1|1)&1|(((0|0)|0&0)|((1&1|(1&0)&1)|0)|((0&0)&0)&0&1|1|1)|(1|0)&0&0)") cout << "1\n22 36";else {cout << rand()%2<<endl;long long a = 0,b = 0;for(int i = 0; i < s.size(); i++) {if(s[i] == '|') a++;if(s[i] == '&') b++;}cout << rand()%(b/2)<< ' ' <<  rand()%(a/2) << endl;}return 0;
}

我的帖子:T3这样能拿20分吗

这篇关于骗分技巧之打表出省一的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/238128

相关文章

Java中的雪花算法Snowflake解析与实践技巧

《Java中的雪花算法Snowflake解析与实践技巧》本文解析了雪花算法的原理、Java实现及生产实践,涵盖ID结构、位运算技巧、时钟回拨处理、WorkerId分配等关键点,并探讨了百度UidGen... 目录一、雪花算法核心原理1.1 算法起源1.2 ID结构详解1.3 核心特性二、Java实现解析2.

深度解析Python装饰器常见用法与进阶技巧

《深度解析Python装饰器常见用法与进阶技巧》Python装饰器(Decorator)是提升代码可读性与复用性的强大工具,本文将深入解析Python装饰器的原理,常见用法,进阶技巧与最佳实践,希望可... 目录装饰器的基本原理函数装饰器的常见用法带参数的装饰器类装饰器与方法装饰器装饰器的嵌套与组合进阶技巧

Go语言代码格式化的技巧分享

《Go语言代码格式化的技巧分享》在Go语言的开发过程中,代码格式化是一个看似细微却至关重要的环节,良好的代码格式化不仅能提升代码的可读性,还能促进团队协作,减少因代码风格差异引发的问题,Go在代码格式... 目录一、Go 语言代码格式化的重要性二、Go 语言代码格式化工具:gofmt 与 go fmt(一)

如何在Mac上彻底删除Edge账户? 手动卸载Edge浏览器并清理残留文件技巧

《如何在Mac上彻底删除Edge账户?手动卸载Edge浏览器并清理残留文件技巧》Mac上的Edge账户里存了不少网站密码和个人信息,结果同事一不小心打开了,简直尴尬到爆炸,想要卸载edge浏览器并清... 如果你遇到 Microsoft Edge 浏览器运行迟缓、频繁崩溃或网页加载异常等问题,可以尝试多种方

qt5cored.dll报错怎么解决? 电脑qt5cored.dll文件丢失修复技巧

《qt5cored.dll报错怎么解决?电脑qt5cored.dll文件丢失修复技巧》在进行软件安装或运行程序时,有时会遇到由于找不到qt5core.dll,无法继续执行代码,这个问题可能是由于该文... 遇到qt5cored.dll文件错误时,可能会导致基于 Qt 开发的应用程序无法正常运行或启动。这种错

mtu设置多少网速最快? 路由器MTU设置最佳网速的技巧

《mtu设置多少网速最快?路由器MTU设置最佳网速的技巧》mtu设置多少网速最快?想要通过设置路由器mtu获得最佳网速,该怎么设置呢?下面我们就来看看路由器MTU设置最佳网速的技巧... 答:1500 MTU值指的是在网络传输中数据包的最大值,合理的设置MTU 值可以让网络更快!mtu设置可以优化不同的网

MySQL JSON 查询中的对象与数组技巧及查询示例

《MySQLJSON查询中的对象与数组技巧及查询示例》MySQL中JSON对象和JSON数组查询的详细介绍及带有WHERE条件的查询示例,本文给大家介绍的非常详细,mysqljson查询示例相关知... 目录jsON 对象查询1. JSON_CONTAINS2. JSON_EXTRACT3. JSON_TA

Spring @RequestMapping 注解及使用技巧详解

《Spring@RequestMapping注解及使用技巧详解》@RequestMapping是SpringMVC中定义请求映射规则的核心注解,用于将HTTP请求映射到Controller处理方法... 目录一、核心作用二、关键参数说明三、快捷组合注解四、动态路径参数(@PathVariable)五、匹配请

如何确定哪些软件是Mac系统自带的? Mac系统内置应用查看技巧

《如何确定哪些软件是Mac系统自带的?Mac系统内置应用查看技巧》如何确定哪些软件是Mac系统自带的?mac系统中有很多自带的应用,想要看看哪些是系统自带,该怎么查看呢?下面我们就来看看Mac系统内... 在MAC电脑上,可以使用以下方法来确定哪些软件是系统自带的:1.应用程序文件夹打开应用程序文件夹

Mac备忘录怎么导出/备份和云同步? Mac备忘录使用技巧

《Mac备忘录怎么导出/备份和云同步?Mac备忘录使用技巧》备忘录作为iOS里简单而又不可或缺的一个系统应用,上手容易,可以满足我们日常生活中各种记录的需求,今天我们就来看看Mac备忘录的导出、... 「备忘录」是 MAC 上的一款常用应用,它可以帮助我们捕捉灵感、记录待办事项或保存重要信息。为了便于在不同