#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
int arr[110];
bool use[110];
int ans = -1;
int maxx = 0;
int main()
{
cin >> n;
for (int i = 1;i <= n;i++)
{
cin >> arr[i];
maxx += arr[i];
}
for (int i = 1;i <= n;i++)
{
int flag = 1;
int pos = i;
int ans1 = 0;
memset(use, 1, sizeof(use));
while (1)
{
if (pos == n + 1)
{
pos = 1;
}
if (arr[pos] == flag&&use[pos]==1)
{
ans1 += flag;
flag = 1;
use[pos] = 0;
}
else if(use[pos]==1)
{
flag++;
}
pos++;
if (flag > n || ans1 >= maxx)
{
break;
}
}
ans = max(ans1, ans);
}
cout << ans << endl;
return 0;
}
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cmath>
int main()
{
int n;
cin >> n;
for (int i = 0;i * i <= n;i++)
{
for (int j = i;i * i + j * j <= n;j++)
{
for (int z = j;i * i + j * j + z * z <= n;z++)
{
int x = sqrt(n - (i * i + j * j + z * z));
int y = n - i * i - j * j - z * z;
if (x * x == y)
{
cout << i << " " << j << " " << z << " " << x << endl;
return 0;
}
}
}
}
return 0;
}
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
long long ans = 0;
for (int i = 1;i <= n;i++)
{
int num = i;
while (num)
{
int flag = num % 10;
if (flag == 0 || flag == 2 || flag == 1 || flag == 9)
{
ans += i;
break;
}
num /= 10;
}
}
cout << ans << endl;
return 0;
}
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
long long n;
long long ans = 0;
long long mod = 1e9 + 7;
cin >> n;
n--;
for (int i = 1;i <= n;i++)
{
ans += (n - i + 1) * (n - i + 1);
ans += (n - i + 1) * (n - i + 1) * (i - 1);
ans %= mod;
}
cout << ans << endl;
return 0;
}
#include<iostream>
using namespace std;
#include<algorithm>
#include<cmath>
#include<cstring>
int main()
{
int n;
cin >> n;
for (int i = 1;i <= n;i++)
{
cout << max((i-1)*2, (n - i) * 2 )<< endl;
}
return 0;
}
#include<iostream>
using namespace std;
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
int n;
void f2(int x)
{
if (x <= 9)
{
cout << x;
}
else
{
cout << char(x + 55);
}
return;
}
void f(int i,int j)
{
int num = i * j;
vector<int>v;
while (num)
{
v.push_back(num % n);
num /= n;
}
while (!v.empty())
{
vector<int>::iterator pos = v.end();
pos--;
f2(*pos);
v.erase(pos);
}
return;
}
int main()
{
cin >> n;
for (int i = 1;i < n;i++)
{
for (int j = 1;j <= i;j++)
{
f2(i);
cout << "*";
f2(j);
cout << "=";
f(i, j);
cout<< " ";
}
cout << endl;
}
return 0;
}
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
int const N= 1e5 + 10;
int use[N];
int main()
{
cin >> n;
memset(use, 0, sizeof(use));
int num;
for (int i = 1;i <= n;i++)
{
cin >> num;
use[num]++;
}
int n1 = 0;
int n2 = 0;
for (int i = 1;i <= n;i++)
{
if (use[i] > 2)
{
n1 += (use[i] - 2);
}
else if (use[i] == 1)
{
n2++;
}
}
int ans = max(n1, (n1 + n2) / 2);
cout << ans << endl;
return 0;
}
#include<iostream>
using namespace std;
#include<vector>
int const N = 1e5 + 10;
pair<int, int> pii[N];
int main()
{
int n, k;
cin >> n >> k;
for (int i = 1;i <= n;i++)
{
cin >> pii[i].first >> pii[i].second;
}
int left = 1;
int right = 1e5;
int mid;
int ans = -1;
while (left <= right)
{
mid = (left + right) / 2;
int res = 0;
for (int i = 1;i <= n;i++)
{
res += (pii[i].first / mid) * (pii[i].second / mid);
if (res > k)break;
}
if (res >= k)
{
ans = max(ans, mid);
left = mid + 1;
}
else
{
right = mid - 1;
}
}
cout << ans << endl;
return 0;
}