solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, t;
double a;
cin >> n >> t;
a = ((double)n * pow(1.000000011, (double)t));
cout << a;
return 0;
}
| 2 |
#include <bits/stdc++.h>
using namespace std;
char a[100020], b[100020];
int c[1 << 8][1 << 8];
int main(void) {
int i;
scanf("%s", a);
scanf("%s", b);
for (i = 0; a[i]; i++) ++c[a[i]][b[i]];
printf("%d\n", max(c['4']['7'], c['7']['4']));
return 0;
}
| 1 |
#include<bits/stdc++.h>
double dy[110][210][110];
bool chk[110][210][110];
int T[110];
int V[110];
int n;
double go(int idx, int t, int v) {
if (idx == n && v == 0) {
return 0;
}
if (idx == n) {
return -1e9;
}
if (v > V[idx])return -1e9;
auto& ret = dy[idx][t][v];
if (chk[idx][t][v])return ret;
chk[idx]... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long double d, r, x1, y1, x2, y2;
cin >> r >> x1 >> y1 >> x2 >> y2;
d = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
cout << ceil(d / (2.0 * r)) << endl;
}
| 2 |
#include <bits/stdc++.h>
template <typename C>
int sz(const C &c) {
return c.size();
}
using namespace std;
int main() {
iostream::sync_with_stdio(false);
int n;
cin >> n;
int d;
cin >> d;
int r = 2;
int p;
cin >> p;
for (int i = 1; i < n; ++i) {
int c;
cin >> c;
if (c - p == 2 * d) {
... | 1 |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const int N = 100010;
int n, m, p, q;
int f[N];
long long w[N];
set<pair<long long, int> > s;
int find_set(int x) {
if (f[x] == x) return x;
return f[x] = find_set(f[x]);
}
int main() {
scanf("%d %d %d %d", &n, &m, &p, &q);
for (int i = 1;... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 10 || n > 21) {
cout << 0 << endl;
} else if (n == 20) {
cout << 15 << endl;
} else {
cout << 4 << endl;
}
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
map<string, int> M = {{"monday", 0}, {"tuesday", 1}, {"wednesday", 2},
{"thursday", 3}, {"friday", 4}, {"saturday", 5},
{"sunday", 6}};
int main() {
ios_base::sync_with_stdio(false);
string a, b;
cin >> a >> b;
assert(M... | 1 |
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
int n;
int dist[101][101];
int atk[101][101];
int memo[101][101]; //memo[i][j] : ??????j??§?????????i???????????¨??????????°??\???\?????°
bool used[101][101];
const int INF = 1000000000;
struct V{
int p,m;
V(int p,in... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n, d;
cin >> n >> d;
int len = 0;
int64_t temp = n, to_add = 0, num = n;
while (1) {
if (temp == 0) {
break;
}
int64_t t_ans = num;
int val = 0;
if (temp % 10 != 9) {
val = 1;
}
temp /= 10;
len++;
... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
string a, b, c;
cin >> a >> b >> c;
int flag = 0;
for (int i = 0; i < a.length(); i++) {
if ((a[i] == c[i]) || (c[i] == b[i])) {
} else {
flag = 1;
}
}
if (flag) {
... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
long long n, p[N], tp;
bool vld;
char c;
string s;
string::iterator it;
void solve() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> p[i];
getline(cin, s);
vld = 1;
for (int i = 1; i <= n; i++) {
getline(cin, s);
tp = 0;
for (it = s.... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 61;
const long long mod = 1000000007;
const int maxn = 3e5 + 10;
long long c[maxn], a[maxn];
priority_queue<pair<long long, int> > que;
int main() {
std::ios::sync_with_stdio(false);
int n, k;
long long sum = 0, ans = 0;
;
scanf("%d%d"... | 3 |
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>> a >> b;
int ans=0;
if (12<a) ans=b;
else if (6<=a) ans=b/2;
cout<< ans <<endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, r;
cin >> n >> r;
int a[2222] = {0}, x = 0, ans = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i]) x++;
}
if (x * (2 * r - 1) < n)
cout << -1;
else {
int t = 0;
int x = -1;
for (int i = r - 1; i >= 0; i--) {
... | 2 |
#include <bits/stdc++.h>
using namespace std;
vector<long long> ans;
long long pw[205];
set<long long> stc[2], str[2];
map<long long, vector<long long>> mpc[2], mpr[2];
long long cur;
void bct(vector<long long> v) {
if (v.size() == 1) {
long long hsh = 0;
ans[v[0]] = 1;
for (long long i = 1; i < ans.size(... | 5 |
#include <bits/stdc++.h>
using namespace std;
int l, k;
char s[100050];
char fb[14][4];
int bad[26];
int dp[100050][26] = {0};
inline void relax(int &x, int val) {
if (val > x) x = val;
}
int main(void) {
scanf("%s", s);
scanf("%d", &k);
memset(bad, -1, sizeof(bad));
for (int i = 0; i < k; i++) {
scanf("%... | 1 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
void itval(istream_iterator<string> it) {}
template <typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args)... | 3 |
#include <bits/stdc++.h>
using namespace std;
int a[666666], b[666666], x, y, l, r, m[666666], i, n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (i = 1; i <= n; i++) {
cin >> x >> y;
m[x] = i;
m[y] = i;
if (x > y) {
l++;
a[l] = x;
... | 4 |
#include<iostream>
using namespace std;
int N,Y;
int main(void){
cin>>N>>Y;
Y=Y/1000;
for(int i=0;i<=N;i++)
for(int j=0;j<=N-i;j++)
if(i*10+j*5+(N-i-j)==Y){
cout<<i<<' '<<j<<' '<<N-i-j;
return 0;
}
cout<<"-1 -1 -1";
return 0;
} | 0 |
#include<stdio.h>
int main()
{
int N,M,P,i;
while(scanf("%d%d%d",&N,&M,&P),N)
{
int a[101]={0},s=0;
for(i=1;i<=N;++i)scanf("%d",&a[i]),s+=a[i];
if(a[M])printf("%d\n",s*(100-P)/a[M]);
else puts("0");
}
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
string s;
char limit;
bool solve(int n) {
if (n == -1) return 0;
for (int i = 1;; ++i) {
if (s[n] + i >= limit) break;
if (n > 0 && s[n - 1] == s[n] + i) continue;
if (n > 1 && s[n - 2] == s[n] + i) continue;
s[n] += i;
return true;
}
if (!solve(... | 3 |
// C - Traveling
#include <bits/stdc++.h>
using namespace std;
int main(){
int N; cin>>N;
bool ans=true;
for(int i=0; i<N; ++i){
int t,x,y; cin>>t>>x>>y;
if(t%2 != (x+y)%2){ ans = false; break; }
else if(t < x+y){ ans = false; break; }
}
cout<< (ans?"Yes":"No") <<endl;
} | 0 |
#include <bits/stdc++.h>
const long long inf = 1e9;
const double eps = 1e-9;
const long long infll = 1e18;
const long long mod = 1e9 + 7;
const long long N = 1001;
using namespace std;
vector<vector<long long> > g, gi, gt;
vector<vector<long long> > dp;
vector<long long> a, b;
vector<long long> u, d;
inline long long s... | 5 |
#include <bits/stdc++.h>
using namespace std;
char S[100];
int n, sum, f[1 << 22], a[200200], bin[100];
int get() {
int ret = 0, l = strlen(S + 1);
for (int i = 1; i <= l; i++) ret = (ret << 1) + S[i] - '0';
return ret;
}
void Min(int &a, int b) {
if (a > b) a = b;
}
int main() {
scanf("%d", &n);
for (int i... | 5 |
#include<bits/stdc++.h>
using namespace std;
int k,s,cnt;
int main()
{
cin>>k>>s;
for(register int x=0;x<=k;x++)for(register int y=0;y<=k;y++) if(s-x-y>=0&&s-x-y<=k) cnt++;
cout<<cnt<<endl;
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int n;
int arr[810][810];
int maxx = 0;
int p, q;
int d[1000];
int main() {
cin >> n;
for (int i = 2; i <= 2 * n; i++) {
for (int j = 1; j < i; j++) cin >> arr[i][j];
}
for (int k = 1; k <= n; k++) {
for (int i = 0; i <= 2 * n; i++) {
for (int j = 0; j... | 2 |
#include <bits/stdc++.h>
using namespace std;
long long powermodm(long long x, long long n, long long M) {
long long result = 1;
while (n > 0) {
if (n % 2 == 1) result = (result * x) % M;
x = (x * x) % M;
n = n / 2;
}
return result;
}
const long long N = 2e5 + 5;
const long long M = 1e2 + 5;
const l... | 6 |
#include <bits/stdc++.h>
using namespace std;
int n, m, k, f[1005][1005], a, b, sum;
int x[1005], y[1005], r[1005], rx[1005], ry[1005];
bool cal(int i, int j) {
return (long long int)(x[i] - rx[j]) * (x[i] - rx[j]) +
(long long int)(y[i] - ry[j]) * (y[i] - ry[j]) <
(long long int)r[j] * r[j];
}
... | 4 |
#include<iostream>
#include<string>
#define NUM 26
using namespace std;
int gcd(int a, int b){
if(a%b){
return gcd(b, a%b);
}
return b;
}
int main(){
int a, y, b, n, i, j, k, fy;
int ay[257];
string str, tmpstr;
cin>>n;cin.ignore();
for(i=0;i<n;i++){
getline(cin, str);
y=0;
tmpstr = str;
while(true)... | 0 |
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;
int main(){
int n;
map<int,int> p;
int mx = 0;
while( cin >> n){
mx = max(mx,++p[n]);
}
for(auto i : p )
if( mx == i.second ) cout << i.first << endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
int a[n + 1];
int b[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
int s = 0;
for (int i = 1; i <= n; i++) {
if (... | 1 |
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double PI = acos(-1.0);
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
long long N, K, L, M;
struct matrix {
long long m[2][2];
} ji;
matrix m_cheng(matrix x, matrix y) {
matrix ans;... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500007;
int n, t, cH, cS;
char a[maxn];
bool check(int v) {
stack<int> mystack;
int prev;
int c = v, cost = 0, pos = -1;
for (int i = 0, _a = (n); i < _a; ++i)
if (a[i] == 'S') {
if (mystack.empty()) {
c++;
} else {
p... | 2 |
#include <bits/stdc++.h>
using namespace std;
vector<long long> ans;
long long root(long long x) {
long long left = 0, right = 1e9;
long long mid, ans;
while (left <= right) {
mid = (left + right) >> 1;
if (mid * mid <= x) {
ans = mid;
left = mid + 1;
} else
right = mid - 1;
}
re... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2500, M = 1000000;
int a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int k;
cin >> k;
if (k <= M) {
cout << "1\n" << -k << endl;
return 0;
}
int n = 1501, d = 125000;
while ((k + d) % 1500) {
++d;
}
int c =... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int LINF = -1 * 1e6;
char str[1003], a[53], b[53];
int len, alen, blen;
int dp[1003][53][53];
int api[53], bpi[53];
void getpi(const char s[53], int *pi, int tlen) {
int j = 0;
for (int i = 2; i <= tlen; i++) {
while (j > 0 && s[j + 1] != s[i]) j = pi[j];
... | 4 |
#include <iostream>
using namespace std;
const int N = 8;
int rows[8];
bool cols[8];
bool dpos[15];
bool dneg[15];
bool skip[8];
void displayBoard(){
for(auto i = 0; i < N; ++i){
for(auto j = 0; j < N; ++j){
if(j == rows[i] && cols[j]) cout << 'Q';
else cout << '.';
}
cout << endl;
}
}
void putQueen(i... | 0 |
#include <bits/stdc++.h>
using namespace std;
double P[110], PP, PP2, MAX;
int n;
int main() {
int i, j;
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%lf", &P[i]);
sort(P, P + n);
if (P[n - 1] == 1.0) {
printf("%.13lf\n", 1.0);
return 0;
}
for (i = 0; i < n; i++) {
PP = 1;
PP2 = 0;
... | 2 |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long maxn = 3e6;
const long long mod = 1e9 + 7;
const long double PI = acos((long double)-1);
long long pw(long long a, long long b, long long md = mod) {
long long res = 1;
while (b) {
... | 6 |
#include <bits/stdc++.h>
using namespace std;
int r, b;
int points[2][20][2] = {0};
bool flag = false;
int cha(int x, int y, int x2, int y2) {
if ((x * y2 - x2 * y) > 0)
return 1;
else
return -1;
}
bool connect(int i, int j, int a[]) {
int x[2][2] = {0};
int y[2][2] = {0};
x[0][0] = points[0][i][0];
... | 5 |
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,l,m=-1e9,n,s,w,z,c[5040],p[5040],v[5040],x[5040],y[5040];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
for(;i++<n;)cin>>p[i];
for(i=0;i++<n;)
{
cin>>c[i];
m=max(m,c[i]);
}
for(i=0;... | 0 |
#include <bits/stdc++.h>
using namespace std;
int isp[10000089], T = 0;
vector<long long> primes;
void prime_gen() {
primes.push_back(2);
T = 1;
for (long long i = 3; i <= 10000079; i += 2) {
if (!isp[i]) {
primes.push_back(i);
for (long long j = i * i; j <= 10000079; j += i) {
isp[j] = 1;... | 1 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int a, b; cin >> a >> b;
string s; cin >> s;
int n = a + b;
if (n % 2 == 0 && a % 2 == 1 && b % 2 == 1) {
cout << "-1\n";
return;
}
for (char c : s) {
if (c == '0') a -= 1;
else if (c == '1') b -= 1;
if (a < 0 || b < 0) {
cout << "-1\n";
... | 3 |
#include <bits/stdc++.h>
using namespace std;
int ans[200005];
int n, val;
struct node {
int l, r;
int len;
node(int lll, int rr, int llen) {
l = lll;
r = rr;
len = llen;
}
friend bool operator<(const node &a, const node &b) {
if (a.len == b.len) return a.l > b.l;
return a.len < b.len;
}... | 4 |
#include <bits/stdc++.h>
using namespace std;
vector<int> v[300005];
int col[300005], cnt, m;
bool comp(vector<int> x, vector<int> y) {
if (x.size() != y.size()) return x.size() > y.size();
int mn = min(x.size(), y.size());
for (int i = 0; i < mn; i++)
if (x[i] < y[i])
return 1;
else
return 0;... | 5 |
#include <bits/stdc++.h>
using namespace std;
template <class _Tp>
void ckmax(_Tp &a, _Tp b) {
if (a < b) a = b;
}
template <class _Tp>
void ckmin(_Tp &a, _Tp b) {
if (a > b) a = b;
}
template <class _Tp>
_Tp gcd(_Tp a, _Tp b) {
return (b == 0) ? (a) : (gcd(b, a % b));
}
int read() {
char ch = getchar();
bool... | 5 |
#include <bits/stdc++.h>
using namespace std;
template <class T>
void ckmin(T &a, T b) {
a = min(a, b);
}
template <class T>
void ckmax(T &a, T b) {
a = max(a, b);
}
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);
void solve() {
int n, k;
string s;
cin... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long a[7];
long long t1, t2, t3, t4;
long long ans;
void work() {
for (int i = 1; i <= 6; i++) cin >> a[i];
t1 = min(a[1], a[5]);
t2 = min(a[2], a[4]);
t3 = max(a[1], a[5]) - t1;
ans = (a[6] + (t1 + a[6] - 1)) * (t1) + t1;
ans += (a[3] + (t2 + a[3] - 1)) * ... | 1 |
#include <bits/stdc++.h>
using namespace std;
char s[200003];
int n, num[200003];
int main() {
gets(s);
int len = strlen(s);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int k;
scanf("%d", &k);
num[k]++;
}
for (int i = 1; i <= len / 2; i++) num[i] += num[i - 1];
for (int i = 0; i < len; i++... | 2 |
#include <bits/stdc++.h>
using namespace std;
long long int n, a[200005], used[200005];
string s1, s2;
long long int ok(long long int x) {
memset(used, 0, sizeof(used));
for (long long int i = 0; i < x; i++) used[a[i]] = 1;
long long int cnt = 0;
for (long long int i = 0; i < n; i++) {
if (!used[i] && s1[i]... | 4 |
#include <bits/stdc++.h>
using namespace std;
double dp[210][210][210 * 2];
int p[210], a[210];
inline int fix(int x, int bb) {
if (x < 0) return x;
if (x >= bb) return bb - 1;
return x;
}
int main() {
int i, j, k, l, n, r;
cin >> n >> l >> k;
for (i = 1; i <= n; i++) cin >> p[i];
for (i = 1; i <= n; i++)... | 4 |
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<functional>
#include<stack>
#include<list>
#include<set>
#include<deque>
#include<climits>
using namespace std;
typedef long long ll;
int main(){
int N;
... | 0 |
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
bool vis[100005][2];
pair<int, int> path[100005][2];
bool draw = false;
void bfs(int v) {
queue<pair<int, int> > q;
q.push(make_pair(v, 0));
vis[v][0] = true;
path[v][0] = {-1, -1};
int it = 0;
while (!q.empty() && it < 2e6) {
int x =... | 2 |
#include <bits/stdc++.h>
using namespace std;
inline int Read() {
int x(0), f(1);
char c(getchar());
while (c < '0' || '9' < c) {
if (c == '-') {
f = -1;
}
c = getchar();
}
while ('0' <= c && c <= '9') {
x = (x << 1) + (x << 3) + c - '0';
c = getchar();
}
return f * x;
}
void Wri... | 2 |
#include <bits/stdc++.h>
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:367077216")
using namespace std;
const long double EPS = 1e-9;
const long double PI = acos(-1);
int mod = (int)998244353;
const int MOD7... | 5 |
#include <bits/stdc++.h>
using namespace std;
int n;
int a[2000];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", a + i);
}
sort(a, a + n);
printf("%d ", a[n - 1]);
for (int i = 1; i < n - 1; i++) {
printf("%d ", a[i]);
}
printf("%d\n", a[0]);
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
long long int power(int a, int b) {
long long int t;
if (b == 0)
return 1;
else if (b == 1)
return a;
else if (b % 2) {
t = power(a, b / 2);
t *= t;
t %= 1000000007;
t *= a;
t %= 1000000007;
return t;
} else {
t = power(a, b / 2... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x;
cin >> x;
printf("%.9lf\n", x*x*x/27.0);
return 0;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5;
int pr[maxn];
int cnt[6][6][200000];
void precalc() {
for (int i = 2; i * i <= maxn; i++)
if (pr[i] == 0) {
for (int j = i * i; j <= maxn; j += i) pr[j] = i;
}
for (int len = 1; len <= 5; len++) {
int fin = 1;
for (int j ... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int N = 3000;
int n, m, x, y;
vector<int> g[N];
int d[N][N];
int s1, t1, l1;
int s2, t2, l2;
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> x >> y;
x--, y--;
g[x].push_back(y);
g[y].push_back(x);
}
for (int i = 0; i < n; i++)
... | 4 |
#include <iostream>
using namespace std;
int main(){
int cnt, a, b, tmp;
while(cin>>a>>b){
cnt=0;
tmp=a+b;
while(tmp>0){
cnt++;
tmp/=10;
}
cout<<cnt<<endl;
}
} | 0 |
#include<bits/stdc++.h>
using namespace std;
int N, C;
int A[401], B[401];
long long ptable[401][401]; //dp a, b = 1^b + ... + a^b
long long dp[401][401];
const int MOD = 1e9+7;
void init()
{
for(int b=0; b<=400; ++b)
{
for(int a=1; a<=400; ++a)
{
long long x = 1;
for... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10, K = 1e6 + 10;
int n, m, k, p;
long long rowSum[N], colSum[N];
long long rowGain[K], colGain[K];
priority_queue<long long> rowPQ, colPQ;
long long ans = LLONG_MIN;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
scanf("%d%d%d%d", &n, &m, &k, &... | 2 |
#include<cstdio>
#include<algorithm>
#include<ctype.h>
#define int long long
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int T,n,k,a[100005],ans;
bool check(int x)
{
fo... | 2 |
#include <bits/stdc++.h>
using namespace std;
char func(char a) {
if (a == 'a') return 'b';
return 'a';
}
int main() {
int n, ans = 0;
cin >> n;
string s;
cin >> s;
for (int i = 1; i < n; i += 2) {
if (s[i] == s[i - 1]) {
ans++;
s[i] = func(s[i]);
}
}
cout << ans << endl;
cout <<... | 1 |
#include <bits/stdc++.h>
using namespace std;
int ans;
int main() {
int n, b = 0, c = INT_MAX;
cin >> n;
int a[n];
for (int z = 0; z < n; z++) {
cin >> a[z];
b = max(b, a[z]);
c = min(c, a[z]);
}
cout << max(0, b - c - (n - 1));
}
| 1 |
#include<iostream>
using namespace std;
int main() {
int W, H, C, divisor, bolck_sum, ans;
cin >> W >> H >> C;
/* 回数を減らすために少ない方に入れ替える */
if (W >= H)swap(W, H);
for (int i = 1; i <= W; i++) {
if (W % i == 0) { /* 約数を求める */
divisor = i;
if (H % divisor == 0) bolck_sum = divisor * divisor; /* 求めた約数から正... | 0 |
#include <bits/stdc++.h>
inline unsigned long long gen(unsigned long long x) {
return x ^= x << 13, x ^= x >> 7, x ^= x << 17;
}
std::map<unsigned long long, unsigned long long> map = {
{12807924072251749236, 25},
{8316942776798443357, 125},
{1427138097708291513, 230},
{13880348951595021113, 120},
... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 10;
int main() {
int n;
while (~scanf("%d", &n)) {
int a[M], dp[M], s[M];
int res = 0;
memset(s, 0, sizeof(s));
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n; i++) {
s[a[i]] = 1;
if (s[a[i]... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 2e5 + 4;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
void input() {}
int main() {
fastio();
input();
int n;
cin >> n;
int a[n + 1];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (a[0] != 25) {
... | 1 |
#include <bits/stdc++.h>
using namespace std;
long long int pd(long long int x, long long int y) {
if (x % y == 0)
return x / y;
else
return x / y + 1;
}
long long int mdls(long long int x) { return max(x, -x); }
long long int pow1(long long int n, long long int p) {
if (p == 0) return 1;
long long int ... | 2 |
#include<iostream>
using namespace std;
int main(){
int n;
cin >> n;
for(int i=0;i<n;i++){
int a,b,c;
cin >> a >> b >> c;
if((a*a+b*b==c*c)||(b*b+c*c==a*a)||(c*c+a*a==b*b))
cout << "YES" << endl;
else cout << "NO" << endl;
}
} | 0 |
#include <bits/stdc++.h>
using namespace std;
vector<long long> d1;
vector<long long> d2;
struct Point {
long long x, y;
};
bool check(Point p1, Point p2, Point p3) {
if (p1.x == p2.x) {
long long miny = min(p1.y, p2.y);
long long maxy = max(p1.y, p2.y);
if (p3.y <= miny || p3.y >= maxy) {
return ... | 4 |
#include<bits/stdc++.h>
using namespace std;
const int M=100017;
bool book[510][510];
int n,m,a[M],b[M];
bool vis[510];
int main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
cin>>a[i]>>b[i];
}
for(int i=1;i<=n;i++){
book[i][i]=1;
for(int j=m;j>=1;j--){
bool x=book[i][a[j]],y=book[... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, m, w, i, step, Max;
int a[100000 + 5], sum[100000 + 5];
bool ok(int l) {
int crt, m2;
m2 = m;
for (int j = 1; j <= n; ++j) sum[j] = 0;
for (int j = 1; j <= n; ++j) {
sum[j] += sum[j - 1];
if (sum[j] + a[j] >= l) continue;
crt = sum[j] + a[j];
... | 3 |
#include <bits/stdc++.h>
const int N = 2e5 + 54;
int n, a[N], s[N];
long long ans;
int main() {
std::cin >> n;
for (int i = 1; i <= n; ++i) std::cin >> a[i], ++s[a[i]];
for (int i = 1; i <= n; ++i)
if (s[i]) ans += (long long) s[i] * (s[i] - 1) / 2;
for (int i = 1; i <= n; ++i) {
std::cout << ans - s[a[i]] + 1... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 20000;
long long int inf = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;
vector<pair<int, int> > adj[maxn];
vector<pair<int, pair<int, int> > > sadj[maxn];
vector<pair<pair<int, int>, pair<int, int> > > E;
long long int d[maxn];
int mark[maxn];
void mul_dij(in... | 5 |
#include<iostream>
using namespace std;
int main(){
int d;
cin>>d;
cout<<d/30<<" "<<(d%30)*2<<endl;
return 0;
}
| 0 |
#include<iostream>
#include<string>
using namespace std;
int main(){
string bg[8]={"AAA","AA","A","B","C","D","E","NA"};
double m500[7]={35.5,37.5,40.0,43.0,50.0,55.0,70.0};
double m1000[7]={71.0,77.0,83.0,89.0,105.0,116.0,148.0};
double a,b;
while(cin >> a && cin >> b){
int ans=7;
for(int i=0;i<7;i+... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1E6 + 10;
int a[MAXN];
struct range {
int bg, ed, step;
range(int a, int b, int c) {
bg = a;
ed = b;
step = c;
}
int next() { bg += step; }
int end() { return bg > ed; }
int now() { return bg; }
};
int getAns(long long n, long long k... | 2 |
#include <bits/stdc++.h>
using namespace std;
int l[5];
int r[5];
int s[5];
int p[5];
int main() {
for (int i = 0; i < 4; i++) {
cin >> l[i] >> s[i] >> r[i] >> p[i];
}
for (int t = 0; t < 4; t++) {
if (p[t] == 1) {
if (l[(t + 1) % 4] == 1 || s[(t + 2) % 4] == 1 || r[(t + 3) % 4] == 1) {
cout... | 1 |
#include <bits/stdc++.h>
using namespace std;
struct Node {
int v, kd;
char s[20];
} a[100010];
int n, m;
bool cmp(Node x, Node y) {
if (x.kd == y.kd) {
return x.v > y.v;
}
return x.kd < y.kd;
}
int main() {
scanf("%d %d\n", &n, &m);
for (int i = 1; i <= n; i++) {
scanf("%s %d %d", a[i].s, &a[i].k... | 2 |
#include <bits/stdc++.h>
using namespace std;
std::map<long long, long long> mp, love, mp1, fucklove;
std::vector<long long> v[1000001], v1[1000001];
void dfs(long long a, long long c) {
love[a] = c;
mp[a] = 1;
for (long long i = 0; i < v[a].size(); ++i) {
if (mp[v[a][i]] == 0) dfs(v[a][i], c);
}
}
void dfs... | 4 |
#include <bits/stdc++.h>
using namespace std;
pair<int, int> pega[200005];
int peg[200005], id[200005], rev[200005];
int main() {
ios::sync_with_stdio(false);
int n, q, p;
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> pega[i].first;
pega[i].second = i;
}
sort(pega + 1, pega + n + 1);
for (i... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
int position = n - a, tot_pos;
if (position - 1 <= b) {
position = n - a;
} else {
position = b + 1;
}
cout << position << endl;
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int d, n;
int a[N];
int ans = 0;
int cnt[N];
vector<int> g[N];
void dfs(int v, int id, int p = -1) {
cnt[v] = 1;
for (int j = 0; j < g[v].size(); ++j) {
int to = g[v][j];
if (a[to] > a[id] || to == p) continue;
if ((a[to] == a[id] && to >... | 4 |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int s = 0, t = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') t = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
return s * t;
}
const int N = 1e5 +... | 5 |
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
temp... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int n, k, a, b;
vector<int> v;
int ret(int lt, int rt) {
int id2 = upper_bound(v.begin(), v.end(), rt) - v.begin();
int id1 = lower_bound(v.begin(), v.end(), lt) - v.begin();
return id2 - id1;
}
long long dfs(int lt, int rt) {
int nm = ret(lt, rt)... | 3 |
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
cin >> N;
if (N % 2 == 1) {
cout << (N - 1) / 2 << "\n";
return 0;
}
int msb = 30;
for (; msb >= 0; msb--)
if ((N & (1 << msb))) break;
cout << (N - (1 << msb)) / 2 << "\n";
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 200004;
int n, a[N], ans = 1;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
int res = 1, i = 1;
while (i < n) {
if (a[i] * 2 >= a[i + 1])
res++;
else
res = 1;
ans = max(ans, res);
i... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;
const int MAXL = 19;
const int MOD = 998244353;
const int RT = 3;
struct eT {
void setd(int _u, int _v,... | 6 |
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
cin >> n;
int i = 2;
while (i <= n) {
if (n % i == 0) {
cout << i;
n = n / i;
}
i++;
}
if (n != 1) cout << n;
}
| 2 |
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9;
struct edge {
int to, cost;
};
using edges = vector<edge>;
using graph = vector<edges>;
int main() {
int C, N, M, S, D;
while(cin >> C >> N >> M >> S >> D, N) {
S--; D--;
graph g(N);
for(int i=0; i<M; ++i) {
... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, m;
int tot, h[105];
int f[105][105][30];
struct node {
int to, nxt, v;
} e[5005];
void add_edge(int x, int y, int v) {
e[++tot].to = y;
e[tot].v = v;
e[tot].nxt = h[x];
h[x] = tot;
}
int dfs(int x, int y, int c) {
if (f[x][y][c] != 0) return f[x][y][c];
... | 2 |
#include <bits/stdc++.h>
using namespace std;
long long n, r, avg;
class woca {
public:
long long p;
long long b;
} F[100005];
bool CMP(woca A, woca B) {
if (A.b < B.b) return 1;
return 0;
}
long long tot = 0;
double temp = 0.0;
long long ANS = 0;
int main() {
int i;
scanf("%I64d%I64d%I64d", &n, &r, &avg);... | 3 |
// D - 3N Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
int main(){
int N; cin>>N;
vector<ll> A(3*N);
rp(i, 3*N) cin>>A[i];
vector<ll> F(3*N);
F[0] = A[0];
priority_queue<int> fque;
fque.push(-A[0]);
for(... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300864;
struct sam {
sam *son[26], *pre;
int len;
long long cnt;
void init() {
memset(son, 0, sizeof(son));
pre = 0;
len = 0;
cnt = 0;
}
} que[maxn], *root, *tail, *b[maxn];
int tot;
void initt() {
tot = 0;
tail = root = &que[t... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int n;
int ta[N], tc[N], ret;
int a[N], b[N];
void update(int i, long long v) {
for (v -= ta[i], ta[i++] += v; i <= n;
tc[i - 1] += v, i += ((i) & ((i) ^ ((i)-1))))
;
}
int query(int i) {
for (ret = 0; i; ret += tc[i - 1], i ^= ((i) & ... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.