当前位置: 首页 > news >正文

CF2111B 学习笔记

正如题目名所说,这真的是一个斐波那契数列题。

题意

题目已经说得很清楚了,我就不说了。

唯一要注意的点是

\[f_1=1,f_2=2 \]

不要像我一样因为弄成

\[f_1=1,f_2=1 \]

而调了整整半小时!

思路

注意到

\[f_{n-2}=f_n-f_{n-1}, \]

所以边长为 \(f_{n-2}\) 的正方体可以放进 \(f_n\)\(f_{n-1}\) 的缝隙中,依此类推,所以只用考虑 \(f_{n-1}\)\(f_{n-2}\) 能否放得下就可以了。

代码

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iterator>
#include <map>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
#include <set>
#include <bitset>
#include <unordered_set>
#include <vector>
#include <deque>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <list>
#include <array>
#include <iterator>
#include <cmath>
#include <new>
#include <random>
#include <cfloat>
#include <cstdlib>
#include <climits>
#include <numeric>
#include <complex>
#include <ctime>
#include <chrono>
#include <thread>
#include <mutex>
#include <future>
#include <exception>
#include <stdexcept>
#include <cstdint>
#include <cassert>
#include <stack>
#include <cctype> // 一大坨头文件
#define Ofile(s) freopen(s".in", "r", stdin), freopen (s".out", "w", stdout)
#define Cfile(s) fclose(stdin), fclose(stdout)
#define mod 998244353
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ciin cin
#define ccout cout
#define iint int
#define init int
#define intt int
#define endll endl // 防手滑
#define maxn 25
using namespace std;int t, n, m, l, w, h;
int f[maxn];int main() {
#ifndef ONLINE_JUDGE
//	Ofile("");
//	Cfile("");
#endiffast;f[1] = 1;f[2] = 2; // 小坑点for (init i = 3; i <= 20; i++)f[i] = f[i - 1] + f[i - 2];cin >> t;while (t--) {cin >> n >> m;while (m--) {cin >> w >> l >> h;if (f[n] > w || f[n] > l || f[n] > h)cout << 0;else if (f[n + 1] <= w || f[n + 1] <= l || f[n + 1] <= h)cout << 1;else cout << 0;}cout << endll; // 多测记得换行}return 0;
}

通过记录

http://www.jsqmd.com/news/333965/

相关文章:

  • 2026最新BI工具服务商top5推荐!国内优质智能分析企业权威榜单发布,数智赋能助力企业高效决策 - 品牌推荐2026
  • 目前深圳腾讯代理商哪家好? - 服务品牌热点
  • Apache Beam实战冲刺:Beam如何run everywhere?
  • 【重磅】可靠的朋友圈广告排行榜单 - 服务品牌热点
  • 阿里云《PolarDB AI 实践全景:加速企业大模型应用落地》电子书重磅上线!
  • 2026灵芝孢子粉哪家产品好?真实用户口碑推荐 - 品牌排行榜
  • 【JS类型转换符】字符串转布尔值的真实应用
  • 口碑好的深圳小红书广告代理哪家强? - 服务品牌热点
  • WordCount Beam Pipeline实战
  • 实测封神|涡街/涡轮/电磁流量计哪家好?头部厂家实力对比,靠谱供应商闭眼冲 - 品牌推荐大师1
  • 学长亲荐 9 个降AI率网站,千笔助你轻松降AIGC
  • 多模态RAG系统进阶:从零掌握olmOCR与MinerU的部署与应用
  • 救命神器!千笔ai写作,最受欢迎的AI论文工具
  • <span class=“js_title_inner“>李飞飞世界模型公司一年估值暴涨5倍!正洽谈新一轮5亿美元融资</span>
  • Excel隐藏神器EVALUATE:比INDIRECT更强大的公式执行引擎
  • 07. 信号源讲解(七)---VPWL_FILE、IPWL_FILE篇 I PSpice高级应用
  • 2026年中频点焊机厂家推荐:银触点点焊机 /凸焊机 /点焊机 /铜点焊机厂家精选 - 品牌推荐官
  • 【论文自动阅读】ReWorld:具身世界模型的多维度奖励建模
  • <span class=“js_title_inner“>AI交警已上线,3分钟通行五个路口!</span>
  • 【论文自动阅读】未来光流预测提升机器人控制与视频生成
  • SSM银行管理系统275d1(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
  • <span class=“js_title_inner“>限时免费!快来百度智能云一键部署OpenClaw</span>
  • 2026最新BI工具服务商top3推荐!国内优质智能分析企业权威榜单发布,数智赋能助力企业高效决策 - 品牌推荐2026
  • 图吧工具箱最新绿色版,内置上百种硬件检测工具
  • fastapi异步处理模板
  • 【深度学习实战】基于YOLO11的水稻病虫害智能检测系统_1
  • <span class=“js_title_inner“>忽如一夜春风来丨2024年总结</span>
  • 【网络安全】ip获取伪造与隐藏挖掘_ip伪造
  • 企业需要这位AI生产力总监而非首席AI官
  • 依据安卓包名查应用名称