text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> tab(n); for (int i = 0; i < n; i++) cin >> tab[i]; for (int i = 0; i < n; i++) { if (tab[i] % 2 == 0) continue; else { if (i == (n - 1) || tab[i + 1] == 0) { cout << NO ...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
#include <bits/stdc++.h> using namespace std; int x[1010], y[1010], cnt, _cnt; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) scanf( %d %d , &x[i], &y[i]); while (true) { int cnt = 0; for (int i = 1; i <= n; i++) if ((x[i] + y[i]) & 1 == 1) cnt++; if (cnt >= 1...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; vector<pair<int, int>> a(n * 2); vector<pair<int, int>> ans; for (int i = 0; i < n; i++) { cin >> a[i].first >> a[n + i].first; a[n + i].second = 1; } sor...
//----------------------------------------------------------------------------- // The FPGA is responsible for interfacing between the A/D, the coil drivers, // and the ARM. In the low-frequency modes it passes the data straight // through, so that the ARM gets raw A/D samples over the SSP. In the high- // frequenc...
//module for forwarding the arithmetic instructions and preventing data hazards module forwarding_unit ( rf_waddr_exmem, rf_waddr_memwb, inst_curr_IDEX_7_4_rs, inst_curr_IDEX_3_0_rt, inst_curr_IDEX_11_8_rd, rf_wen_exmem, rf_wen_memwb, mem2reg_memwb, mem2reg_exmem, dmem_wen_idex, forwardA, for...
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, n, m, a, b, s = 0, e1, e2, o1, o2; long long t; cin >> t; while (t--) { e1 = e2 = o1 = o2 = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a; if (a & 1) o1++; else ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:45:24 07/28/2013 // Design Name: // Module Name: UARTDemux // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) const int nmax = 3e5 + 1; using namespace std; struct node { int ind; int cur; node() {} node(int cur, int ind) : cur(cur), ind(ind){}; }; node bolshe(node a, node b) { return (a.cur == b.cur ? (a.ind > b.ind ? a : b) : (a.cur > b.cu...
#include <bits/stdc++.h> using namespace std; const int MX = 2020; const int MOD = 1e9 + 7; const long long INF = 1061109567; const long double EPS = 1e-9; const long double PI = acos(-1); const int MXX = 2e5 + 5; long long F[MXX + 5], iF[MXX + 5]; long long qpow(long long b, long long e) { if (!e...
module spmc_timestamp_counter #( parameter CLOCK_FREQUENCY = 16000000, //input clock frequency parameter BASE_ADR = 10'h0) ( //*** Connections to SpartanMC Core (do not change) *** input wire clk_peri, //System-Clock input wire [17:0] do_peri, ...
#include <bits/stdc++.h> using namespace std; long long int m; long long int a; long long int b; set<int> s; long long int im(long long int val, int dv) { long long int z = 0; long long int U = (1LL + val / dv) * (val / dv) / 2LL; U *= dv; U -= (val / dv) * (dv - (val % dv) - 1); return ...
#include <bits/stdc++.h> using namespace std; int n; int y[50010] = {}; int t[50010] = {}; unordered_map<int, int> ha; bool cmp(int x, int y) { return x > y; } bool ff(int x) { ha.clear(); for (int i = 1; i <= n; i++) y[i] = t[i]; for (int i = 1; i <= n; i++) { if (y[i] <= x && ha[y[i]] ...
/** * 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 i, a[1111], x, n, s, y, f1, f2; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> x; if (x == 0 || x == 100) a[++s] = x; else if (x < 10 && f1 == 0) a[++s] = x, f1 = 1; else if (x % 10 == 0 && f2 == 0) ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-12; const int inf = 2000000000; const long long int infLL = (long long int)2e18; long long int MOD = 998244353; int MOD1 = 1000000007; int MOD2 = 1000000009; inline bool checkBit(long long int n, long long ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a, x, b, y; cin >> n >> a >> x >> b >> y; while (a != x && b != y) { if (a == b) break; a = (a % n) + 1; if (b == 1) b = n; else b--; } if (a == b) cout << YES ; else ...
// ============================================================== // 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 1ns/1ps modul...
/** * 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...
/** * 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 long long MOD = 1000000007; class Matrix { public: long long m[4][4]; Matrix(){}; Matrix(long long k[4][4]) { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) m[i][j] = k[i][j]; } }; Matrix operator*(const Matrix &a, c...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, mod = 998244353; int n, m, x, y; vector<int> e[2][N]; inline void adde(int x, int y, int o) { e[o][x].push_back(y); } inline int read() { char ch = getchar(); int x = 0, f = 1; while (ch < 0 || ch > 9 ) { if (ch == -...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module pulse_gen_core #( parameter ABUSWIDTH = 16...
#include <bits/stdc++.h> using namespace std; const long long int MaxN = 300005; const long long int mod = 1e9 + 7; const float pi = 3.1415926535897932384626433832795028; long long int mcd(long long int a, long long int b) { if (a == 0) return b; return mcd(b % a, a); } int arr[MaxN]; void solve...
// // Copyright (c) 1999 Steven Wilson () // // 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 option) // ...
#include <bits/stdc++.h> using namespace std; inline long long read() { char c = getchar(); long long x = 0; bool f = 0; for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45); for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); if (f) x = -x; return x; } long long n, a[...
#include <bits/stdc++.h> using namespace std; int Month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int A[1000 + 1]; int B[126]; void omae_wa_mou_shindeiru() { int n, k; cin >> n >> k; string s; cin >> s; for (int i = 0; i < n; ++i) { int c = 1; while (s[i] == s[...
#include <bits/stdc++.h> using namespace std; const int M = 2000 + 4, Inf = 1e9 + 10; int n, m, k; char f[M][M]; int main() { ios::sync_with_stdio(false); cin >> n >> m >> k; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> f[i][j]; for (int i = 0; i < m; i++) { int a...
#include <bits/stdc++.h> using namespace std; char __buf[1 << 20], *__p1, *__p2; int read() { int s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s << 1) + (ch ^ 48), ch ...
#include <bits/stdc++.h> using namespace std; inline void read(int &data) { data = 0; int e = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) e = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) data = data * 10 + ch - 48, ch = getchar(); ...
#include <bits/stdc++.h> using namespace std; queue<int> que; vector<bool> init, goal; vector<bool> visited; vector<vector<int>> nodes; void calculate(int root, bool flip1, bool flip2) { const vector<int> &children = nodes[root]; visited[root] = true; if (init[root] ^ flip1 != goal[root]) { ...
/** * 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...
// Accellera Standard V2.3 Open Verification Library (OVL. // Accellera Copyright (c) 2005-2008. All rights reserved. `include "std_ovl_defines.h" `module ovl_valid_id (clock, reset, enable, issued, issued_id, returned, returned_id, flush, flush_id, issued_count, fire); parameter severity_level = `OVL_SEVERITY_D...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; string s; cin >> n >> m; int a[n][m]; int r[m]; memset(r, 0, sizeof r); for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < m; j++) { a[i][j]...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000, INF = 2000000000; struct edge { int x; int y; int w; int o; }; vector<vector<edge> > G(MAXN + 1); int n, m, depth[MAXN + 1], low[MAXN + 1], s, t, previous[MAXN + 1], prevCost[MAXN + 1], cntEdges[MAXN + 1][MAXN + 1], c...
// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; char xB[1 << 15], *xS = xB, *xTT = xB; template <typename T> inline void rd(T& xaa) { char xchh; T f = 1; xaa = 0; while (xchh = (xS == xTT && (xTT = (xS = xB) + fread(xB, 1, 1 << 15, stdin), xS == xTT) ...
#include <bits/stdc++.h> using namespace std; unsigned long long k, n, d = 0, ans; string s; unsigned long long int sol1(int k); int main() { cin >> s; n = s.size(); cin >> k; ans = max(0ULL, min(2 * k, n + k - ((n + k) % 2))); ans = max(ans, sol1(k)); cout << ans << endl; const cl...
#include <bits/stdc++.h> using namespace std; int N, K; long long A[100100], sol; map<long long, long long> M; long long __grundy(long long n) { if (n == 0) return 0; if (((M).find(n) != (M).end())) return M[n]; long long r = __grundy(n - 1); if (n % 2 != 0) return M[n] = ((r == 0) ? 1 : 0); ...
#include <bits/stdc++.h> using namespace std; int main() { long long k, sum = 0, i, j, n, cnt = 0; int a[20] = {0}, value; string s; cin >> k; cin >> s; for (i = 0; i < ((int)s.size()); ++i) { n = s[i] - 0 ; sum += n; a[n]++; } if (sum >= k) { cout << cnt << ...
/** * 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...
/* * 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, a, b, T, i, j, temp, le, ri, mid, ma = 0; cin >> n >> a >> b >> T; char str[n]; cin >> str; int r[n], l[n]; if (str[0] == h ) r[0] = 1; else r[0] = b + 1; for (i = 1; i < n; i++) { if (str[i] == h )...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // // 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 // //...
#include <bits/stdc++.h> using namespace std; int n, k, x, y; struct node { int L, R, e; long long int Lsum, Rsum, Ls, Rs; int mid() { return (L + R) / 2; } } a[200005 * 4]; void BuildTree(int r, int L, int R) { a[r].L = L; a[r].R = R; a[r].e = 0; a[r].Lsum = 0; a[r].Rsum = 0; ...
#include <bits/stdc++.h> using namespace std; int d, n, m, b[200005]; int mn[200005 << 2]; long long ans; struct node { int x; long long p; bool operator<(const node &a) const { return x < a.x; } } a[200005]; int check(int x, int y) { return a[x].p < a[y].p ? x : y; } void build(int l, int r...
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == - ) flag = true; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Tue Oct 17 02:50:46 2017 // Host : Juice-Laptop running 64-bit major relea...
//Legal Notice: (C)2012 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 associate...
#include <bits/stdc++.h> using namespace std; string s[555]; int dp[555], v[555], ones[555]; vector<pair<int, int> > vc[555]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= n; i++) { cin >> s[i]; int ...
#include <bits/stdc++.h> using namespace std; long long leftBinarySearch(long long* color, long long size, long long target) { int l = 0; int r = size - 1; int idx = -1; while (l <= r) { int m = l + (r - l) / 2; if (color[m] <= target) { l = m + 1; idx = m; } else {...
#include <bits/stdc++.h> using namespace std; bool yes; int t, n, m, len, l, sender[105]; map<string, int> msi; map<int, string> mis; string str, user[105], text[105]; set<int> mention[105]; int ans[105]; int dp[105][105]; char c; bool solve(int pos, int idx) { if (pos == m) return 1; if (...
#include <bits/stdc++.h> using namespace std; const int maxn = 400005; int n, q, a[maxn]; namespace SGT { int Min[maxn << 2]; void modify(int l, int r, int id, int x, int y) { if (l == r) { Min[id] = y; return; } int mid = (l + r) >> 1; if (x <= mid) modify(l, mid, id << 1,...
////////////////////////////////////////////////////////////////// // // // Wishbone master interface port buffer // // // // This file is part of the Amber project ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:47:43 03/06/2017 // Design Name: MUX32 // Module Name: D:/Projects/XilinxISE/HW1/Homework1/testMUX32.v // Project Name: Homework1 // Target Device: // Tool vers...
module unified_mem(clk,rst_n,addr,re,we,wdata,rd_data,rdy); ///////////////////////////////////////////////////////////////////// // Unified memory with 4-clock access times for reads & writes. // // Organized as 16384 64-bit words (i.e. same width a cache line // ///////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; long long f[6][10010], b = 1; int main() { for (int i = 1; i <= 5; ++i) for (int j = 1; j <= (i == 5 ? 1 : 10000); ++j) { long long now = f[i - 1][j]; for (int k = 1; k <= j; ++k) now += f[i - 1][min(now + j + 1, 10000ll)] + 1; ...
#include <bits/stdc++.h> using namespace std; void setIO(string NAME) {} inline long long gI() { char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); long long flag = 1, p = 0; if (c == - ) flag = -1, c = getchar(); while (c >= 0 && c <= 9 ) p = p * 10 + (c - 0 ), c...
/** * 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...
// bsg_delay_line // // new settings are delivered via bsg_tag_i // // the clock is designed to be atomically updated // between any of its values without glitching. // // the order of components is: // // ADT, CDT, FDT --> feedback (and buffer to outside world) // // All three stages invert their outputs. // // All o...
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, q; string s; int dp[251][251][251]; int nxt[26][112345]; int len[3]; int chs[3][250]; template <class T, class U> inline void smax(T &a, U b) { a = a > b ? a : b; } template <class T, class U> inline void smin(T &a,...
// (C) 2001-2017 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
/** * 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...
/** * 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...
/*64 bit wide byte addressable memory*/ module ememory(/*AUTOARG*/ // Outputs wait_out, access_out, packet_out, // Inputs clk, reset, access_in, packet_in, wait_in ); parameter DW = 32; parameter AW = 32; parameter MAW = 10; parameter PW = 104; //Basic Interface input ...
#include <bits/stdc++.h> using namespace std; int n, k; int a[105], C[105]; double f[105][105], s1[105][105], s2[105][105], s3[105][105]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) f = -1; ch = getchar(); if (ch == -1)...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; const int N = 10; char str[N][N]; int n = 8, ans, way[4][2] = {2, 2, 2, -2, -2, 2, -2, -2}; int flag[N][N][N][N]; void dfs(int x, int y, int u, int v) { flag[x][y][u][v] = 1; if (x == u && v == y && str[x][y] != # )...
#include <bits/stdc++.h> using namespace std; void optIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const long long mod = 1e9 + 7, mod2 = 998244353, mod3 = 1e9 + 9; long long p[5020], pp = 31, hh[5020]; long long p2[5020], pp2 = 37, hh2[5020]; int dp[5020]; bool can[5020][5...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) using namespace std; template <typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; } template <type...
#include <bits/stdc++.h> using namespace std; const int MAX_SIZE = 200010; pair<int, int> arr[MAX_SIZE], backup[MAX_SIZE]; long long prefix[MAX_SIZE]; int N; void sortX(int l, int r) { if (l >= r) return; int mi = (l + r) / 2; sortX(l, mi); sortX(mi + 1, r); int i = l, j = mi + 1, k = l;...
#include <bits/stdc++.h> using namespace std; vector<pair<pair<long long, long long>, int> > island; set<pair<long long, long long> > bridge; int ans[200100]; int main() { int n, m; long long l, r, prevl, prevr, a; cin >> n >> m; cin >> prevl >> prevr; for (int i = 1; i < n; i++) { c...
#include <bits/stdc++.h> using namespace std; const int limite = 1000000; int n; long long int a[limite]; long long int suma[limite]; map<long long int, int> cuantos; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i + n] = a[i]; } for (int i = 1; i <= 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 law...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); vector<int> vet, mat; int n, x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (x != 0) vet.push_back(x); } for (int i = 0; i < n; i++) { cin >> x; if (x != 0) mat.push_b...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 5; const long long linf = 1e18 + 5; const int mod = 1e9 + 7; const int N = 100 + 5; const int M = 10; int n, a[M], C[N][N], dp[M][N]; int f(int cur, int n) { if (cur == M) return !n; int &r = dp[cur][n]; if (r != -1) return ...
//---------------------------------------------------------------------------- //-- Ejemplo de uso del receptor serie //-- Se hace eco de todos los caracteres recibidos. Ademas los 4 bits menos //-- significativos se sacan por los leds de la IceStick //-------------------------------------------------------------------...
#include <bits/stdc++.h> const int mod = 1e9 + 7; const int p_mod = 998244353; using namespace std; long long fast_pow(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = (res * a) % mod; b >>= 1; a = (a * a) % mod; } return res % mod; } const int N ...
#include <bits/stdc++.h> using namespace std; int n, l, r, x, y, o, e, w, z, b[50000], aa, bb, ans; vector<int> vec; map<int, int> ma; int main() { ios_base ::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> l >> r >> x >> y; if (y % x != 0) { cout << 0 << endl; return 0...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define fast ios::sync_with_stdio(false);cin.tie(0); typedef long long ll; typedef long double ld; typedef unsigned long long ull; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); map<pair<in...
#include <bits/stdc++.h> using namespace std; const int N = 200200; int n; long long b[N], c[N]; long long a[N]; int dg[32]; void solve() { memset((dg), (0), sizeof(dg)); long long sum = 0, suma = 0; for (int i = (int)0; i < (int)n; ++i) sum += b[i] + c[i]; suma = sum / (n + n); bool f...
`include "alu_ops.vh" `include "rv32_opcodes.vh" `default_nettype none module alu( input wire [`ALU_OP_WIDTH-1:0] op, input wire [`XPR_LEN-1:0] in1, input wire [`XPR_LEN-1:0] in2, output reg [`XPR_LEN-1:0] out ); wire [`SHAMT_WIDTH-1:0] shamt...
/** * @module MEM_WB * @author sabertazimi * @email * @brief MEM_WB pipeline register * @input clk clock signal * @input rst reset signal * @input en load enable signal * @input MEM_PC PC value in MEM stage * @input MEM_IR instruction value in MEM stage * @input MEM_writetolo writetolo signal in MEM stage *...
#include <bits/stdc++.h> using namespace std; string itosm(long long x) { if (x == 0) return 0 ; string ans = ; while (x > 0) { ans += ((x % 10) + 0 ); x /= 10; } reverse(ans.begin(), ans.end()); return ans; } long long stoim(string str) { long long ans = 0; long ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: California State University San Bernardino // Engineer: Bogdan Kravtsov // Tyler Clayton // // Create Date: 15:17:23 10/24/2016 // Module Name: ALU_CONTROL_tb // Project Name: ...
#include <bits/stdc++.h> using namespace std; long long n, ans; string a; int main() { cin >> a; ans = a.size(); long long t = 0; for (int i = 0; i < a.size(); i++) { if (a[i] == ) ) t--; else t++; if (t < 0) { t = 0; ans--; } } co...
`timescale 1ns/1ns module ddr2_ctrl( sys_rst_n, ddr2_clk, local_init_done, local_ready, local_address, local_read_req, local_write_req, local_wdata, local_be, local_size, local_rdata, local_rdata_valid, local_burstbegin, um2ddr_wrclk, um2ddr_wrreq, um2ddr_data, um2ddr_ready, um2ddr_command_wrreq, um2ddr_command, dd...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo_71x256.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ===========================================...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin.sync_with_stdio(false); cout.sync_with_stdio(false); cin >> n; vector<long long> q(1000100, 0); for (long long i = 0; i < n; i++) { long long t; cin >> t; q[t]++; } long long ans = 0; fo...
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { ~debug() { cerr <...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool uin(T& a, T b) { return a > b ? (a = b, true) : false; } template <class T> inline bool uax(T& a, T b) { return a < b ? (a = b, true) : false; } const int nax = 5123; pair<int, int> edge[nax]; vector<int> g[nax]; ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: FIFO_SUM_IN_SQUARED.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ===================================...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } return gcd(b, a % b); } long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); } const long long maxn = 1e5; long long n, k; vector<long long> freq(maxn, 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...
#include <bits/stdc++.h> using namespace std; struct node { long long x; int c; friend bool operator<(node x, node y) { return x.x < y.x; } } a[400001]; long long leftdata[400001], rightdata[400001]; int n; long long ans; long long max1, max2, l1, r1, ttt; void work1() { long long tans; ...
/** * 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...
//---------------------------------------------------------------------------- // Copyright (C) 2009 , Olivier Girard // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must re...
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, n, m, d, f, x, d1, ans = 1e9; cin >> n >> m; long long a[n], b[n]; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n; i++) cin >> b[i]; sort(a, a + n); sort(b, b + n); for (i = 0; i < n; i++) { x = ...
#include <bits/stdc++.h> using namespace std; const int N = 60; const int M = 40010; const int OFF = 20005; int n, m; int lt[N], rt[N]; set<int> cnt; bitset<N> ll[M], rr[M]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> lt[i]; } for (int i = 0; i < m; i++) { ...
// trigger_top.v `timescale 1 ns / 1 ps module trigger ( input clk, input sclk, input sync, input reset, input ctrl_write, input [31:0]ctrl_writedata, input [3:0]ctrl_address, // async trigger input input trigger_in, // trigger data in/out input evin, output evout, // pattern generator inpu...
//================================================================================================== // Filename : Priority_Codec_32.v // Created On : 2016-10-17 18:21:34 // Last Modified : 2016-10-17 19:20:05 // Revision : // Author : Jorge Sequeira Rojas // Company : Instituto Tecnolog...