lightoj 1025 弱智区间dp

【嵙大OJ】Problem 1177:成绩统计 Problem A: 成绩统计 Time Limit: 1 Sec  Memory Limit: 16 MB Submit: 4407  Solved: 1878 [Submit][Status][Web Board] Description 把百分制的考试成绩转换为五个等级: 90~100:Excellent 80~89:Good 70~79:Average 阅读详情

Feuzem is an unemployed computer scientist who spends his days working at odd-jobs. While on the job he always manages to find algorithmic problems within mundane aspects of everyday life.

Today, while writing down the specials menu at the restaurant he’s working at, he felt irritated by the lack of palindromes (strings which stay the same when reversed) on the menu. Feuzem is a big fan of palindromic problems, and started thinking about the number of ways he could remove letters from a particular word so that it would become a palindrome.

Two ways that differ due to order of removing letters are considered the same. And it can also be the case that no letters have to be removed to form a palindrome.

Input
Input starts with an integer T (≤ 200), denoting the number of test cases.

Each case contains a single word W (1 ≤ length(W) ≤ 60).

Output
For each case, print the case number and the total number of ways to remove letters from W such that it becomes a palindrome.

Sample Input
Output for Sample Input
3
SALADS
PASTA
YUMMY
Case 1: 15
Case 2: 8
Case 3: 11

去掉任意字符找个回文串…
标准的区间dp
从左到右-1和从右到左-1加上减掉中间
如果两边一样就加上中间再+1

#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<string>
#include<memory.h>
using namespace std;
long long dp[61][61];
int main()
{
    int T;
    cin >> T;
    int u = 0;
    string q;
    while (T--)
    {
        memset(dp, 0, sizeof(dp));
        cin >> q;
        int chang = q.size();
        for (int a = 0;a < chang;a++)dp[a][a] = 1;
        for (int a = 0;a < chang;a++)
        {
            for (int b = a-1;b >=0;b--)
            {
                dp[b][a] = dp[b][a - 1] + dp[b + 1][a] - dp[b + 1][a - 1];
                if (q[a] == q[b])dp[b][a] += dp[b + 1][a - 1] + 1;
            }
        }
        printf("Case %d: %lld\n", ++u, dp[0][chang - 1]);
    }
    return 0;
}
miniDP与DP管脚定义差异详解及设计避坑指南 本文详细解析了Mini DisplayPort与标准DisplayPort接口在管脚定义上的核心差异,通过对比表格直观展示了两者20针脚的不同排列方式,特别是高速差分信号线的分布。文章结合真实设计案例,为硬件工程师提供了从原理图设计、PCB布局到信号完整性考量及故障排查的完整避坑指南,强调绝不能将两者视为简单的物理缩小版。 阅读详情

相关推荐

Vue3多级路由缓存失效的深度解析与实战解决方案

本文深度解析了Vue3项目中多级路由下keep-alive缓存失效的根本原因,并提供了三种实战解决方案:通过路由扁平化根治问题、利用状态管理精细模拟缓存效果,以及借助keep-alive-vue3插件快速修复。文章旨在帮助开发者彻底理解Vue Router与keep-alive的协作机制,从而根据项目情况选择最佳策略,有效解决页面状态丢失的难题。

weixin_29015801的博客 288

lightoj1025

区间DP代码如下:#include <bits/stdc++.h>using namespace std;long long dp[110][110];int main () { // freopen("E:\\1.in", "r", stdin); // freopen("E:\\1.out", "w", stdout); int t, cnt = 1; scanf("

记一笔、三三两两 302

【FPGA】安路FPGA下载器驱动安装教程

#来自学渣的问候 最近正在参加19年的FPGA创新设计大赛,然后我们选择了安路(全名:上海安路信息科技有限公司)的 FPGA 开发板。安路算是国产FPGA中还不错的一家,和紫光一样,除了自主生产的FPGA,也开始拥有了自己的编译环境。 好了。言归正传,写这篇博客的原因是,前几天在安装 安路 的编译环境和下载器驱动的时候,出了点问题,弄得心烦意乱。所以打算解决之后写篇博客,避开这个神奇的问题。 首先...

