poj不能快读吗???
  • 板块灌水区
  • 楼主xyvsvg
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/11/12 11:53
  • 上次更新2023/10/27 03:17:36
查看原帖
poj不能快读吗???
807950
xyvsvg楼主2022/11/12 11:53

我第一次去poj,提交了一个数字三角形的题 代码:

#include<iostream>
#include<stack>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<climits>
#include<cstdio>
#include<ctype.h>
using namespace std;
inline void mr(int& theNumberToRead){theNumberToRead = 0; int prn = 1; char c = getchar(); while (!isdigit(c)){if (c == '-')prn = -1;c = getchar();}while (isdigit(c)){	theNumberToRead = 10 * theNumberToRead + c - 48;c = getchar();}theNumberToRead *= prn;}
int n, f[1001][1001], a[1001][1001], ans;
int main()
{
	mr(n);
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= i; ++j)
		{
			mr(a[i][j]);
			f[i][j] = max(f[i - 1][j - 1], f[i - 1][j]) + a[i][j];
		}
	}
	for (int i = 1; i <= n; ++i)
		ans = max(ans, f[n][i]);
	printf("%d", ans);
	return 0;
}

结果编译错误,后来把快读改成cin就通过了 有没有懂得解释下怎么会事

2022/11/12 11:53
加载中...