|
|
第1行: |
第1行: |
| <pre> | | <pre> |
| //第一题
| | homoaaaaa@protonmail.com |
| #include <bits/stdc++.h>
| |
| using namespace std;
| |
| int a[100000];
| |
| int main()
| |
| {
| |
| int n;
| |
| int m=-9999,sum=1;
| |
| int i;
| |
| cin>>n;
| |
| a[0]=-3456497;
| |
| for(i=1;i<=n;i++)
| |
| {
| |
| cin>>a[i];
| |
| if(a[i]==a[i-1])
| |
| sum++;
| |
| else
| |
| sum=1;
| |
| if(sum>m)
| |
| m=sum;
| |
| }
| |
| cout<<m<<endl;
| |
| return 0;
| |
| }
| |
| | |
| //第二题 自己写
| |
| //第三题
| |
| #include <bits/stdc++.h>
| |
| using namespace std;
| |
| const int N = 1010;
| |
| int w[N][N];
| |
| int t[N];
| |
| bool st[N];
| |
| int n;
| |
| | |
| int main()
| |
| {
| |
| cin >> n;
| |
| for(int i = 1; i <= n; i ++)
| |
| {
| |
| cin >> t[i];
| |
| for(int j = 0; j < t[i]; j ++)
| |
| cin >> w[i][j];
| |
| }
| |
| | |
| st[1] = true;
| |
| for(int i = 0; i < t[1]; i ++)
| |
| {
| |
| int x = w[1][i];
| |
| st[x] = true;
| |
| for(int j = 0; j < t[x]; j ++)
| |
| {
| |
| int y = w[x][j];
| |
| st[y] = true;
| |
| }
| |
| }
| |
| | |
| int ans = 0;
| |
| for(int i = 1; i <= n; i ++)
| |
| if(st[i])
| |
| ans ++;
| |
| cout << ans;
| |
| }
| |
| //第四题
| |
| #include <bits/stdc++.h>
| |
| using namespace std;
| |
| | |
| bool check(int x) {
| |
| int sum1 = 0, sum2 = 0, p = 1;
| |
| while (x) {
| |
| if (p) sum1 += x % 10;
| |
| else sum2 += x % 10;
| |
| p ^= 1;
| |
| x /= 10;
| |
| }
| |
| return sum1 == sum2;
| |
| }
| |
| | |
| int main() {
| |
| int a, b, ans = 0;
| |
| cin >> a >> b;
| |
| for (int i = a; i <= b; i++) {
| |
| if (check(i)) ans++;
| |
| }
| |
| cout << ans << endl;
| |
| return 0;
| |
| }
| |
| //第五题
| |
| #include <bits/stdc++.h>
| |
| using namespace std;
| |
| const int N = 40;
| |
| int w[N][N], n, m, k;
| |
| | |
| int check(int x1, int y1, int x2, int y2)
| |
| {
| |
| int ans = 0;
| |
| for(int i = x1; i <= x2; i ++)
| |
| for(int j = y1; j <= y2; j ++)
| |
| ans += w[i][j];
| |
|
| |
| return ans;
| |
| }
| |
| | |
| int main()
| |
| {
| |
| cin >> n >> m >> k;
| |
| for(int i = 0; i < n; i ++)
| |
| for(int j = 0; j < m; j ++)
| |
| cin >> w[i][j];
| |
| | |
| int ans = 1000000000;
| |
| for(int i = 0; i < n; i ++)
| |
| for(int j = 0; j < m; j ++)
| |
| {
| |
| for(int i1 = i; i1 < n; i1 ++)
| |
| for(int j1 = j; j1 < m; j1 ++)
| |
| {
| |
| if(check(i, j, i1, j1) >= k)
| |
| ans = min(ans, (i1 - i + 1) * (j1 - j + 1));
| |
| }
| |
| }
| |
|
| |
| cout << ans;
| |
| return 0;
| |
| }
| |
|
| |
|
| </pre> | | </pre> |