Fibonacci again and again HDU - 1848

基于GEC6818开发板的C/C++贪吃蛇小游戏 f.开始游戏(进入游戏,并没有马上开游戏,需要点击播放才能开始)2.相关宏,全局变量(可以根据自己需要进行修改)k.显示文字前的相关初始化。k.自定义font.h文件。1.需要的主要头文件。l.在开发板上显示字1。m.在开发板上显示字2。a.显示固定大小图片。h.线程1:获得坐标。 阅读详情

需要理解SG函数,自行百度。(至今证明还没有完全看懂)

结论: 

公平组合游戏(ICG),都符合 :多个游戏的结果=各子游戏的异或和。

sg【i】=mex(sg【j】| j为i的后继(比如现在是5个苹果,每次只能拿2个,那么3个苹果就是5个苹果的后继))

//简单来讲就sg【i】是当前后继集合中最小的非负整数

那么这道题我们可以预处理sg【i】的值,最后把sg[n]^sg[m]^sg[p]就能知道结果(因为有结论多个游戏的结果=各子游戏的异或和)

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>  
#include <iostream>  
#include <cstdlib>  
#include <cstring>  
#include <string>
#include <cstdio>  
#include <climits>
#include <cmath> 
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <sstream>
#define INF 0x3f3f3f3f
#define LL long long
#define fora(i,a,n) for(int i=a;i<=n;i++)
#define fors(i,n,a) for(int i=n;i>=a;i--)
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define MAXN 100024
const double eps = 1e-8;
using namespace std;
int m,n,p;
int sg[1024];
int f[20];
int Hash[1024];
void work(){
	for(int i=0;i<=1000;i++){
		memset(Hash,0,sizeof(Hash));
		for(int j=0;f[j]<=i;j++){
			Hash[sg[i-f[j]]]=1;

		}
		for(int j=0;j<1000;j++)
			if(Hash[j]==0){
				sg[i]=j;break;
			}
	}
}
int main() {
#ifdef DID
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
	f[0]=1;
	f[1]=2;
	for(int i=2;i<=16;i++)
		f[i]=f[i-1]+f[i-2];
	work();
	
	while(scanf("%d%d%d",&m,&n,&p)==3&&(n||m||p)){
		int ans=sg[m]^sg[n]^sg[p];
		ans?printf("Fibo\n"):printf("Nacci\n");
	}
	return 0;
}


智能能效管家:基于 ESP32 的智能插座设计与精细化功耗管理实现 针对传统插座无法远程控制、功耗监测缺失、能源浪费严重等问题,本文设计一款基于 ESP32 主控芯片的智能插座。该系统集成 WiFi 无线通信、交流功耗采集、继电器通断控制模块,实现四大核心功能。硬件采用模块化选型与安全接线设计,软件基于 Arduino-ESP32 框架开发,搭载 Mqtt 通信协议与功耗算法,可通过手机 / 云端实时管控设备,有效提升用电安全性与能源利用率。:ESP32;智能插座;功耗管理;远程控制;能耗监测。 阅读详情

相关推荐

提示deepseek生成完整的json用于对接外部API

通过精准的提示词设计(字段过滤、格式约束)、动态验证机制(自检与修正)和官方模板参考,可有效确保DeepSeek生成的JSON纯净无冗余。

神棍之路 2308

hdu 1848 Fibonacci again and again

Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2963    Accepted Submission(s): 1205 Problem Description

WEYuLi的专栏 1038

深入解析高通Adreno DPU的DRM/KMS驱动架构与硬件协同设计

本文深入解析了高通Adreno DPU的DRM/KMS驱动架构与硬件协同设计,详细介绍了Adreno DPU的核心模块组成、显示接口设计以及DRM驱动架构。通过实际案例和调试技巧,帮助开发者理解硬件与软件的协同工作原理,优化显示性能并解决常见问题。

weixin_29266679的博客 437

HDU 1848 Fibonacci again and again(SG函数的应用)

原题:http://acm.hdu.edu.cn/showproblem.php?pid=1848

风尘_浪子 1016

避开封号风险!wxauto+Claude API实现微信智能客服的合规方案

本文详细介绍了如何利用wxauto和Claude API构建合规的微信智能客服系统,避免封号风险。通过技术选型对比、防封策略设计及大模型接入实践,为企业提供了一套安全高效的解决方案,特别适合中小企业在微信生态中部署AI客服。

sql99的博客 446

数字孪生实战:如何用Unity3D为工厂设备快速搭建可视化孪生体(附GitHub源码)

本文详细介绍了如何利用Unity3D游戏引擎为工厂设备快速构建可视化数字孪生体。通过实战案例,阐述了从3D模型导入、MQTT实时数据接入,到振动、温度等关键参数可视化呈现的完整流程。文章旨在为智能制造和工业物联网开发者提供一套灵活、低成本的技术方案,并附有完整的GitHub源码,助力实现设备状态的直观监控与预测性维护。

weixin_29184075的博客 473

Fibonacci again and again(HDU 1848)经典组合博弈&SG不连续整数

#include <bits/stdc++.h> using namespace std; #define max(a, b) ((a) > (b) ? (a) : (b)) const int MAXN = 1005; int sg[MAXN],f[MAXN],ind; bool flag[MAXN]; void getsg(int n) { memset(sg,0, sizeof(sg)); for(int i=1;i<=n;i++) {

征服所有不服的博客 276

用rsl_rl训练四足机器人走梅花桩:PPO算法调参实战与避坑指南

