AcWing 3418. 杨辉三角形
原题链接
简单
作者:
Mr.W
,
2021-04-27 15:04:18
,
所有人可见
,
阅读 952
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2005;
ll f[N][N];
int main()
{
int n;
cin >> n;
for(int i = 1; i < N; i ++ )
for(int j = 1; j <= i; j ++ )
{
if(i == 1 && j == 1) f[i][j] = 1;
else f[i][j] = f[i - 1][j] + f[i - 1][j - 1];
if(f[i][j] > 1e9) f[i][j] = 1e10;
if(f[i][j] == n)
{
cout << i * 1ll * (i - 1) / 2 + j << endl;
return 0;
}
}
int m = sqrt(n * 2) + 1;
if(m * (m - 1) / 2 == n) cout << m * 1ll * (m + 1) / 2 + 3 << endl;
else cout << n * 1ll * (n + 1) / 2 + 2 << endl;
return 0;
}
您好,请问m是代表什么?