Ninquelote的博客 2万+

Lightoj 1025 DP

dp[i][j] 表示从i到j的种类数,然后分要j不要j  要j的时候分只有j还是和其他配对(注意在与其他配对的时候要+1) AC代码如下: #include #include #include #include #include using namespace std; long long dp[61][61]; int main(){ int T, Case = 1; c

马德里小铁匠的铁匠铺 869

PVE虚拟机运行不流畅,出现卡顿。

🏆本文收录于《CSDN问答解惑-专业版》专栏,主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!

**My Coding Family** 3073

【PyTorch深度学习项目实战100例目录】项目详解 + 数据集 + 完整源码

大家好,我是阿光。本专栏整理了《深度学习100例》,内包含了各种不同的深度学习项目,包含项目原理以及源码,每一个项目实例都附带有完整的代码+数据集。正在更新中~ ✨。

CSDN 精品推荐 10万+

lightoj 1025 区间dp

#include using namespace std; typedef long long ll; char a[70]; ll dp[70][70]; int main(){ int T; scanf("%d",&T); int n; int ca = 0; while(T--){ memset(dp,0,sizeof(dp)); scanf("%s",a+1);

basasuya的博客 405

星载SAR的各项指标解读(史上最全)

一、系统指标 系统指标主要指雷达系统的通用的指标,以及和卫星整星相关的指标,主要有一下几项: 工作频段: 雷达体制: 极化方式: 设计s

9299

lightoj 1025【区间DP】