本文详细介绍了如何使用rsl_rl框架和PPO算法训练四足机器人在梅花桩上行走的实战经验。通过分析梅花桩场景的独特挑战,提供PPO算法关键参数配置策略、奖励函数设计方法以及常见问题的解决方案,帮助开发者高效实现机器人平衡控制。文章特别强调了仿真到实机的过渡技巧,最终实现98%的过桩成功率。

weixin_29103191的博客 221

hdu 1848Fibonacci again and again

博弈论,SG函数最后就行nim就行 #include &lt;bits/stdc++.h&gt; #define maxn 1005 typedef long long ll; using namespace std; ll f[maxn]; ll s[maxn]; ll SG[maxn]; void sg(int n) { for(int i = 1; i &lt;= n...

WINDZLY的博客 324

详解Nacos集群搭建

在我们日常的开发当中,用的都是单点Nacos,这种模式,我们自己开发测试玩一玩还可以,但是到了企业的生产环境之下,你还这么玩的话,那肯定是要出大问题了。因为在企业当中,我们更加强调的是高可用,所以在企业的生产环境下,Nacos一定要做成个集群。

博客 1万+

Smali语言基础语法

定义、声明、调用 Smali数据类型 定义:与Java相同,Smali中也有一套数据类型体系,且该体系实质上是同Java一一对照的。 示例1:Smali——Java数据类型对照表 PS:如上图所示,Smali语言中的数据类型的关键词基本上为Java中同名数据类型的首字母大写,需要着重记忆的例外为:1.long类型的关键词为大写J;2.boolean类型的关键词为大写Z;3.数组的关键词为左半边中括号[;4.object类型(各种类)的关键词为大写L加上该类的全类名路径,路径中的层级用/分割。

aketoshknight的博客 1万+

D - Fibonacci again and again HDU - 1848(Nim+ sg)

一、知识点 Nim博弈 + sg 二、随便说 蒟蒻的我,在打比赛时接触了sg题, 所以就来死嗑sg题。 这个题可以说是sg的模板题 只要搞懂了Nim博弈 的异或原理。 在学一下sg就行了。 我个人理解只要,一个博弈游戏, 可以分为 独立的子游戏就可以用Nim博弈, 如果Nim博弈实在无法解决就加上sg函数。 思路 该题可以说是Nim博弈取石子的进化版。 ①大体流程: 因为可...

T.J的博客 265

试读源码在这里下载

试读文章的源码在这里下载。源码不做任何修改,重点重点重点:为了代码运行不报错,安装matlab 版本为 2021 及以上版本。matlab安装教程大家可以参考这个教程:手把手教你安装matlab软件。

在职AI算法工程师,擅长计算机视觉,YOLO目标检测、分割等,擅长web、pyqt界面可视化,好内容持续更新中,来这里跟大家一起学习,共同进步 4302

hdu1848Fibonacci again and again

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1848 题意:中文题。 分析:基础的SG函数的应用。 代码: #include #include #include #include #include #include #include #include #include #include #include #include #pragma com

Fsss 406

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Fibonacci again and again HDU - 1848

https://cn.vjudge.net/problem/HDU-1848 SG函数: 首先定义mex(minimal excludant)运算,这是施加于一个集合的运算,表示最小的不属于这个集合的非负整数。例如mex{0,1,2,4}=3、mex{2,3,5}=0、mex{}=0。 SG 定理:游戏的和的 SG 值是各个子游戏的 SG 值的 xor。 对于任意状态 x , 定义 SG...

newhonor 187

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

HDU1848-Fibonacci again and again

题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1848 这个题目代码不是很复杂,但那个等价类,(SG函数)没怎么理解, 题目难,不过代码不怎么复杂,在网上找了一些解释, 博弈题,一开始好难理解。还是用到了那个定理 对于nim游戏的某个位置(x1,x2,x3),当且仅当它各部分的nim-sum等于0时(即x1⊕x2⊕x3=0),则当前位...

weixin_30892037的博客 179

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

HDU 1848 Fibonacci again and again

Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;F(n)=F(n-1)+F(n-2)(n>=3);所以,1,2,3,5,8,13……就是菲波那契数列。在HDOJ上有不少相关的题目,比如1005 Fibonacci again就是曾经的浙江省赛题。今天,又一个关于Fibona...

weixin_30455067的博客 75

HDU 1848 Fibonacci again and again【博弈SG】

Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的: F(1)=1; F(2)=2; F(n)=F(n-1)+F(n-2)(n>=3); 所以,1,2,3,5,8,13……就是菲波那契数列。 在HDOJ上有不少相关的题目,比如1005 Fibonacci again就是曾经的浙江省赛题。 今天,又一个关于...

NoobPlayer_llke的博客 212

【hdu 1848】Fibonacci again and again

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8194 Accepted Submission(s): 3410 Problem Description 任何一个大学生对菲波那契数列(Fibona...

AWCXV 78

hdu1848 Fibonacci again and again

Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3622 Accepted Submission(s): 1500 Problem Description 任何一个大学生对菲波

习惯与规则决定命运 1368

ACM-SG函数之Fibonacci again and again——hdu1848

ACM SG函数 Fibonacci again and again hdu1848

继续激情,继续奋斗。 4389

HDU1848 Fibonacci again and again【SG函数】

Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15284 Accepted Submission(s): 6793 Problem Description 任何一个大学生对菲波那...

海岛Blog 690

【HDU】1848 Fibonacci again and again

http://acm.hdu.edu.cn/showproblem.php?pid=1848 题意:同nim,3堆,每次取的为fib数,n<=1000 #include <cstdio> #include <cstring> using namespace std; int f[1005], a[100]; bool b[20]; int ...

72
上一篇: ZOJ 3956 Course Selection System
下一篇: HDU 2509 Be the Winner (Anti-Nim)
DIDCJS
博客等级 码龄11年 5粉丝 31原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值