Timus 1225. Flags dp

1225. Flags
Time Limit: 1.0 second
Memory Limit: 16 MB
On the Day of the Flag of Russia a shop-owner decided to decorate the show-window of his shop with textile stripes of white, blue and red colors. He wants to satisfy the following conditions:
Stripes of the same color cannot be placed next to each other.
A blue stripe must always be placed between a white and a red or between a red and a white one.
Determine the number of the ways to fulfill his wish.
Example. For N = 3 result is following:

Input
N, the number of the stripes, 1 ≤ N ≤ 45.
Output
M, the number of the ways to decorate the shop-window.
Sample

input 
3

output

4

 

 

 

 

discuss里有人这么说:

use fibonacci
1,1,2,3,5,8,13...

answer = fibonacci(3)*2;

不明白……但这么做答案是对的。

我用的是dp

 

 

* index: 2 name: <alsa_output.platform-dp0-sound.multichannel-output> driver: <module-alsa-card.c> flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY state: RUNNING suspend cause: (none) priority: 9000 volume: front-left: 46530 / 71% / -8.92 dB, front-right: 46530 / 71% / -8.92 dB balance 0.00 base volume: 65536 / 100% / 0.00 dB volume steps: 65537 muted: no current latency: 0.00 ms max request: 344 KiB max rewind: 344 KiB monitor source: 4 sample spec: s16le 2ch 48000Hz channel map: front-left,front-right 立体声 used by: 1 linked by: 1 configured latency: 1837.50 ms; range is 0.50 .. 1837.50 ms card: 0 <alsa_card.platform-dp0-sound> module: 6 properties: alsa.resolution_bits = "16" device.api = "alsa" device.class = "sound" alsa.class = "generic" alsa.subclass = "generic-mix" alsa.name = "rockchip,dp0 spdif-hifi-0" alsa.id = "rockchip,dp0 spdif-hifi-0" alsa.subdevice = "0" alsa.subdevice_name = "subdevice #0" alsa.device = "0" alsa.card = "0" alsa.card_name = "rockchip,dp0" alsa.long_card_name = "rockchip,dp0" device.bus_path = "platform-dp0-sound" sysfs.path = "/devices/platform/dp0-sound/sound/card0" device.form_factor = "internal" device.string = "hw:0" device.buffering.buffer_size = "352800" device.buffering.fragment_size = "176400" device.access_mode = "mmap+timer" device.profile.name = "multichannel-output" device.profile.description = "多声道" device.description = "内置音频 多声道" module-udev-detect.discovered = "1" device.icon_name = "audio-card" ports: multichannel-output: 多声道输出 (priority 0, latency offset 0 usec, available: unknown) properties: active port: <multichannel-output>
最新发布
07-15
Sun Jun 29, 2025 19:43:35: : IAR Embedded Workbench 9.40.1 (armPROC.dll) Sun Jun 29, 2025 19:43:35: : Loaded macro file: C:\iar\arm/config/debugger/Infineon/CYT2BL_M4.dmac Sun Jun 29, 2025 19:43:35: : Loaded macro file: C:\iar\arm/config/debugger/Infineon/CYTVII_M4.dmac Sun Jun 29, 2025 19:43:35: : Loaded macro file: C:\iar\arm/config/debugger/Infineon/CYTVII_Trace.dmac Sun Jun 29, 2025 19:43:35: : Loaded macro file: C:\iar\arm/config/debugger/Infineon/CYTVII_Common.dmac Sun Jun 29, 2025 19:43:35: : Loaded macro file: C:\iar\arm/config/flashloader/Infineon/FlashTVII.mac Sun Jun 29, 2025 19:43:35: : Loading the CMSIS-DAP driver Sun Jun 29, 2025 19:43:35: : Probe: CMSIS-DAP probe SW module ver 1.24 Sun Jun 29, 2025 19:43:35: : Probe: Connecting to ZF-WLFS-CMSIS-DAP:80940860-DC5475E17B3C firmware v.2.1.1 Sun Jun 29, 2025 19:43:35: : Emulation layer version 5.21 Sun Jun 29, 2025 19:43:35: : Notification to core-connect hookup. Sun Jun 29, 2025 19:43:35: : Connected DAP v2 on SWD. Detected DP ID=0x6ba02477. Sun Jun 29, 2025 19:43:35: : Connecting to TAP#0 DAP AHB-AP-CM port 0x2 (IDR=0x2477'0011). Sun Jun 29, 2025 19:43:35: : Recognized CPUID=0x410fc241 Cortex-M4 r0p1 arch ARMv7-M Sun Jun 29, 2025 19:43:35: : Debug resources: 6 instruction comparators, 4 data watchpoints. Sun Jun 29, 2025 19:43:35: : DMAC: Family ID: 0x108, Series: CYT2BL, Major.Minor Rev.: 1.1, Silicon ID: 0xea02 Sun Jun 29, 2025 19:43:35: : DMAC: FlashBoot Ver.: 3.1.0.556, TOC2 Flags: 0x243, Protection: NORMAL Sun Jun 29, 2025 19:43:35: : LowLevelReset(script, delay 200) Sun Jun 29, 2025 19:43:35: : Calling reset script: Traveo2_CM4_ResetAndAcquireDevice Sun Jun 29, 2025 19:43:35: : DMAC: Performing a hardware reset and entering test mode ... Sun Jun 29, 2025 19:43:35: : DMAC: Device has successfully entered test mode. Sun Jun 29, 2025 19:43:35: : DMAC: The power mode of Cortex-M4 core was set to ENABLED. Sun Jun 29, 2025 19:43:36: : Loaded debugee: C:\iar\arm/config/flashloader/Infineon/FlashTVIIBE_128K.out Sun Jun 29, 2025 19:43:36: : Target reset Sun Jun 29, 2025 19:43:37: : Unloaded macro file: C:\iar\arm/config/flashloader/Infineon/FlashTVII.mac Sun Jun 29, 2025 19:43:37: : Downloaded C:\Users\zhang\Downloads\CYT2BL3_Brushless_Driver_Project-master\CYT2BL3_Brushless_Driver_Project-master\Seekfree_CYT2BL3_Double_Foc_Project\project\iar\Debug_m4\Exe\cyt2bl3.out to flash memory. Sun Jun 29, 2025 19:43:37: : 105462 bytes downloaded into FLASH (53.45 Kbytes/sec) Sun Jun 29, 2025 19:43:37: : DMAC: Performing a hardware reset and entering test mode ... Sun Jun 29, 2025 19:43:37: : DMAC: Device has successfully entered test mode. Sun Jun 29, 2025 19:43:37: : DMAC: The power mode of Cortex-M4 core was set to ENABLED. Sun Jun 29, 2025 19:43:37: : Loaded debugee: C:\Users\zhang\Downloads\CYT2BL3_Brushless_Driver_Project-master\CYT2BL3_Brushless_Driver_Project-master\Seekfree_CYT2BL3_Double_Foc_Project\project\iar\Debug_m4\Exe\cyt2bl3.out Sun Jun 29, 2025 19:43:37: : Loaded extra image: C:\Users\zhang\Downloads\CYT2BL3_Brushless_Driver_Project-master\CYT2BL3_Brushless_Driver_Project-master\Seekfree_CYT2BL3_Double_Foc_Project\project\iar\project_config\cyt2bl3.ewx, image ID 3 Sun Jun 29, 2025 19:43:37: : LowLevelReset(software, delay 200) Sun Jun 29, 2025 19:43:37: : LowLevelReset(script, delay 200) Sun Jun 29, 2025 19:43:37: : Calling reset script: Traveo2_CM4_ResetAndAcquireDevice Sun Jun 29, 2025 19:43:37: : Download completed. Sun Jun 29, 2025 19:43:37: : LowLevelReset(software, delay 200) Sun Jun 29, 2025 19:43:38: : Target reset Sun Jun 29, 2025 19:43:38: : DMAC: Cortex-M0+ core was reset. Sun Jun 29, 2025 19:43:38: : DMAC/Trace: Configuring platform side SWO component. Sun Jun 29, 2025 19:43:38: : INFO: Configuring trace using 'swoinit(baseswo=0xE008_E002,baseitm=0xE000_0002)' setting... Sun Jun 29, 2025 19:43:38: : INFO: SWO trace mode is not supported by the probe (use I-jet/I-jet-Trace probe) - trace is disabled. 有问题吗
06-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值