题意: 给出一个word,求有多少种方法你从这个word清除一些字符而达到一个回文串。 思路: 区间问题,还是区间DP; 我判断小的区间有多少,然后往外扩大一点。 dp[i,j]就代表从i到j的方案数。 状态转移: 其实对于在任意区间[i ,j],都可以, 在子区间[i+1,j]中可以直接去掉s[j]时,顺便去掉s[i],所以就有它的方案, 在子区间[i,j-...

weixin_30752377的博客 138

得物(毒)App潮鞋价格波动监控系统实战:从爬虫开发到数据可视化完整指南

本文将带领您从零开始构建一套完整的得物潮鞋价格监控系统,涵盖爬虫开发、数据存储、价格波动分析和可视化展示等全流程技术。我们将使用最新的Python技术栈,包括异步爬虫框架、智能代理池、反爬虫绕过技巧,以及基于机器学习的时间序列预测模型。无论您是想要追踪特定鞋款价格的潮流爱好者,还是希望构建商业级监控系统的开发者,这篇文章都将为您提供切实可行的解决方案。

2201_76125261的博客 2515

SAP SEGW 事物码里的 Association 建模方式

Association 模型用于描述 OData 模型里不同 Entity Type 之间的关联关系。我们来看一个具体的例子:Principal Entity(主体):代表 association 的主导端。Cardinality(基数):指定主体实体类型和依赖实体类型之间的关系。按 F4 或点击从列表中选择。关联的多重性如下:为引用约束()指定以下参数,目的是将主体实体类型的每个键,关联到从属实体类型的一个属性:Referential Constraints 的一个例子如下: 引用约束(Referenti

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 914

lightoj 1025 - The Specials Menu 【区间dp】

题目链接:lightoj 1025 - The Specials Menu 1025 - The Specials Menu PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Feuzem is an unemployed computer scientist who

世界很大 525

嵌入式数字信号处理器(DSP)高频面试题及参考答案

数字信号处理器(DSP)是一种专门设计用于执行数字信号处理任务的微处理器。它具有高度优化的架构,能够高效地执行复杂的数学运算,如快速傅里叶变换(FFT)、卷积、滤波和其他信号处理算法。DSP通常具有高速的中央处理器、专用的硬件乘法器、累加器、硬件循环支持和高速的内存访问能力,以满足实时信号处理的需求。通信:用于调制解调、语音编码、数据压缩、加密和解密。音频处理:如音乐合成、音效增强、语音识别和语音合成。视频和图像处理:包括图像压缩、视频编码、图像增强和模式识别。生物医学工程。

大模型大数据攻城狮的专栏 5281

OJ第二批——Problem B:处理成绩(C++类训练)

问题及代码:   #include using namespace std; void average(int ,int ,int ); void juage(int ,int ,int ); void average(int a,int b,int c) { int d; d=(a+b+c)/3; cout<<d<<endl; }

Timor7hao的专栏 767

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Light OJ 1025 The Specials Menu 详细题解(回文串的区间DP)

1025 - The Specials Menu     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Feuzem is an unemployed computer scientist who spends h

K键盘里的青春K 674

老版QQ原生表情gif动态

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

LightOJ1025-The Specials Menu-区间dp

题目大意:给你一段字符串,让你求它的字串中有多少个回文字符串; 题目解析:区间dp,定义dp[i][j]为从第i个字母到底j个字母中含有的回文字符串,那么 dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1],如果s[i]=s[j],那么相当于在dp[i+1][j-1]所对应的回文字符串开头和最后各加一个s[i],所以dp[i][j]要加上dp[i+1][j-

zyz_3_14159的博客 285

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

lightoj 1025 The Specials Menu (DP)

Feuzem is an unemployed computer scientist who spends his days working at odd-jobs. While on the job he always manages to find algorithmic problems within mundane aspects of everyday life. Today, whi

fisty 713

SWUST OJ 1025

地址:http://acm.swust.edu.cn/oj/problem/1025/ Description TT lives in a dream world.All countries in the world are circular or rectangular.There is a moat on the territorial border of each

qqspeed 5725

hdu1025 Constructing Roads In JGShining's Kingdom(最长上升子序列 + 二分处理)

Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8812Accepted Submission(s): 2513 Problem De...

angtongyou1893的博客 233

lightoj 1031 被区间dp虐哭...看题解才学会

You are playing a two player game. Initially there are n integer numbers in an array and player A and B get chance to take them alternatively. Each player can take one or more numbers from the left or

NineFailure的博客 2840

HDU1024 这压缩真先进...先进的我想跳河

DescriptionNow I think you have got an AC in Ignatius.L’s “Max Sum” problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult probl

NineFailure的博客 1507

POJ1661 神坑卧槽!!

Description“Help Jimmy” 是在下图所示的场景上完成的游戏。 场景中包括多个长度和高度各不相同的平台。地面是最低的平台,高度为零,长度无限。 Jimmy老鼠在时刻0从高于所有平台的某处开始下落,它的下落速度始终为1米/秒。当Jimmy落到某个平台上时,游戏者选择让它向左还是向右跑,它跑动的速度也是1米/秒。当Jimmy跑到平台的边缘时,开始继续下落。Jimmy每次下落的高度不能超

NineFailure的博客 1316

HDU1069终于会一个不算水的DP

Problem Description A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some

NineFailure的博客 1019

HDU1159最长公共子序列

这个题貌似是算法导论的原题 不过本着能循环坚决不用递归的态度 我认真地写了循环… 关键其实就是一个转移方程 如果两个字节一样,他就等于 dp[a][b]=dp[a+1][b+1]+1; 如果不一样就找两边最大的 dp[a][b]=max(dp[a][b+1],dp[a+1][b]); 另外在DP题里有点找到感觉了,如果想要用循环就先找到以前递归的感觉,然后自底向上加回去#includ

NineFailure的博客 772

codeforces768D(87/600)

D. Jon and Orbs time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Jon Snow is on the lookout for some orbs required to defeat the white walk

NineFailure的博客 767

CodeForces - 812B

Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building,

NineFailure的博客 747
上一篇: lightoj 1009 二分染色
下一篇: lightoj 1027 幼儿园概率...
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值