text
stringlengths
59
71.4k
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:29:20 10/26/2014 // Design Name: // Module Name: uart // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Re...
/** * 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 a, b, n; long long mod = 1000000007; vector<long long> factorial(1000005); bool excellent(long long z) { while (z != 0) { if (z % 10 != a && z % 10 != b) return false; z /= 10; } return true; } long long pow(long long a, long long p...
#include <bits/stdc++.h> using namespace std; const int N = 5010; struct Edge { int v, u, f, r, c; Edge() {} Edge(int v, int u, int f, int c, int r) : v(v), u(u), f(f), c(c), r(r) {} }; const int inf = 1e9; const int C = 4000; int n, m, k, nflow, s, t, parent[N], number[N], a[N], b[N]; int d...
/* * 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 BIN[30], P[1000005], vis[1000005]; int _bin(int n) { int i, now; for (i = 0; BIN[i] <= n; i++) now = BIN[i]; return BIN[i]; } int main() { int i, j, n, k, now, t; long long ans = 0; for (i = 1, BIN[0] = 1; i < 30; i++) BIN[i] = BIN[i - ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const bool MULTI_TESTCASES = 0; struct Query { int l, r, id; }; void solve() { int n, k; cin >> n >> k; vector<int> t(n + 1); for (int i = 1; i < n + 1; ++i) { cin >> t[i]; if (t[i] == 2) t[i] = -1; } ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:00:03 05/22/2014 // Design Name: // Module Name: cpu_top // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
/* --VGA Timing --Horizontal : -- ______________ _____________ -- | | | --_______________| VIDEO |_______________| VIDEO (next line) --___________ _____________________ ______________________ -- |_| |_| --...
// Jagadeesh Vasudevamurthy nes_top_X99.v // Please do not remove the header // Char array passed is as follows //-------------------------------------- //0:000000 01101101 //1:000001 00100010 //2:000010 00000010 //3:000011 01000010 //4:000100 10000001 //5:000101 10100000 //6:000110 10100000 //7:000111 01100000 //8:001...
`timescale 1 ps / 1 ps module system_top_wrapper (DDR_addr, DDR_ba, DDR_cas_n, DDR_ck_n, DDR_ck_p, DDR_cke, DDR_cs_n, DDR_dm, DDR_dq, DDR_dqs_n, DDR_dqs_p, DDR_odt, DDR_ras_n, DDR_reset_n, DDR_we_n, FIXED_IO_ddr_vrn, FIXED_IO_ddr_vrp, FIXED_IO_mio,...
/** * 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 ADC_CTRL ( iRST, iCLK, iCLK_n, iGO, oDIN, oCS_n, oSCLK, iDOUT, oADC_12_bit_channel_0, oADC_12_bit_channel_1, ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2008 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; reg toggle; initial toggle=0; integer cyc; initial cyc=1; wire [7:0] cyc_copy = cyc[...
/** * 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 maxn = 3e3 + 100; const long long inf = 0x3f3f3f3f; const long long iinf = 1 << 30; const long long linf = 2e18; const long long mod = 998244353; const double eps = 1e-7; template <class T = long long> T chmin(T &a, T b) { return a = mi...
// DSP48E1 - 7 Series DSP48E1 User Guide UG479 (v1.9) September 27, 2016 `ifndef PB_TYPE `include "alu/alu.sim.v" `include "alumode_mux/alumode_mux.sim.v" `include "carryinsel_logic/carryinsel_logic.sim.v" `include "carryinsel_mux/carryinsel_mux.sim.v" `include "creg_mux/creg_mux.sim.v" `include "dual_ad_preadder/dual...
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &x) { x = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) { x = x * 10 + c - 0 ; c = getchar(); } } int fr[100005], to[100005 << 1], ne[100005 << 1], x[100005]; i...
// // 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...
// +---------------------------------------------------------------------------- // GNU General Public License // ----------------------------------------------------------------------------- // This file is part of uDLX (micro-DeLuX) soft IP-core. // // uDLX is free soft IP-core: you can redistribute it and/or modify ...
`timescale 1ns / 1ps /* * Spartan3AN_PicoBlaze_Leds.v * * ___ _ _ _ _ ___ _ _ ___ * | __._ _ _| |_ ___ _| |_| |___ _| | . | \ |_ _| * | _>| ' ' | . / ._/ . / . / ._/ . | | || | * |___|_|_|_|___\___\___\___\___\___|_|_|_\_||_| * * * Created on : 20/07/2015 * Author : Ernesto An...
module sevenseg ( input wire clk, input wire rstn, input wire [7:0] display_0, input wire [7:0] display_1, input wire [7:0] display_2, input wire [7:0] display_3, input wire [1:0] decplace, output reg [7:0] seg, output reg [3:0] an ); // CHARACTERS Hgfedcba localparam NUM_0 ...
#include <bits/stdc++.h> using namespace std; const int MX = 2e5 + 5; vector<int> v(MX); struct Q { int t, l, r; }; vector<Q> qs(MX); int n, q, m, p; int main() { cin >> n >> q >> m; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= q; i++) cin >> qs[i].t >> qs[i].l >> qs[i]...
#include <bits/stdc++.h> using namespace std; int main() { set<int> s; long long int n, m, k, a; cin >> n >> m; while (n--) { cin >> k; while (k--) { cin >> a; s.insert(a); } } if (s.size() == m) { cout << YES << n ; } else { c...
//altiobuf_out CBX_AUTO_BLACKBOX="ALL" CBX_SINGLE_OUTPUT_FILE="ON" DEVICE_FAMILY="Cyclone V" ENABLE_BUS_HOLD="FALSE" NUMBER_OF_CHANNELS=1 OPEN_DRAIN_OUTPUT="FALSE" PSEUDO_DIFFERENTIAL_MODE="TRUE" USE_DIFFERENTIAL_MODE="TRUE" USE_OE="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN1="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN2="FALSE" USE_TE...
#include <bits/stdc++.h> using namespace std; int n, s[1000006], top, a[1000006]; int solve(int n, int mul) { if (n == 1) return s[++top] = mul; if (n == 2) return s[++top] = mul, s[++top] = mul * 2; if (n == 3) return s[++top] = mul, s[++top] = mul, s[++top] = mul * 3; for (int i = 1; i <= (n - n...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, a, b; cin >> a >> b >> n; if (n % 2 == 0) cout << (n / 2) * (a - b) << endl; else cout << ((n / 2) * (a - b)) + a << endl; } return 0; }
// Module m_2to1_8bit_mux is a dual 2 to 1 multiplexer. When w_channel is HIGH, // w_bus_mux_in_1 bus is selected. When w_channel is LOW, w_bus_mux_in_0 bus is selected. module m_2to1_8bit_mux (w_bus_mux_out, w_bus_mux_in_0, w_bus_mux_in_1, w_channel); output [7:0] w_bus_mux_out; input [7:0] w_bus_mux_in_0, w_bus_mu...
/* * 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 a, b, n; cin >> a >> b >> n; cout << min(b, n) - n + min(a, n) + 1 << n ; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int a, b, n, krok = 0; cin >> a >> b >> n; bool podm = false; int g; while (n > 0) { if (krok % 2 == 0) { g = gcd(a, n); ...
#include <bits/stdc++.h> using namespace std; multiset<int> val[33]; long long sum[33]; int n = 0; int calc() { long long allsum = 0; int res = 0; for (int i = 0; i < 30; i++) { if (val[i].empty()) continue; if (allsum * 2 < *(val[i].begin())) res++; allsum += sum[i]; } r...
#include <bits/stdc++.h> using namespace std; struct FenwickTree { vector<long long int> bit; int n; FenwickTree(int n) { this->n = n; bit.assign(n, 0); } FenwickTree(vector<long long int> a) : FenwickTree(a.size()) { for (size_t i = 0; i < a.size(); i++) add(i, a[i]); } ...
//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 associate...
/** * 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...
// soc_system_mm_interconnect_0_avalon_st_adapter.v // This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module soc_system_mm_interconnect_0_avalon_st_adapter #( parameter inBi...
/** * Testbench: arbiter * * Created: Sat Jun 1 19:01:54 EDT 2013 * * Author: Berin Martini () */ `timescale 1ns/10ps `define TB_VERBOSE //`define VERBOSE //`define DEBUG_CONVOLVER `include "arbiter.v" module arbiter_tb; /** * Clock and control functions */ // Generate a clk reg clk;...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, L, a; int t[N], l[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL)); cin >> n >> L >> a; int res = 0; for (int i = 1; i <= n; i++) { cin >> t[i] >> l[i]; ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2000; int n, m, k, t, a[MAX_N + 1], b[MAX_N + 1], p[MAX_N + 1]; vector<int> x; vector<int> y; int main() { int i, j, ans = 0; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , a + i); for (i = 1; i <= n; i++) scanf( %d , b +...
/** * 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 = 1000005; struct tr { int l, r, c, p; } a[maxn], b[maxn]; int n, k, m, maxr = 0; long long ans = 0, num[maxn << 2], sum[maxn << 2]; bool cmpl(tr a, tr b) { return a.l < b.l; } bool cmpr(tr a, tr b) { return a.r < b.r; } void update(int ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Thu May 25 15:27:52 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; long long Q = 1e9 + 7; long long poww(long long a, long long b) { long long x = 1, y = a; while (b > 0) { if (b % 2 == 1) { x = (x * y); if (x > Q) x %= Q; } y = (y * y); if (y > Q) y %= Q; b /= 2; } return...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int MAX = 200002; int arr[MAX]; int cnt[MAX]; int main() { int n, wrong = 0; cin >> n; for (int i = (1); i <= (n); i++) { cin >> arr[i]; } string s; cin >> s; cnt[1] = s[0] - 0 ; for (int i...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (win64) Build Wed Oct 4 19:58:22 MDT 2017 // Date : Fri Nov 17 14:49:55 2017 // Host : egk-pc running 64-bit major release (build...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TESTS = 1; while (TESTS--) { long long int n; cin >> n; long long int a[n + 1], b[n + 1]; for (long long int i = 1; i <= n; i++) cin >> a[i]; fo...
`timescale 1ns / 1ps /******************************************************************************* * Engineer: Robin zhang * Create Date: 2016.09.10 * Module Name: spi_slave_b2b * this module will get 64 bytes and then return the count 64 at next clks *************************************************************...
#include <bits/stdc++.h> using namespace std; const int inf = (int)1.01e9; const long long infll = (long long)1.01e18; const long double eps = 1e-9; const long double pi = acos((long double)-1); mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x) { return mrand() % x; } ...
/* * Copyright (c) 2001 Stephen Williams () * * 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> const long long md = (1e9 + 7); const long long fakmd = 998244353; using namespace std; long long n, m; pair<long long, long long> a[100100]; long long ans[100100]; int32_t main() { cin >> n >> m; long long it = 1; long long sum = 0; for (long long i = 1; i <= m; 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; const int N = 4010; int n, m, a[N], rt, tot, L[N], siz[N], R[N], ls[N], rs[N]; long long val[N], dp[N][N]; inline void build(int &p, int l, int r) { if (l > r) return; p = ++tot; int pos = l; for (int i = l; i <= r; ++i) if (a[i] < a[pos]) po...
#include <bits/stdc++.h> using namespace std; long long n, k, mod = 1000000007, dp[2010][2010]; long long solve(long long num, long long x) { long long i; if (x == k) return 1; if (dp[num][x] != -1) return dp[num][x]; long long res = 0; for (i = 1; (i * num) <= n; i++) { res += solve(num...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 5e5; long long id[N], a[N], pos[N]; int main() { ios_base::sync_with_stdio(false); long long n, t, m, l, k, ans, i, j, res = 0, fl; t = 1; long long x; while (t--) { long long o; ci...
#include <bits/stdc++.h> using namespace std; bool prime[10000007]; void SieveOfEratosthenes() { memset(prime, true, sizeof(prime)); for (long long int p = 2; p * p <= 10000007; p++) { if (prime[p] == true) { for (long long int i = p * p; i <= 10000007; i += p) prime[i] = false; } ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long prod = 1; for (int i = 1; i < n; i++) prod *= i; prod *= 2; prod /= n; cout << prod << endl; return 0; }
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_io_cmos2_pad_dn.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 i...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b; cin >> n >> m >> a >> b; int q = m * a; if (q < b) { cout << n * a; } else { int v = n / m; n -= v * m; cout << v * b + min(b, n * a); } }
#include <bits/stdc++.h> using namespace std; int n, m; char s[100010]; int main() { cin >> n >> m; scanf( %s , s + 1); while (m--) { int l, r; cin >> l >> r; char a[2], b[2]; scanf( %s%s , a, b); for (int i = l; i <= r; i++) if (s[i] == a[0]) s[i] = b[0]; }...
#include <bits/stdc++.h> using namespace std; struct __timestamper {}; vector<vector<int>> g; vector<vector<int>> id; vector<int> used; vector<int> ts; void dfs(int v, int x) { if (used[v]) return; used[v] = 1; for (int i = 0; i < (int)g[v].size(); i++) { if (id[v][i] < x) { dfs(...
#include <bits/stdc++.h> using namespace std; int main() { clock_t clk_begin = clock(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string s; cin >> s; int c = 0; for (int i = 0; i < n; ++i) if (s[i] == 8 ) c++; n /= 11; co...
#include <bits/stdc++.h> using namespace std; const long long iinf = 1e9 + 10; const long long inf = 1ll << 60; const long long mod = 1e9 + 87; void GG() { cout << 0 n ; exit(0); } long long mpow(long long a, long long n, long long mo = mod) { long long re = 1; while (n > 0) { if (n...
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f3f3f3f3f; const long long N = 5000; long long n, m, s, t; vector<pair<long long, long long> > nei[N + 1]; vector<long long> rv[N + 1]; void ae(long long x, long long y, long long z) { nei[x].push_back(make_pair(y, z)), nei[y...
`timescale 1ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:52:26 06/07/2015 // Design Name: // Module Name: joystick_protocols // Project Name: // Target Devices: // Tool versions: // Descri...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n >= 1 && n <= 10 || n >= 22 && n <= 25) cout << 0 ; else if (n == 11) cout << 4 ; else if (n == 20) cout << 15 ; else cout << 4 ; return 0; }
#include <bits/stdc++.h> using namespace std; long long fn(long long x) { long long ret = (x * (x + 1)) / 2; if (x < 0) ret = 0; return ret; } long long fn(long long R, long long K1, long long K2) { long long ret = 0; K1 = min(K1, R - 1); K2 = min(K2, R); if (R - K1 >= K2) return ((K...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Sun Jun 04 00:41:34 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, f, k; cin >> a >> b >> f >> k; int now = b; int ret = 0; for (int i = 1; i <= k; i++) { if (i % 2 == 1) { if (now < f) { return puts( -1 ), 0; } if (i == k) { if (now < a) { ...
module ADT7310P32LS16 ( (* intersynth_port="Reset_n_i" *) input Reset_n_i, (* intersynth_port="Clk_i" *) input Clk_i, (* intersynth_port="ReconfModuleIn_s", intersynth_conntype="Bit" *) input Enable_i, (* intersynth_port="ReconfModuleIRQs_s", intersynth_conntype="Bit" *) output CpuIntr_o, (* inter...
//============================================================= // // Copyright (c) 2017 Simon Southwell. All rights reserved. // // Date: 30th May 2017 // // This code 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 So...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= n; i++) cout << i << ; cout << endl; } }
/** * 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 msg { long long lstl = 0; long long lstr = 0; long long num = 0; }; int32_t main() { long long n, k; cin >> n >> k; long long a[n]; msg ms[n]; for (long long i = 0; i < n; i++) { cin >> a[i]; } for (long long i = ...
#include <bits/stdc++.h> using namespace std; void File() { freopen( output.txt , w , stdout); freopen( input.txt , r , stdin); } void fast() { ios::sync_with_stdio(NULL); cout.tie(NULL); cin.tie(NULL); } const double pi = 2 * acos(0.0); const int nn = 5e2 + 5; const int oo = 0x3f3...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:10:22 08/01/2014 // Design Name: // Module Name: keytofrequency // Project Name: // Target Devices: // Tool versions: // Description: // // ...
`ifndef _REGFILE `define _REGFILE `include "../misc/demux.v" `include "../misc/mux.v" `include "../reg-file/register.v" module register_file(clk, out1, out2, readAdd1, readAdd2, write, writeAdd, writeR7, inR7, in, reset); // Modify to include R7 effects output [15:0] out1, out2; input [15:0] in, inR7; input [2:...
#include <bits/stdc++.h> using namespace std; long long int MOD = 1000000007; void solve() { int p, f; cin >> p >> f; if (f > p) swap(p, f); int cs, cw; cin >> cs >> cw; int s, w; cin >> s >> w; if (w > s) { swap(w, s); swap(cs, cw); } int maxv = 0; for (int...
// (C) 2001-2016 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 doc...
/** * 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> long long arr[10000001]; using namespace std; int main() { long long n, k, m = 0; cin >> n >> k; m = (2 * n) + 1; for (int i = 1; i <= m; i++) { cin >> arr[i]; } for (int i = 2; i <= m; i += 2) { if (k == 0) { break; } if (arr[i] > a...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { int q, ans = 0; cin >> q; if (q % 2) q -= 9, ans++; if (q < 0) ans = -1; else ans += q / 4; if (q == 2) ans = -1; cout << ans << endl; } return 0; ...
/*************************************************************************** * pcx2mb_link_cnt.v: A counter to keep track of outstanding transactions * to one of the five destinations of the PCX request. This * counter will be instantiated 5 times. * * The core has a link credit of 2 transactions. However, i...
/* * Copyright (c) 2008 Gyorgy Jeney () * * 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) * a...
#include <bits/stdc++.h> using namespace std; long long int max(long long int a, long long int b) { if (a > b) return a; else return b; } long long int min(long long int a, long long int b) { if (a < b) return a; else return b; } const int dx[4] = {-1, 1, 0, 0}; 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 law...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, x, c1 = 0, c2 = 0; bool flag = false; cin >> n; while (n--) { cin >> x; if (x == 100) ++c1; else ++c2; } if (c1 % 2 == 0) { if ((...
module axi_master_stub( output M2S_AXI_ACLK, //Read Transaction output M2S_AXI_ARVALID, input M2S_AXI_ARREADY, output [31:0] M2S_AXI_ARADDR, output [1:0] M2S_AXI_ARBURST, output [3:0] M2S_AXI_ARLEN, output [1:0] M2S_AXI_ARSIZE, // input M2S_AXI_RVALID, output M2S_AXI_RREADY...
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e9; const long long MOD = (long long)1e9 + 7; const long long P = 239; const long long MAX_N = 1000; const long long CNT = 5; const long double pi = 3.1415926535897932384626; const long double eps = 1e-6; int main() { ...
#include <bits/stdc++.h> using namespace std; int n, m, s, t, d[200005], v[200005], dd[200005], ma[1005][1005], ok = 1, y, ans; int main() { scanf( %d%d%d%d , &n, &m, &s, &t); for (int i = 1; i <= m; i++) { int x, y; scanf( %d...
#include <bits/stdc++.h> using namespace std; int main() { long long num, length, devisor = 1, rest; long long i; string str; cin >> str; length = str.length(); num = atoi(str.c_str()); for (i = 1; i <= length - 1; i++) { devisor *= 10; } rest = num % devisor; cout << d...
// UC Berkeley CS150 // Lab 3, Fall 2014 // Module: ALUdecoder // Desc: Sets the ALU operation // Inputs: opcode: the top 6 bits of the instruction // funct: the funct, in the case of r-type instructions // add_rshift_type: selects whether an ADD vs SUB, or an SRA vs SRL // Outputs: ALUop: Selects the...
`include "sd_defines.v" module sd_controller_fifo_wba ( // WISHBONE common wb_clk_i, wb_rst_i, wb_dat_i, wb_dat_o, // WISHBONE slave //wb_adr_i, wb_sel_i, wb_we_i, wb_cyc_i, wb_stb_i, wb_ack_o, wb_adr_i, // wb_sel_i, //Avalon-to-wishbone wb_ava_write_n, wb_ava_read_n, wb_ava_chipselect,...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int N = 2e6 + 10; const long long mod = 1000000007; const double eps = 1e-9; const double PI = acos(-1); template <typename T> inline void read(T &a) { char c = getchar(); T x = 0, f = 1; while (!isdigit(c)) { ...
#include <bits/stdc++.h> using namespace std; int main() { string n; cin >> n; long long even = 0; long long odd = 0; long long len = n.length(); long long aeven = 0; long long aodd = 0; long long beven = 0; long long bodd = 0; for (int i = 0; i < len; i++) { if (n[i] =...
#include <bits/stdc++.h> using namespace std; long long a[500005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, i, j, k, l, m; long long t; cin >> t; long long pret = t; while (t--) { cin >> n >> k; for (i = 1; i <= n; i++) cin >> a[i]; i...
#include <bits/stdc++.h> using namespace std; const long long INF = 2000000000000000000LL; const int inf = 0x3f3f3f3f; const long double EPS = 1e-9; int dirx[] = {0, 0, -1, 1}; int diry[] = {-1, 1, 0, 0}; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int test; ...
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; #ifdef eclipse #define debug(...) do{ fprintf(stderr, LINE %d: (%s) = ,__LINE__, #__VA_ARGS__ ); _do(__VA_ARGS__); }while(0) template<typename T> void _do(T &&_x) {cerr << _x ...
/* * Copyright 2012, Homer Hsing <> * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to ...
// nios_solo_mm_interconnect_0_avalon_st_adapter_001.v // This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module nios_solo_mm_interconnect_0_avalon_st_adapter_001 #( par...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/12/2016 06:18:20 PM // Design Name: // Module Name: Mux_Array // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: ...