#include<bits/stdc++.h> #define ll long long usingnamespace std;
intmain(){ int T; scanf("%d", &T); while (T--) { int n; scanf("%d", &n); int cnt = 0; for (int sum = 0, i = 1; sum < n; sum += i, i += 2) ++cnt; printf("%d\n", cnt); } return0; }
#include<bits/stdc++.h> #define ll long long usingnamespace std;
int s[105];
intmain(){ int T; scanf("%d", &T); while (T--) { int n, a, b; scanf("%d%d%d", &n, &a, &b); for (int i = 1; i <= n; i++) scanf("%1d", &s[i]); if (b >= 0) printf("%d\n", n * (a + b)); else { s[0] = -1; int cnt[2] = { 0, 0 }; for (int i = 1; i <= n; i++) { if (s[i] != s[i - 1]) ++cnt[s[i]]; } printf("%d\n", n * a + (min(cnt[0], cnt[1]) + 1) * b); } } return0; }
#include<bits/stdc++.h> #define ll long long usingnamespace std;
constint MAX = 2e5+50; int a[MAX];
intmain(){ int T; scanf("%d", &T); while (T--) { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); int ans = n + n - 1; auto d = [&](int i, int j) -> int { returnabs(a[i] - a[j]) + abs(i - j); }; auto check = [&](int l, int r) -> int { for (int i = l; i <= r; i++) { for (int j = l; j <= r; j++) { for (int k = l; k <= r; k++) { if (i == j || i == k || j == k) continue; if ((ll)d(i, j) == (ll)d(i, k) + (ll)d(k, j)) { return0; } } } } return1; }; for (int i = 3; i <= n; i++) { ans += check(i - 2, i); if (i >= 4) ans += check(i - 3, i); } printf("%d\n", ans); } return0; }