3.4w+
社区成员
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
cin >> a;
for(int i = a.size() - 1, ans = 0; i >= 0; i -- )
{
if(a[i] != '0')
{
cout << ans;
break;
}
ans ++;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
// 2 3 5 7
//23 37 53 73
//237 373
int main()
{
// int n; cin >> n;
// for(int i=2;i<50;i++)if(!(n%i)){cout<<"no"; break;}
cout << 373;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long n, m, l = 0, r = N, mid, ans;
long long a[N], b[N];
bool pd;
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i ++ ) cin >> a[i];
for (int i = 0; i < n; i ++ ) cin >> b[i];
while (l < r)
{
pd = true, mid = l + r + 1 >> 1, ans = m;
for (int i = 0; i < n; ++i)
{
if (a[i] >= mid) continue;
if (a[i] + b[i] < mid || mid - a[i] > ans)
{
pd = false;
break;
}
ans -= mid - a[i];
}
if(pd) l = mid;
else r = mid - 1;
}
cout << l;
return 0;
}
(看完题感觉像DP, 可能对题目理解有偏差, 但也不是特别懂为什么,只通过20%)
#include<bits/stdc++.h>
using namespace std;
int n, m, ans;
int dp[510][510];
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i ++ ) for(int j = 0; j < m; j ++ ) cin >> dp[i][j];
for(int i = 1; i < n; i ++ ) dp[i][0] += dp[i - 1][0];
for(int i = 1; i < m; i ++ ) dp[0][i] += dp[0][i - 1];
for(int i = 1; i < n; i ++ ) for(int j = 1; j < m; j ++ )
dp[i][j] += min(dp[i - 1][j], dp[i][j - 1]), ans = max(ans, dp[i][j]);
cout << ans;
return 0;
}
应该是最短路问题