大提琴的声音就像一条河,左岸是我无法忘却的回忆,右岸是我值得紧握的璀璨年华,中间流淌的,是我年年岁岁淡淡的感伤

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
#define P pair<int,int>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
int n,s[110][110],dp[110][110];
int main()
{cin>>n;for(int i=1;i<=n;i++)for(int j=1;j<=i;j++)cin>>s[i][j];for(int i=1;i<=n;i++)dp[n][i]=s[n][i];for(int i=n-1;i>=1;i--)for(int j=1;j<=i;j++)dp[i][j]=s[i][j]+max(dp[i+1][j],dp[i+1][j+1]);cout<<dp[1][1]<<endl;return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
#define P pair<int,int>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
void xhr(string& str)
{char c=str[str.length()-1];int i=str.length();while(--i) str[i]=str[i-1];str[0]=c;
}
void xhl(string& str)
{char c=str[0];for (int i=0; i<str.length()-1; i++)str[i]=str[i+1];str[str.length()-1]=c;
}ll getlh(const string& str)
{vector<vector<ll> > dp(str.length(), vector<ll>(2,0));dp[0][0]=dp[1][0]=1;for (int i=2; i<str.length()-1; i++){int ls1=i-1;int ls2=i-2;dp[i][0]=dp[ls1][0]+dp[ls1][1]; if (str[i]=='A') continue; if (str[ls1]=='A') dp[i][0]=dp[ls2][1];  if (str[i+1]!='A') continue;if (str[ls1]=='B')dp[i][0]=dp[i][1]=dp[ls1][0];    else{dp[i][0]=dp[ls2][1];dp[i][1]=dp[ls1][0];}}int cur=str.length()-1;dp[cur][0]=dp[cur-1][0]+dp[cur-1][1]; if (str[cur]=='B'&&str[cur-1]=='A') dp[cur][0]=dp[cur-2][1];ll res=dp[cur][0];if (str[0]=='B'&&str[cur]=='A')res=dp[cur-1][1];return res;
}
int main()
{string str;getline(cin,str);if (str[0]=='A'&&str[str.length()-1]=='B')xhr(str);if (str[1]=='B'&&str[2]=='A')xhl(str);ll jg=getlh(str);if (str[0]=='B'&&str[1]=='A'){swap(str[0],str[1]);jg+=getlh(str);}cout<<jg<<endl;return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
#define P pair<int,int>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
int n,ct,jg;
ll k, a, x, y, m;
struct node{ int t,a,i;
} d[200010];
bool compare(node x, node y) {if(x.t==y.t) return (x.a<y.a||(x.a==y.a&&x.i<y.i));elsereturn x.t<y.t;
}
int main() {cin>>n;for(int i=1; i<=n; i++) {cin>>k>>a>>x>>y>> m;int t=0;ll b;for(int j=0; j<k; j++){if(ct<2e5) d[ct++]=(node){t,a,i};b=(a*x+y)%m;if(b<a&&j!=k-1) t++;a=b;}jg=max(jg, t);}cout<<jg<<endl;if(ct<2e5) {sort(d,d+ct,compare);for(ll i=0; i<ct; i++) cout<<d[i].a<<' '<<d[i].i<<endl;}return 0;
}

蓝桥杯练习----数字三角形,Cowboys,Beaver's Calculator相关推荐

  1. (蓝桥杯)数字三角形。。(最简单的dp题)

    (图3.1-1)示出了一个数字三角形. 请编一个程序计算从顶至底的某处的一条路 径,使该路径所经过的数字的总和最大. ●每一步可沿左斜线向下或右斜线向下走: ●1<三角形行数≤100: ●三角形 ...

  2. 蓝桥杯-代码-数字三角形

    一:题目 二:代码 #include <iostream> #include<vector> using namespace std; int main() {/**思路:1. ...

  3. 蓝桥杯 ALGO-1005 数字游戏 python

    蓝桥杯 ALGO-1005 数字游戏 python 试题 算法训练 数字游戏 资源限制 时间限制:1.0s 内存限制:256.0MB 问题描述 给定一个1-N的排列a[i],每次将相邻两个数相加,得到 ...

  4. 蓝桥javab组数字三角形--dfs的思路

    数字三角形 基本思想 dfs模板 蓝桥javab组数字三角形 思路 代码 基本思想 第一次学习dfs的同学也许像我一样,刚开始学习的时候,感觉在写dfs不知道要干些什么. 首先我们要知道dfs和bfs ...

  5. java中的冰雹数,java实现第七届蓝桥杯打印数字

    打印数字 打印数字 小明写了一个有趣的程序,给定一串数字. 它可以输出这串数字拼出放大的自己的样子. 比如"2016"会输出为: 00000 1 6666 2 0 0 1 1 6 ...

  6. 蓝桥杯 算法训练 ALGO-128 Cowboys 递推、动态规划

    算法训练 Cowboys 时间限制:2.0s 内存限制:256.0MB 提交此题 问题描述 一个间不容发的时刻:n个牛仔站立于一个环中,并且每个牛仔都用左轮手枪指着他旁边的人!每个牛仔指着他顺时针或者 ...

  7. Java实现 蓝桥杯 算法提高 三角形

    算法提高 12-1三角形 时间限制:1.0s 内存限制:256.0MB 提交此题 问题描述 为二维空间中的点设计一个结构体,在此基础上为三角形设计一个结构体.分别设计独立的函数计算三角形的周长.面积. ...

  8. 准备蓝桥杯--dyx--杨辉三角形

    问题描述 杨辉三角形又称Pascal三角形,它的第i+1行是(a+b)i的展开式的系数. 它的一个重要性质是:三角形中的每个数字等于它两肩上的数字相加. 下面给出了杨辉三角形的前4行: 1 1 1 1 ...

  9. 【c语言】蓝桥杯算法提高 三角形面积

    问题描述 由三角形的三边长,求其面积. 提示:由三角形的三边a,b,c求面积可以用如下的公式: s=(a+b+c)/2 面积= 输入格式 由空格分开的三个整数. 输出格式 一个实数,保留两位小数. 样 ...

最新文章

  1. linux网络报文接收发送浅析_Docker容器网络-基础篇
  2. SAP 电商云 Spartacus UI 里的 InjectionToken 应用场景
  3. 与大家分享一个我最近开始用的不错的JavaScript IDE
  4. 认识Linux系统中的inode,硬链接和软链接
  5. Azure IoT Hub入门 - 接口介绍
  6. Nginx的主要函数调用关系分析
  7. App Support
  8. 大赛响锣、Call 你来战……对面的开发者看过来!
  9. 深度解析MySQL启动时报“The server quit without updating PID file”错误的原因
  10. eagle打开的brd和sch转换为AD打开的原理图和PCB
  11. 工行u盾显示316_工行U盾常见故障处理
  12. luci编程 openwrt_【玩转开源】BananaPi R2 —— 第四篇 Openwrt Luci 初探
  13. Thinkphp6 Malformed UTF-8 characters, possibly incorrectly encoded in
  14. 新上线APP如何推广提升排名
  15. 软件使用:如何用Mac做热点。
  16. android怎么点击换图片,ImageButton单击切换按钮图片
  17. linux trace 进程 文件路径,linux panic 问题定位
  18. 华为路由器默认用户名密码
  19. 使用TensorFlow进行图像识别
  20. AI测谎仪:通过微表情在法庭检测谎言,性能已优于人类

热门文章

  1. qt中制作添加 .ts 翻译文件
  2. J2EE struts2MVC应用在线书签1
  3. Java语言最新实用案例教程_Java语言最新实用案例教程
  4. 一个简单的Vue过滤器
  5. 51单片机用STC—ISP烧录程序是一直显示“正在检测目标单片机···”冷启动板子没有反应
  6. (重点)“Grid“网格布局
  7. 生活中软件易用性的例子_大学生活中那些堪称神器的软件,真实且好用,生活学习必备...
  8. 图像质量评价学习笔记02:IQA模型性能评价指标(PLCC、SROCC、KROCC、RMSE)
  9. 必测的支付漏洞(一)——使用fiddler篡改支付金额
  10. 优思学院:通俗地谈谈FMEA