text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int a[200002], ans[200002]; int main() { int n, i, k = 0, sum = 0; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &a[i]); sum += a[i]; } for (i = 0; i < n; i++) { if (((sum - a[i]) / (n - 1) == a[i]) && ((sum - a[i]) % (n ...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) #pragma comment(linker, /STACK:2000000 ) using namespace std; template <int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, Vector dimension must be greater than zero! ); templ...
#include <bits/stdc++.h> using namespace std; vector<int> E[1 << 18]; pair<int, int> R[1 << 18]; int dfs(int a, int p, int d) { int cnt = 1; for (auto it = (E[a]).begin(); it != (E[a]).end(); ++it) { int b = *it; if (b == p) continue; cnt += dfs(b, a, d + 1); } R[a] = pair<int,...
#include <bits/stdc++.h> using namespace std; const int maxN = (int)2E5 + 5; int n, x, y; vector<int> Adj[maxN]; int deg[maxN]; bool avail[maxN]; bool marked[maxN]; int Count[maxN]; int DFS(int u) { marked[u] = true; Count[u] = 0; int cnt = 0; for (int i = 0, sz = Adj[u].size(); i < sz...
/** * 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> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize( Ofast ) using namespace std; namespace ywy { inline int get() { int n = 0; char c; while ((c = getchar()) || 23333) { if (c >= 0 && c <= 9 ) break; if (c == - ) goto s; } n = c ...
#include <bits/stdc++.h> using namespace std; int N, M, K; int color[200002]; vector<int> edge[200002]; int id[200002]; int ite = 1; int siz[200002]; map<int, int> m[200002]; int ans; void dfs(int a) { if (id[a]) { return; } id[a] = ite; for (int i = 0; i < edge[a].size(); i++)...
#include <bits/stdc++.h> using namespace std; const int N = 100100; pair<long double, long double> a[N]; int n; bool f(long double mid) { long double l[n], r[n]; multiset<pair<long double, int>> xex; for (int i = 0; i < n; i++) { l[i] = 1.0 * a[i].first - a[i].second * mid; xex.insert(...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:21:26 03/28/2014 // Design Name: // Module Name: cu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revi...
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include library/debug.cpp #else #define debug(...) #endif template <long long mod> struct modular { long long value; modular(long long x = 0) { value = x % mod; if (value < 0) value += mod; } modu...
`include "../lib/flip_flop.v" module reg_32bits ( input [31:0] d, input we, clk, output [31:0] q); d_flip_flop dff0 (.q(q[0 ]), .d(d[0 ]), .we(we), .clk(clk)); d_flip_flop dff1 (.q(q[1 ]), .d(d[1 ]), .we(we), .clk(clk)); d_flip_flop dff2 (.q(q[2 ]), .d(d[2 ]), .we(we), .clk(clk)); d_flip_flop dff3 (.q(...
/** * 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; vector<vector<int> > data; vector<vector<int> > sticks; vector<int> h; int dfs(int vertex, int last) { int longest = 0; for (int i = 0; i < data[vertex].size(); ++i) { int to = data[vertex][i]; if (to == last) continue; int len = dfs(to, ...
#include <bits/stdc++.h> using namespace std; template <class T> long long size(const T& x) { return x.size(); } template <class T> T smod(T a, T b) { return (a % b + b) % b; } long long n, k; vector<long long> X; vector<pair<long long, pair<long long, long long> > > A; vector<vector<long ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // Author: Yu-Sheng Lin // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Outputs state, // Inputs clk ); input clk; int cyc; reg rstn; output [4:0] state; ...
/* * 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; const int N = 1e3 + 10; struct ft_t { long long d[N], t[N]; void init() { memset(d, 0, sizeof(d)); memset(t, 0, sizeof(t)); } void put(long long x, long long k) { for (int i = x + 1; i < N; i += -i & i) d[i] ^= k; for (int i = x...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, a[N]; int cnt[N], odd, neg, sum; int f[N]; long long res; bool check(int L, int R) { for (int i = 1; i <= n; ++i) if (!(L <= (i) && (i) <= R) && !(L <= (n - i + 1) && (n - i + 1) <= R) && a[i] != a[n - i + 1]) ...
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) #pragma GCC optimize( unroll-loops ) using namespace std; const int MAX = 1e6 + 5; const long long MOD = 1000000007; struct state { int len, link, cnt; int nx[26]; } st[MAX << 1]; int id, last, cur; vector<int> v[MAX]; inline void sa_init()...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:20:24 02/22/2015 // Design Name: // Module Name: Add // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencie...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09:14:49 05/10/2016 // Design Name: // Module Name: prob_computer // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; const long long INFL = 1LL << 60; const long long INF = INFL; long long MOD = 1000000007; vector<long long> dy = {0, -1, 0, 1, 1, 1, -1, -1, 0}; vector<long long> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0}; void pres(double A, long long x = 10) { cout << fixed <<...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.4 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
`timescale 1ns/1ns `define LOG_EVENTS `define LOG_SAMPLES module fx2_timetag_bench(); reg clk; wire fx2_clk; wire [7:0] fd; wire [2:0] flags; wire [1:0] fifoadr; wire sloe, slrd, slwr, pktend; reg [3:0] strobe_in; wire [35:0] counter = uut.tagger.apdtimer.tagger.timer; // External Clock initial clk = 0; always #2...
#include <bits/stdc++.h> using namespace std; int main() { int n; while (~scanf( %d , &n)) { int cnt = 0; for (int i = 1; i < n; i++) { for (int j = i + 1; j < n; j++) { int sum = i * i + j * j; if (sum <= n * n) { if ((int)sqrt(sum) * (int)sqrt(sum) == su...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); string a, b; cin >> a >> b; if (a.size() == b.size()) { int ca = 0, cb = 0; for (int i = 0; i < a.size(); i++) { ca += a[i] == 1 ; cb += b[i] == 1 ; } if (!ca && cb || ca && ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Tecnológico de Costa Rica // Engineer: Juan José Rojas Salazar // // Create Date: 30.07.2016 10:22:05 // Design Name: // Module Name: Convert_Float_To_Fixed // Project Name: // Target Devices: // To...
module ALU ( input [31:0] in1, in2, input [5:0] ALUFun, input sign, output reg [31:0] out ); reg zero, overflow; wire negative; reg [31:0] out00, out01, out10, out11; reg nega; assign negative = sign&nega; always @ (*) begin case (ALUFun[0]) 1'b0: begin ...
#include <bits/stdc++.h> using namespace std; template <typename T> T In() { T x; cin >> x; return x; } int main() { ios::sync_with_stdio(false), cin.tie(0); cout << ((In<int>() & 1) ? Ehab : Mahmoud ); return cout << endl, 0; }
#include <bits/stdc++.h> using namespace std; uint64_t mat[5][5] = {{0, 0, 1, 0, 0}, {1, 0, 1, 0, 0}, {0, 1, 1, 0, 0}, {0, 0, 1, 1, 0}, {0, 0, 0, 1, 1}}; uint64_t ex[5][5] = {{0, 0, 0, 0, 0}, {0,...
#include <bits/stdc++.h> using namespace std; int a[4], i, n, x; int main() { for (cin >> n, i = 0; i < n; ++i) cin >> x, --x, a[0] += !x, a[1] = max(a[0], a[1] + x), a[2] = max(a[1], a[2] + !x), a[3] = max(a[2], a[3] + x); cout << a[...
#include <bits/stdc++.h> using namespace std; vector<int> adj[200005]; int visited[200005]; int dfs(int u) { visited[u] = 1; int iscycle = ((adj[u].size() == 2) ? (1) : (0)); for (int i = 0; i < adj[u].size(); ++i) { if (visited[adj[u][i]] == 0 and dfs(adj[u][i]) == 0) iscycle = 0; } r...
/** * 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> const int S = 400004; int last, tr[S][26], fail[S], len[S], tot = 0, eg = 1, h[S], nx[S << 1], v[S << 1], e[S]; char c[S]; void insert(int &last, char c) { c -= a ; int p = last, now = ++tot; len[now] = len[last] + 1; while (p != ...
/* * 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; int main() { int n, sum = 0, sum1 = 0; int x; cin >> n; for (int i = 0; i < (int)n - 1; ++i) { cin >> x; sum += x; } for (int i = 1; i <= n; i++) sum1 += i; cout << sum1 - sum << endl; return 0; }
#include <bits/stdc++.h> constexpr int P = 998244353; struct Matrix { int a[4]; Matrix() : a{} {} friend Matrix operator*(const Matrix &lhs, const Matrix &rhs) { Matrix res; res.a[0] = (1ll * lhs.a[0] * rhs.a[0] + 1ll * lhs.a[1] * rhs.a[2]) % P; res.a[1] = (1ll * lhs.a[0] * rhs.a[1] + ...
#include <bits/stdc++.h> using namespace std; const unsigned long long MOD = 1e8 + 7; const unsigned long long base = 71; const unsigned long long max_n = 2e5 + 400; unsigned long long n, m, k, q; string s; unsigned long long pw[2 * max_n + 200]; unsigned long long save[20][2 * max_n + 200]; unsigned ...
#include <bits/stdc++.h> using namespace std; int main() { int wall[110][110] = {0}; int r, c; scanf( %d %d%*c , &r, &c); char a[110]; for (int i = 1; i < r; i++) gets(a); int flag = 0; int seg = 0; for (int i = 0; i < c; i++) { char x; scanf( %c , &x); if (flag == ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09/27/2014 12:04:19 PM // Design Name: // Module Name: keyed_permutation // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; const int NMAX = 6100, EMAX = 13000, VMAX = 6100; struct Edge { int x; int y; int next; }; int N, R[NMAX], ans; short f[NMAX][NMAX], g[NMAX][NMAX]; int V[VMAX], eid; Edge E[EMAX]; void insert(int x, int y) { E[++eid] = (Edge){x, y, V[x]}; ...
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c; cin >> a >> b >> c; if (a >= c || b >= c) { cout << 0 ; } else if (a <= 0 && b <= 0) { cout << -1 ; } else { long long int count = 0; while (a < c && b < c) { if (a > b) { ...
// qmem_sram_tb.v // 2013, `timescale 1ns/10ps module qmem_sram_tb(); //// parameters //// parameter QAW = 32; // qmem adr width parameter QDW = 32; // qmem dat width parameter QSW = QDW/8; // qmem sel width parameter AD = 10; // allowed delay for qmem slave //// internal signals //// reg ...
#include <bits/stdc++.h> using namespace std; int x, k, n, q, cnt; long long num[10]; int bel[1 << 10]; struct Square { long long num[75][75]; Square() { for (int i = 1; i <= 70; i++) { for (int j = 1; j <= 70; j++) num[i][j] = 1e18; num[i][i] = 0; } } Square operat...
/* * 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; void start() {} int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long a, b; cin >> a >> b; if (a < b) swap(a, b); b = 2 * b; if (b >= a) cout << b * b ...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2015.4 // Copyright (C) 2015 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps mod...
#include <bits/stdc++.h> using namespace std; int points(int p, int t) { int first = 75 * p; int second = 250 * p - p * t; return max(first, second); } int main() { int a, b, c, d; scanf( %d %d %d %d , &a, &b, &c, &d); int misha = points(a, c); int vasia = points(b, d); if (misha...
#include<bits/stdc++.h> using namespace std; int main(){ int t,n,x; set<int> notes; cin>>t; while(t--){ cin>>n; notes.clear(); for(int i=0;i<n;i++){ cin>>x; if(notes.find(x)==notes.end()){ notes.insert(x); }else{ notes.insert(x+1); } } cout<<notes.s...
//Legal Notice: (C)2015 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int dis[40]; long long adj[40]; vector<long long> v1; vector<long long> v2; void bt(int l, int r, long long mask) { if (l == r) { v1.emplace_back(mask); return; } bt(l + 1, r, mask); if (adj[l] & mask) return;...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<int> d(5000, 0); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { ++d[abs(a[i] - a[j])]; } } ...
//***************************************************************************** // (c) Copyright 2009 - 2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property /...
#include <bits/stdc++.h> using namespace std; int n, a, i, j, sum, k; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> a; sum += a; j += 1 - 2 * a; if (j < 0) j = 0; if (k < j) k = j; } if (!k) { cout << sum - 1; } else { cout << sum + k; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n, t, k, x, d[200001] = {}, last_d = 1, last = 0, a; long long sum = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> t; if (1 == t) { cin >> a >> x; sum += a * x; if (last_d == 0) { last +=...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 3 * (n / 2); }
#include <bits/stdc++.h> const int INF = 1e9; using namespace std; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; bool vis[1005][1005], cvis[50]; vector<pair<int, int> > cc[50]; int m, n, k, a[1005][1005], D[45][1005][1005]; void DFS(int c) { memset(vis, 0, sizeof(vis)); memset(cvis, 0, siz...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:56:23 06/11/2014 // Design Name: // Module Name: DasBlinkenLights // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencie...
#include <bits/stdc++.h> using namespace std; using namespace std; long long ara[205]; long long dp[205][205][205]; int n, k, x; long long rec(int pos, int last, int left) { if (last > k) return -1e17; if (pos == n + 1) { if (!left) return 0; return (-1e17); } if (left < 0) retur...
/* * 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 "Global_Macros.v" module ALU( operation_i, status_i, operand1_i, operand2_i, status_o, result_o ); //Input signals : input wire [4:0] operation_i; input wire [7:0] status_i; input wire [15:0] operand1_i; input wire [15:0] operand2_i; //Output signals : out...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:60000000 ) using namespace std; const int MAXN = 10 + 100000; const int INF = int(1e9); const int m = 4; int k, t, d; int a[5][5], i, j, n; void nhap() { scanf( %d , &n); for (int i = (1), _b = (m); i <= m; ++i) scanf( %d%d%d%d , &a[...
#include <bits/stdc++.h> int main() { int n; int a[100000]; int l0, l1; int i, j; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &a[i]); } l0 = 0; l1 = 0; for (i = 1; i < n; i++) { if (a[i] >= a[i - 1]) { l1++; } if (a[i] < a[i - 1]) { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int get_next_state(bool s1, bool s2, bool b1, bool b2) { if (s1 && b1) { return -1; } if (s2 && b2) { return -1; } bool a1 = s1 | b1; bool a2 = s2 | b2; if ((a1 && a2) || (!a1 && !a2)) { retu...
module ALU ( input signed [15:0] DATA_A, DATA_B, input [3:0] S_ALU, output [15:0] ALU_OUT, output [3:0] FLAG_OUT); localparam IADD = 4'b0000; localparam ISUB = 4'b0001; localparam IAND = 4'b0010; localparam IOR = 4'b0011; localparam IXOR = 4'b0100; localparam ISLL = 4...
/** * 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...
/** 1. нужно сделать шинным(временным будет массив) 2. и длиной 1-N ноль - соединение напрямую - лучще вставлять в основной код v_shift_registers #( .DELAY(), .WIDTH(`WIDTH) )( .clk(clk), .rst(rst), .clk_ena(clk_ena), .si(), .so() ); */ `include "vconst_lib.v" /** abst. : сдвиговый рег...
#include <bits/stdc++.h> using namespace std; bool binary(vector<int> v, int key) { int lo = 0, hi = v.size() - 1; while (lo <= hi) { int mid = (lo + hi) / 2; if (v[mid] == key) return true; else if (v[mid] < key) lo = mid + 1; else hi = mid - 1; } ret...
module opc5cpu( input[15:0] datain, output [15:0] dataout, output[15:0] address, output rnw, input clk, input reset_b); parameter FETCH0=3'h0, FETCH1=3'h1, EA_ED=3'h2, RDMEM=3'h3, EXEC=3'h4, WRMEM=3'h5; parameter PRED_C=15, PRED_Z=14, PINVERT=13, FSM_MAP0=12, FSM_MAP1=11; parameter LD=3'b000, ADD=3'b001, AND=3...
#include <bits/stdc++.h> using namespace std; long long m, n, q; long long X; long long f(long long a) { long long b = X - 2, c = X, k, ans = 1; while (b > 0) { long long p = 1, k = a; while (p * 2 <= b) { p *= 2; k = k * k % c; } ans = ans * k % c; b -= p; ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2010 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs rst_sync_l, rst_both_l, rst_async_l, d, clk ); /*AUTOINPUT*/ // Beginning of automatic inputs (from unused autoin...
#include <bits/stdc++.h> char s[100], Ans[2000]; int n, m, ans, cnt, b[20], a[40][40], p[50], q[50], x[20][20]; void dfs(int c, int d) { if (d == 15) { memset(x, 0, sizeof(x)); for (int i = 1; i <= 28; i++) { if (x[b[p[i]]][b[q[i]]]) return; x[b[p[i]]][b[q[i]]] = x[b[q[i]]][b[p[i]]...
#include <bits/stdc++.h> using namespace std; const int N = 5001; const int B = 27; int zhu[B], n, m; char s[N], t[N]; void solve() { memset(zhu, 0, sizeof(zhu)); n = strlen(s); m = strlen(t); for (int i = 0; i < n; ++i) zhu[s[i] - a ]++; int r = -1, p; if (n > m) p = m; e...
/** * 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...
// DESCRIPTION: Verilog::PLI: Example Verilog code that will call perl // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module hello_top; initial begin // Set debug level $pli_debug(0); // Set to 7 for more verbosity // Setup the perl in...
//+FHDR------------------------------------------------------------------------ //Copyright (c) 2013 Latin Group American Integhrated Circuit, Inc. All rights reserved //GLADIC Open Source RTL //----------------------------------------------------------------------------- //FILE NAME : //DEPARTMENT : IC Design / Veri...
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f3f3f3f3f; int32_t main() { long long n; cin >> n; vector<long long> v1, v2; long long i, j, ans = 0; for (i = 0; i < n; i++) { long long len; cin >> len; bool fg = true; long long mi = INT_MAX...
/* * HIFIFO: Harmon Instruments PCI Express to FIFO * Copyright (C) 2014 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 * (a...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Xilinx // Engineer: Lisa Liu // // Create Date: 06/30/2014 03:42:37 PM // Design Name: // Module Name: rx_isolation // Project Name: // Target Devices: // Tool Versions: // Description: read back pre...
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int MOD = 1e9 + 7; int n; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed; cin >> n; int dp[] = {1, 0}; for (int i = 1; i < n; i++) dp[i % 2] = (dp[i % 2] + dp[1 - i % 2] + 1) % MOD; co...
/* * 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; const double inf = 1.0 / 0.0; const double pi = 2 * acos(0.0); map<char, int> tab, tab1; char x; int main() { tab1[ Q ] = 9; tab[ q ] = 9; tab1[ R ] = 5; tab[ r ] = 5; tab1[ B ] = 3; tab[ b ] = 3; tab1[ P ] = 1; tab[ p ] = 1; ...
#include <bits/stdc++.h> using namespace ::std; const long long maxn = 400; const long long mod = 1e9 + 7; const long long inf = 1e17 + 500; string s[maxn]; long long a[maxn]; string t; long long n; long long ger[maxn][maxn]; long long tvi[maxn][maxn]; long long sav[maxn][maxn]; long long tyu[ma...
/* ######################################################################## Generic small FIFO using distributed memory Caution: There is no protection against overflow or underflow, driving logic should avoid wen on full or ren on empty. ###############################################################...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; vector<int> v[maxn]; int vos[maxn]; int ans; void dfs(int now, int pre) { if (vos[now]) { ans = 0; return; } vos[now] = 1; for (int i = 0; i < v[now].size(); i++) { if (v[now][i] != pre) { dfs(v...
#include <bits/stdc++.h> using namespace std; int n, m, k, w, nm; char ls[1000][10][10]; int _d[1000][1000]; int used[1000], res[1000], sz = 0, c = 0; int main() { cin >> n >> m >> k >> w; nm = n * m; c = nm; for (int i = 0; i < k; i++) for (int y = 0; y < n; y++) for (int x = ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long gcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return a; } long long x1, y1; long long g = gcd(b, a % b, x1, y1); x = y1; y1 = x1 - y1 * (a / b)...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_clk_cl_jbi_cmp.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it...
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 10; int par[maxn], sub[maxn], col[maxn]; vector<pair<int, int>> parHis, colHis, subHis; bool bad[maxn]; int c[maxn]; int root(int x) { while (x != par[x]) { x = par[x]; } return x; } int getCol(int x) { int res ...
#include <bits/stdc++.h> using namespace std; const int M = 220000; vector<int> e1[M], e2[M]; int p[M], dis[M]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; e1[u].push_back(v); e2[v].push_back(u); } int k; cin >> k...
#include <bits/stdc++.h> using namespace std; int n, m, k; int s; struct DSU { int p[505]; void init() { for (int i = 1; i <= n; i++) p[i] = i; } int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); } int count() { int count = 0; for (int i = 1; i <= n; i++) ...
// mmio_if_hps_0.v // This file was auto-generated from altera_hps_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 14.0 200 at 2017.05.28.12:10:00 `timescale 1 ps / 1 ps module mmio_if_hps_0 #( parameter F2S_Width = 0, parameter S2F_Width = 0 ) ( output wire ...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 7; long long f[53], fac[53]; long long add(long long a, long long b) { return min(INF, a + b); } long long mul(long long a, long long b) { if (INF / a < b) return INF; return a * b; } const int N = 50; long long g(int n) ...
#include <bits/stdc++.h> const int inf = 0x3f3f3f; const long long INF = 1ll << 61; using namespace std; int n, x; typedef struct Node { int t, h, m; }; Node aa[2000 + 55], bb[2000 + 55]; void init() { memset(aa, 0, sizeof(aa)); memset(bb, 0, sizeof(bb)); } int cnt1, cnt2; bool input()...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010; const int MOD = 1e9 + 7; int dp[MAXN][MAXN][2]; int Steps[MAXN]; int add(int a, int b) { return ((a + b) >= MOD ? a + b - MOD : a + b); } void PreproccessSteps() { Steps[1] = 1; for (int i = (2); i < (1010); i++) Steps[i] =...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int t, n, a[N]; int main() { ios::sync_with_stdio(false); for (cin >> t; t; t--) { cin >> n; long long l = 0, r = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; l += a[i]; r ^= a[i]; } ...
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; int a[maxn], cnt[maxn], n, q; long long ans = 0; map<pair<long long, long long>, int> mp; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int MAX = 1e9 + 5; long long i, j, k, n, m, RIGHT[N], LEFT[N], ans, a[N]; long long _RIGHT[N], _LEFT[N]; int main() { scanf( %lld , &n); for (int i = 1; i <= n - 1; i++) scanf( %lld , &a[i]); for (int i = n; i >= 1; i--) ...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { ...
#include <bits/stdc++.h> using namespace std; vector<vector<long long>> matrixMul(vector<vector<long long>> lft, vector<vector<long long>> rit, long long mod = 1e9 + 7) { int n = lft.size(), s = rit.size(), m = rit.back().size(); ve...