parent
a0e918102c
commit
cd6fd41524
@ -0,0 +1,29 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 120;
|
||||
int a[N], b[N];
|
||||
const int INF = 0x3f3f3f3f;
|
||||
int n, sum, avg;
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 0; i < n; i++) {
|
||||
cin >> a[i];
|
||||
sum += a[i];
|
||||
a[i + n] = a[i];
|
||||
}
|
||||
avg = sum / n;
|
||||
int mi = INF;
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) b[j] = a[i + j];
|
||||
int cnt = 0;
|
||||
for (int j = 0; j < n - 1; j++) {
|
||||
cnt += abs(b[j] - avg);
|
||||
b[j + 1] += b[j] - avg;
|
||||
b[j] = avg;
|
||||
}
|
||||
mi = min(mi, cnt);
|
||||
}
|
||||
|
||||
cout << mi << endl;
|
||||
return 0;
|
||||
}
|
@ -1 +1,3 @@
|
||||
https://ccgao.blog.csdn.net/article/details/134725679
|
||||
https://ccgao.blog.csdn.net/article/details/134725679
|
||||
|
||||
https://tiku.scratchor.com/paper/view/z8k4y0xsf0ue8xlh
|
@ -0,0 +1,31 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 31;
|
||||
char a[N][N];
|
||||
int n, m, cnt;
|
||||
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = 0; j < m; j++)
|
||||
cin >> a[i][j];
|
||||
for (int e = 2; e <= min(m, n);e++){
|
||||
for (int i = 0; i <= n - e;i++){
|
||||
for (int j = 0; j <= m - e;j++){
|
||||
bool f = true;
|
||||
for (int x = 0; x < e;x++){
|
||||
for (int y = 0; y < e;y++){
|
||||
if(a[i][j]!=a[i+x][j+y]){
|
||||
f = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!f) break;
|
||||
}
|
||||
if (f) cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << cnt << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue