BZOJ1258: [CQOI2007]三角形tri
2024-08-25 13:58:07
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1258
如果最后一位是4,那就改成123就好了。
然后最后一位不是4的话,至多三个答案,然后可以发现把给的串最后一个改成4的一定会有。然后可以发现1继承其祖先12的,2继承13的,3继承23的,然后扫一遍。。
(口胡了这么多还是自己找找规律吧TAT
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 2000
using namespace std;
int n,f[];
char s[maxn];
int read(){
int x=,f=; char ch=getchar();
while (!isdigit(ch)) {if (ch=='-') f=-; ch=getchar();}
while (isdigit(ch)) {x=x*+ch-''; ch=getchar();}
return x*f;
}
void out(){
putchar('T');
rep(i,,n-) putchar(s[i]);
puts("");
}
int main(){
// freopen("in.txt","r",stdin);
scanf("%s",s);
n=strlen(s)-;
if (s[n]==''){
rep(i,,){
putchar('T');
rep(j,,n-) putchar(s[j]);
printf("%d\n",i);
}
return ;
}
if (s[n]=='') f[]=f[]=;
if (s[n]=='') f[]=f[]=;
if (s[n]=='') f[]=f[]=;
out();
while (--n){
int x=s[n]-'';
if (x==) {
if (f[]) f[]=,out();
}
if (x==){
if (f[]) f[]=,out();
}
if (x==){
if (f[]) f[]=,out();
}
}
return ;
}
最新文章
- bootstrap插件引用
- cloudera learning8:MapReduce and Spark
- 习课的redis配置记录
- thinkphp遗留问题
- 关注web前端
- D3.js 简介和安装
- get/close not same thread Druid 连接池一个设置
- DB天气app冲刺二阶段第四天
- mysql修改字段的语句写法
- PDFium-PDF开源之旅(1)-初探代码下载编译
- 网站生产app的一些网址
- java:Comparable比较器
- webpack 3.X学习之JS压缩与打包HTML文件
- AutoMapper在asp.netcore中的使用
- Flask Ansible自动化平台搭建(持续更新)
- 谈谈 ANR 之 Service 超时
- C# 为所有 CheckBox 添加事件
- H5选择颜色-前端颜色选择器
- C# [IPA]IOS In App Purchase(内购)验证(asp.net 版本)
- mysql分组后将未分组的列合并成行GROUP BY,GROUP_CONCAT