text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; long long arr[105], k; int n; bool check(long long x) { long long sum = 0; for (int i = 0; i < n; i++) { sum += (arr[i] + x - 1LL) / x; } return x * sum <= k; } int main(int argc, char const *argv[]) { cin >> n >> k; for (int i = 0;...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:04:15 03/13/2015 // Design Name: // Module Name: PreProcessX // Project Name: // Target Devices: // Tool versions: // Description: // // Dep...
#include <bits/stdc++.h> using namespace std; bool ch1(int t, int da, int db, int a, int b, int x) { for (int i = 0; i <= t - 1; i++) { for (int j = 0; j <= t - 1; j++) { if (((a - i * da + b - j * db == x) && (a - i * da >= 0 && b - j * db >= 0)) || a - i * da == x || b -...
#include <bits/stdc++.h> int main() { int n, i, cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt5 = 0, cnt6 = 0; char x[10]; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %s , x); if (x[0] == p ) { cnt1++; } else if (x[0] == g ) { cnt2++; } else if (x[0] == b ...
#include <bits/stdc++.h> using namespace std; long long n, q, a[300010], f[300010], ans[300010], g[300010]; struct edge { long long v, next; } e[300010 << 1]; long long eid, p[300010]; void insert(long long u, long long v) { e[++eid] = {v, p[u]}; p[u] = eid; } long long dep[300010], cnt, c[3...
#include <bits/stdc++.h> using namespace std; const int MAX_ROW = 2000 + 7; const int MAX_COLUMN = 200 + 7; const int BASE = 2807; const int MOD = 1e7 + 7; int n, m; char TableA[MAX_ROW][MAX_COLUMN], TableB[MAX_COLUMN][MAX_ROW]; int HashA[MAX_ROW][MAX_COLUMN], HashB[MAX_COLUMN][MAX_ROW], Pow2807[MAX_ROW...
/* ORSoC GFX accelerator core Copyright 2012, ORSoC, Per Lenander, Anton Fosselius. CLIPPING/SCISSORING MODULE This file is part of orgfx. orgfx is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either...
#include <bits/stdc++.h> using namespace std; const int N = 100100, M = 32401000, S = 90, oo = 1000000000; int i, j, k, n, m, ch, ff; int s[N]; int F[M]; void R(int &x) { ff = x = 0; while (ch < 0 || 9 < ch) { if (ch == - ) ff = 1; ch = getchar(); } while ( 0 <= ch && ch <=...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright (c) 1998 Philips Semiconductors () * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your optio...
module problem3(out, in1, in2); output [9:0] out; input [4:0] in1, in2; wire [4:0] pp1, pp2, pp3, pp4, pp5; wire c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26; wire s2, s4, s5, s7, s8, s9, s11, s12, s13, s15, s16, s17, s19, s20, s21, s23, s24, ...
#include <bits/stdc++.h> using namespace std; bool ask(int a, int b, int c, int d) { cout << ? << a << << b << << c << << d << endl; fflush(stdout); string response; cin >> response; if (response == BAD ) { exit(0); } else if (response == YES ) return true; e...
#include <bits/stdc++.h> using namespace std; int dx[] = {0, -1, 0, 1}; int dy[] = {1, 0, -1, 0}; int c[2010][2010], edge[2010]; long double s[2010], C[2010][2010]; int main(int argc, char *argv[]) { int n, k; scanf( %d%d , &n, &k); for (int i = (1); i <= (n); ++i) { C[i][0] = 1; for...
#include <bits/stdc++.h> size_t solve(const std::vector<std::string>& c) { const size_t n = c.size(); size_t count = 0; for (size_t i = 0; i < n; ++i) { for (size_t j = 0; j < n; ++j) { for (size_t k = j + 1; k < n; ++k) { if (c[i][j] == C && c[i][k] == C ) ++count; if...
#include <bits/stdc++.h> using namespace std; namespace jyy { const int mod = 998244353, N = 600010; const double eps = 1e-8; inline int read() { static int x = 0, f = 1; x = 0, f = 1; static char ch = getchar(); while (ch < 0 || ch > 9 ) { (ch == - ) ? f *= -1 : f; ch = getcha...
#include <bits/stdc++.h> using namespace std; int main() { int x, y, x1, y1, a, b, c, d, e; cin >> x >> y >> x1 >> y1; a = x1 - x; b = y1 - y; { if (a < 0) { c = (-1) * a; } else c = a; } { if (b < 0) { d = (-1) * b; } else d = b; ...
#include <bits/stdc++.h> using namespace std; int n, q, a[210000], b[210000]; int tree[210000]; char Getchar() { static char now[1 << 20], *S, *T; if (T == S) { T = (S = now) + fread(now, 1, 1 << 20, stdin); if (T == S) return EOF; } return *S++; } int read() { int x = 0, f =...
#include <bits/stdc++.h> using namespace std; void solve(long long int arr[], long long int n, long long int l) { for (int i = 1; i < n; i++) { arr[i] = min(arr[i], 2 * arr[i - 1]); } long long int exp[n]; for (int i = 0; i < n; i++) { exp[i] = 1LL << i; } long long int ans = LLO...
#include <bits/stdc++.h> using namespace std; string itos(int x) { stringstream ss; ss << x; return ss.str(); } int n, m, res, bestlone; map<string, vector<int> > m1; string str; int main() { ios_base::sync_with_stdio(false); cin >> n >> m; for (int i = 0, x; i < n; i++) { ci...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: player1.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ============================...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
// ============================================================================ // Copyright (c) 2010 // ============================================================================ // // Permission: // // // // Disclaimer: // // This VHDL/Verilog or C/C++ source code is intended as a design reference ...
/* * Copyright 2010, Aleksander Osman, . All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * con...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; string s; string p; int a[2005]; int A[2005]; int ans[2005]; int dp[2005][2005]; int main() { cin >> s >> p; memset(a, -1, sizeof(a)); a[0] = 0; for (int i = 0; i < s.size(); i++) { for (int j = p.size() - 1; j >= 0; j--) { if (...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; std::ostream& operator<<(std::ostream& os, pair<int, int> p) { os << p.first << , << p.second; return os; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long int l, r; ci...
#include <bits/stdc++.h> using namespace std; void sol(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; long long ml = 1, ans = 0; vector<int> ls(n); map<long long, int> pre, mp; mp[0] = 1; vector<long long> an; while (ml < 1e15) { ...
#include<bits/stdc++.h> #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 3e5 + 5; int n, m, X; ll A[maxn]; int par[maxn]; set<pair<ll, ii>> adj[maxn]; ...
#include <bits/stdc++.h> using namespace std; void solve(const vector<int>& pearl) { vector<pair<int, int>> ans; ans.reserve(pearl.size()); set<int> app; int l = 0; for (int i = 0; i < pearl.size(); i++) { int cur = pearl[i]; if (app.find(cur) != end(app)) { ans.push_back(mak...
/* lab2_part3.v - 4-bit to decimal (0..15) * * Copyright (c) 2014, Artem Tovbin <arty99 at gmail dot com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is ...
#include <bits/stdc++.h> using namespace std; int main() { long long int k; cin >> k; string str, s; cin >> str; s = str; for (long long int i = 1; i < k; i++) str = str + s; map<char, vector<long long int>> pos; long long int i = 0; for (auto c : str) { pos[c].push_back(i)...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int ans = 0; sort(a.begin(), a.e...
///////////////////////////////////////////////////////////////////// //// //// //// Discrete Cosine Transform, DCT unit block //// //// //// //// Author: Richard Herveille ...
// patterngenerator.v `timescale 1ns / 1ps module patterngenerator ( // avalon clock interface input csi_clock_clk, input csi_clock_reset, // avalon mm slave: status/control input avs_ctrl_address, input avs_ctrl_read, output [31:0]avs_ctrl_readdata, input avs_ctrl_write, input [31:0...
#include <bits/stdc++.h> using namespace std; const int n = 5000; const long long mod = 998244353; long long f[n + 10][n + 10]; int main() { int a, b, c; for (int i = 1; i < n + 10; i++) { for (int j = 1; j < n + 10; j++) { if (i == 1) f[i][j] = j + 1; else if (j < i) ...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; long long l = s.length(); vector<char> s1; long long pos = -1; for (long long i = 0; i < l; i++) { if (s[i] == a ) pos = i; else ...
/////////////////////////////////////////////////////////////////////////////// // // Project: Aurora Module Generator version 2.2 // // Date: $Date: 2004/11/08 16:19:25 $ // Tag: $Name: i+H-38+78751 $ // File: $RCSfile: channel_init_sm.ejava,v $ // Rev: $Revision: 1.1.6.2 $ ...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ `timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time uni...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
#include <bits/stdc++.h> int mat[1010][1010]; int counts = 0; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) scanf( %d , &mat[i][j]); } counts = 0; for (int i = 1; i <= n; i++) counts += mat[i][i]; counts %= 2; int m; scan...
// $Id: tc_cfg_bus_ifc.v 1833 2010-03-22 23:18:22Z dub $ /* Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of...
#include <bits/stdc++.h> using namespace std; int n, m, tot, a[100010], ans[100010]; vector<pair<int, int> > q[100010]; set<int> s; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1, l, x; i <= m; i++) { scanf( %d%d , &l, &x); q[l].empl...
#include <bits/stdc++.h> using namespace std; int32_t main() { long long t = 1; while (t--) { long long n, d; cin >> n >> d; vector<long long> temp(n); vector<long long> temp2(n); for (long long i = 0; i < n; i++) { cin >> temp[i]; } for (long long i = 0; i ...
#include <bits/stdc++.h> using namespace std; int sum(long int c) { int somme = 0; while (c) { somme = somme + c % 10; c = c / 10; } return (somme); } int main() { long int k, c = 19; cin >> k; while (k) { if (sum(c) == 10) k--; c += 9; } cout << c - 9...
#include <bits/stdc++.h> using namespace std; int n; string a; void convA() { int c = 0, r = 0; int i; for (i = 1; a[i] != C ; i++) { r *= 10; r += a[i] - 0 ; } i++; for (; i < a.size(); i++) { c *= 10; c += a[i] - 0 ; } vector<int> ans; while (c !=...
// // Copyright 2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
#include <bits/stdc++.h> using namespace std; const double Pi = acos(-1.0); const int Inf = 0x3f3f3f3f; const int MAXN = 2e5 + 10; inline int read() { register int x = 0, f = 1, ch = getchar(); while (!isdigit(ch)) f = ch == - ? -1 : 1, ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 48, c...
#include <bits/stdc++.h> using namespace std; int pp(int n) { for (int i = 2; i <= floor(sqrt(n)); i++) { if (n % i == 0) return i; } return 1; } void solve() { long long int n, k; cin >> n >> k; if (k > n) cout << max(0ll, n - k / 2) << endl; else cout << max(0ll, ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; struct Edge { long long int from, to, cap, flow, index; Edge(long long int from, long long int to, long long int cap, long long int flow, long long int index) : from(from), to(to), cap(cap), flow(flow), index(inde...
// part of NeoGS project // // (c) NedoPC 2007-2008 // // modelling is in tb_dma2.* module dma_sequencer( clk, rst_n, addr, wd, rd, req, rnw, ack, done, dma_req, dma_addr, dma_rnw, dma_wd, dma_rd, dma_ack, dma_end ); parameter DEVNUM = 4; input clk; input rst_n; input [20:0] addr [...
#include <bits/stdc++.h> using namespace std; void add(int& a, int b) { a += b; a = min(a, 100000000); } const int MX = 300005; int root[MX]; bool is_left[MX]; vector<int> nodes[MX]; int left_size[MX], right_size[MX]; int ans = 0; char s[MX]; vector<int> comps[MX]; int main() { int n...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, m, ans = 999999999999999999, mn = 123456789000LL; cin >> n >> m; long long x = n; vector<pair<long long, long long> > v; long long cnt = 0; for (long long i = 2; i <= sqr...
#include <bits/stdc++.h> using namespace std; vector<string> s; vector<pair<int, int> > v; int gf = 0; int x[9] = {-1, -1, -1, 0, 1, 1, 1, 0, 0}; int y[9] = {-1, 0, 1, 1, 1, 0, -1, -1, 0}; void dfs(int a, int b, int le) { if (gf) return; if (le == 8 || (a == 0 && b == 7)) { gf = 1; ret...
#include <bits/stdc++.h> int x, y, u, v, d = 1, a, b; int main() { for (scanf( %d%d , &a, &b); a; b /= 4, d *= 2, --a) { if (b % 4 == 0) u = y, v = x; else if (b % 4 == 1) u = x, v = y + d; else if (b % 4 == 2) u = x + d, v = y + d; else u = 2 * d - y - 1,...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
//-------------------------------------------------------------------------------- // transmitter.vhd // // Copyright (C) 2006 Michael Poppitz // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundati...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { if (x < y) swap(x, y); while (y > 0) { T f = x % y; x = y; y = f; } return x; } const int maxn = 100007; int BLOCKSIZE = 250; set<int> s[maxn]; int a[maxn]; int nxt[maxn]; int prv[...
#include <bits/stdc++.h> using namespace std; int max(int a, int b) { if (a > b) return a; else return b; } int main() { long int x, y, z, w, mx; cin >> x >> y >> z >> w; mx = max(w, max(z, max(x, y))); if (mx == w) { cout << (mx - z) << << (mx - y) << << (mx - ...
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> p1, pair<int, int> p2) { return (p1.first < p2.first) || (p1.first == p2.first && p1.second > p2.second); } int main() { bool b[200000]; int t[200000]; int n; cin >> n; for (int i = 1; i <= n; ++i) { c...
#include <bits/stdc++.h> using namespace std; namespace WorkSpace { const int max_num = 100010; unsigned int F[max_num >> 1]; void Main() { register int N; scanf( %d , &N); if (N & 1) { printf( 0 n ); return; } static char S[max_num]; register int Half = N >> 1; scanf( ...
#include <bits/stdc++.h> using namespace std; const int maxv = 1.5e7; const int bit = 29; int cnt[maxv] = {}; int go[maxv][2] = {}; int tot = 1; void add(int v, int d, int val) { cnt[v]++; if (d == -1) return; if (!go[v][(val >> d) & 1]) go[v][(val >> d) & 1] = ++tot; add(go[v][(val >> d) ...
// File: FullAdderViaHAs_TBV.v // Generated by MyHDL 0.10 // Date: Tue Aug 21 12:52:20 2018 `timescale 1ns/10ps module FullAdderViaHAs_TBV ( ); // myHDL -> Verilog Testbench for module "FullAdderViaHAs" reg x1 = 0; reg x2 = 0; wire s; wire c; wire [7:0] x1TVals; wire [7:0] x2TVals; reg cin = 0; wire [7:0] cinTVal...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:12:04 10/30/2011 // Design Name: M_uxa_ps2_fifo // Module Name: /Users/kc5tja/tmp/kestrel/2/nexys2/uxa/ps2io/T_uxa_ps2_fifo.v // Project Name: ps2io // Target Dev...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int i, a[n]; long long int c = 0, ans = 0; for (i = 0; i < n; i++) { cin >> a[i]; c += a[i]; } for (i = 1; i <= 5; i++) { if ((c + i) % (n + 1) != 1) ans++; } cout << ans << endl; re...
#include <bits/stdc++.h> using namespace std; int a, b, c, d, p; int main() { cin >> a >> b >> c >> d; d -= c - 1; a -= c; b -= c; if (d == 2) { a--; b--; p = 3; } if (d == 1) { if (a) { a--; p = 1; } else { b--; p = 2; ...
/* * Copyright (C) 2015-2016 Harmon Instruments, LLC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
module clock_display( in_clk, tens_hours, hours, tens_minutes, minutes, tens_seconds, seconds, segment_sel, seven_seg_out ); // ports input in_clk; input [3:0] tens_hours, hours, tens_minutes, minutes, tens_seconds, seconds; output [5:0] segment_sel; output [6:0] seven_seg_out; // registers and wires reg [5:...
`timescale 1 ns / 1 ps ////////////////////////////////////////////////////////////////////////////////// // Company: AGH UST // Engineer: Wojciech Gredel, Hubert Górowski // // Create Date: // Design Name: // Module Name: Player // Project Name: DOS_Mario // Target Devices: Basys3 /...
#include <bits/stdc++.h> using namespace std; using LL = long long; using pii = pair<int, int>; using UI = unsigned int; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const double EPS = 1e-8; const double PI = acos(-1.0); const int N = 5e5 + 10; const int M = N + (1 << 20); int n, a[N][2]; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int N = 2 * maxn; int n, m, a[maxn]; int v[N]; void jl(int x) { for (int i = x; i < N; i += i & -i) { v[i]++; } } long long s(int x) { long long sum = 0; for (int i = x; i > 0; i -= i & -i) { sum +=...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], i; double ans = 0.0f; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); if (n % 2 == 0) { for (i = 0; i < n; i = i + 2) { ans = ans + ((a[i + 1] * a[i + 1]) - (a[i] * a[i])); } ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a = 0, b = 1023, c, n; char op; cin >> n; for (int i = 0; i < n; ++i) { cin >> op >> c; switch (op) { case | : a |= c; b |= c; br...
////////////////////////////////////////////////////////////////////// //// //// //// OR1200's IC RAMs //// //// //// //// This file is part of the OpenR...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, x; cin >> n >> x; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { int k, l; cin >> k >>...
#include <bits/stdc++.h> using namespace std; int main() { string a, s; cin >> a >> s; sort(s.begin(), s.end()); reverse(s.begin(), s.end()); int k = 0; for (int i = 0; i < a.size() && i < s.size(); i++) { bool found = false; for (int j = k; j < a.size(); j++) { if (s[i] ...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
#include <bits/stdc++.h> using namespace std; char s[505][505]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf( %c , &s[i][j]); } } bool ok = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++)...
#include <bits/stdc++.h> using namespace std; const int N = 405; char mp[30], s[N], a[5], b[5]; int L, n, m, e[N][N], nxd[30], nxs[30], flg[30], lim[N], tmp[N], mx[2]; vector<int> ans; bool chk(int pos, int v, int x, bool ff) { if (lim[pos] != -1 && lim[pos] != flg[v]) return 0; for (int i = 1; i <=...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:22:18 05/13/2015 // Design Name: // Module Name: MemoryManagerUnit // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenci...
#include <bits/stdc++.h> using namespace std; const int N = 150, M = 150, OO = 0x3f3f3f3f; int n, arr[2005], temp, ans; void DFS(int u) { temp++; if (arr[u] == -1) return; DFS(arr[u]); } int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , arr + i); } fo...
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, x; cin >> n >> x; long long int a[n]; set<long long int> s; long long int sum = 0; for (long long int i = 0; i < n; i++) { cin >> a[i]; s.insert(a[i]); sum += a[i]; } long long int y = *(s...
#include <bits/stdc++.h> using namespace std; const int N = (1 << 18); const double PI = acos(-1.0); char s[N]; int lA, lB; int a[N], b[N]; int inB[110][N]; int S, B; struct cpx { double x, y; cpx(double p = 0, double q = 0) : x(p), y(q) {} cpx operator+(cpx &o) { return cpx(x + o.x, y + o...
#include <bits/stdc++.h> using namespace std; int tab[205]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> V; for (int i = 0; i < n; i++) { int x; cin >> x; tab[...
#include <bits/stdc++.h> #define int long long int const int INF = 1e9 + 7; using namespace std; const int m = 1e9 + 7; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; string a[n], b[n]; for (int i = 0; i < n;...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1005; int numb[MAXN], numw[MAXN]; int dp[MAXN][2]; string s[MAXN]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); for (int i = 0; i < MAXN; i++) dp[i][0] = dp[i][1] = -1; int n, m, x, y; cin >> n >> m ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int N = 200500; void solve() { long long n, k; cin >> n >> k; if ((n + k) % 2 == 0 && n >= k && (n + k) / 2 >= (k * (k + 1)) / 2) { cout << YES n ; } else cout << NO n ; } int main() { ios::s...
#include <bits/stdc++.h> using namespace std; int n, V[171]; void cauta(int p) { vector<pair<int, int> > Queries; int res, st = 2, dr = n; for (int m = dr; m >= st; --m) { cout << ? ; for (int i = 1; i <= n; ++i) { if (i != p) cout << 1 ; else cout <...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int N = 500, INF = 1 << 30; int nxt[N], a[N][N], n, x, Rank[N][N], now; char s[10]; queue<int> q; void init() { scanf( %d , &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf( %d , &a[i][j]); puts( B ); fflush(stdout...
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 // Date : Tue Sep 17 15:50:55 2019 // Host : varun-laptop running 64-bit Service Pac...
#include <bits/stdc++.h> int a[1000005]; double tt; int main() { int n, i, t; double vb, vs, x, y, d; while (scanf( %d %lf %lf , &n, &vb, &vs) != EOF) { t = 2; for (i = 1; i <= n; i++) { scanf( %d , &a[i]); } scanf( %lf %lf , &x, &y); d = a[2] / vb + sqrt((x - a[2...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-8; const int inf = 0x7FFFFFFF; template <class T> void show(T a, int n) { for (int i = 0; i < n; ++i) cout << a[i] << ; cout << endl; } template <class T> void show(T a, int r, int l) { for...
#include <bits/stdc++.h> using namespace std; signed main() { std ::ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; cin >> n; string s; cin >> s; long long a[2] = {0}; for (long long i = 0; i < n; i++) a[s[i] - 48]++; if (a[0] == a[1]) { cout ...