text stringlengths 59 71.4k |
|---|
`default_nettype none
module simple_ddr3(
input wire clk, // clk491520
input wire rst,
input wire [27:0] addr_i,
input wire [31:0] data_i,
input wire we_i,
input wire pop_i,
output wire [31:0] data_o,
output wire ack_o,
output wire busy_o,
// MIG interface
output wire mig_c... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; assert(1 <= n && n <= (int)(2e5)); string sex; cin >> sex; assert(sex.size() == n); for (int i = 0; i < n; ++i) { assert(sex[i] == B || sex[i] == G ); } vector<int> a(n); for (int i = 0; i < ... |
// This pass performs an optimisation that decomposes wide arithmetic
// comparisons into LUT-size chunks (as guided by the `LUT_WIDTH
// macro) connected to a single lookahead-carry-unit $lcu cell,
// which is typically mapped to dedicated (and fast) FPGA
// carry-chains.
(* techmap_celltype = "$lt $le $gt $ge... |
module ourspi (
OPB_Clk,
rst,
opb_abus,
opb_be,
opb_dbus,
opb_rnw,
opb_select,
opb_seqaddr,
sl_dbus,
sl_errack,
sl_retry,
sl_toutsup,
sl_xferack,
radio1_sclk,
radio1_dout,
radio1_cs,
radio2_sclk,
radio2_dout,
radio2_cs,
radio3_sclk,
radio3_dout,
radio3_cs,
radio4_sclk,
radio4_dout,
radio4_cs,
... |
#include <bits/stdc++.h> using namespace std; const int N = 200100; const int INF = 1000 * 1000 * 100; string s[N]; char ch[30]; int d[1000 * 3000 + 10], l[30], r[30]; int lcps(int x) { int sz = s[x].size(); for (int i = sz - 1; i >= 0; i--) r[i] = r[i + 1] + ((s[x][i] - 0 ) << (sz - i - 1)... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = long double; using str = string; using pi = pair<int, int>; template <class T> using V = vector<T>; template <class T, size_t SZ> using AR = array<T, SZ>; using vi = V<int>; using vb = V<bool>; using vpi = V<pi>; co... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); } int main() { int n; scanf( %d , &n); if (n % 2) printf( %d %d n , n / 2, n / 2 + 1); else { for (int a = n / 2 - 1; a; a--) { if (gcd(a, n - a) == 1) { print... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, m; int a[N], q[N]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> m; for (int i = 0; i < m; ++i) cin >> q[i]; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; sort(q, q + m); sort(a,... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long double temp; temp = log2(n + 1); if (temp == (int)temp) { cout << temp << endl; } else { cout << (int)(temp) + 1 << endl; } } |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y / 2; x = (x * x) % p; } return res; } void solve() { long long ... |
/**
* 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; char s[200005]; char x[26]; int n, m; char a, b; int main() { while (scanf( %d%d , &n, &m) != EOF) { for (int i = 0; i < 26; i++) x[i] = i + a ; getchar(); scanf( %s , s); getchar(); for (int i = 0; i < m; i++) { scanf(... |
#include <bits/stdc++.h> using namespace std; void seif() { std::ios_base::sync_with_stdio(0); } int xa[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; int ya[] = {1, 0, -1, 1, 0, -1, 1, 0, -1}; int anx, any, marx, mary; bool ok = false; char grid[8][8]; bool valid(int x, int y) { if (x < 0 || y < 0 || x > 7 ||... |
`default_nettype wire
module cache_ram_16entry_512bit(
input clock,
input [63:0] byteena_a,
//Write
input wren,
input [3:0] wraddress,
input [511:0] data,
//Read
input [3:0] rdaddress,
output [511:0] q
);
reg [511:0] b_mem[0:15];
always@(posedge clock)begin
if(wren)begin
b_mem[wraddress... |
/**
* 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; const int N = 300005; long long n, e, idx[N], low[N], T, q[300005], ans = 0, ans2 = 1, scc[100005], mini[300005], cn, second[3000005]; vector<vector<long long> > g; vector<long lon... |
/**
* 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... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's Store Buffer ////
//// ////
//// This file is part of the OpenR... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e9 + 7; vector<long long int> v; long long int calcmulti(string s, long long int l, long long int r) { long long int ans = 1; string z = ; for (long long int i = l; i <= r; i++) { if (s[i] == * ) { ans *= stoll(z); ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 101000 * 8; const int G = 3; const int Mod = 998244353; int n; long long m; int Fc[maxN], Ifc[maxN]; int In[maxN], A[maxN], B[maxN], C[maxN], R[maxN]; int QPow(int x, int cnt); void NTT(int *P, int N, int opt); int main() { Fc[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 law... |
#include <bits/stdc++.h> using namespace std; long long n; long long head[1100000], a[1100000]; struct node { long long v, nex; } bian[2100000]; long long cnt; void add(long long x, long long y) { bian[++cnt].v = y; bian[cnt].nex = head[x]; head[x] = cnt; } long long tot[1100000], d[11... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, a, b; cin >> n >> a >> b; string s, ans; for (long long i = 0; i < b; i++) { long long m = a ; char c = m + i; s += c; } for (long lon... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 00:57:43 03/22/2015
// Design Name: dlatch_nand
// Module Name: C:/Users/Joseph/Documents/Xilinx/HW1/latch_test.v
// Project Name: HW1
// Target Device:
... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, k; cin >> n >> k; vector<long long> a(n); for (int i = 0; i < n; i++) cin >> a[i]; ; sort(a.begin(), a.end()); long long mm = a[n / 2]; for (int i = n / 2; i < n - 1; i++) { long long r = a[i + 1] - a[i];... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, idx = 0; cin >> n >> k; pair<int, int> inst[n]; vector<int> v; for (int i = 1; i <= n; i++) { int t; cin >> t; inst[i - 1] = make_pair(t, i); } sort(inst, inst + n); while (k >= inst[idx].first && ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; struct node { long long v[10]; int tag[10]; void init(int x) { int y = 1; memset(v, 0, sizeof(v)); while (x) { v[x % 10] += y; x /= 10; y *= 10; } } void updtag(int* _tag) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int l, r; cin >> l >> r; if (l == r) { cout << l; return 0; } cout << 2 << endl; } |
`include "common.vh"
`timescale 1ns/10ps
module Gpio(clk, strobe, rw, reset, addr, data_i, data_o, gpio);
// four registers
// 0 : enable (1 for enable)
// 1 : read-write (1 for write)
// 2 : read state (1 for high)
// 3 : write state (1 for high)
parameter COUNT = 32;
localparam SIZE = 4;... |
#include <bits/stdc++.h> using namespace std; #define cp ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long int #define vint vector<int> #define vllint vector<ll> #define pair_int pair<int , int> #define pair_ll_int pair<ll , ll> #define vector_of_pair_int vector<pair_... |
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; const long long INF = 1ll << 60; const double Inf = 1e20; const double eps = 1e-9; void gmax(int &a, int b) { a = (a > b ? a : b); } void gmin(int &a, int b) { a = (a < b ? a : b); } const int P = 1e9 + 7; const int maxn = 1000050;... |
module mac(
input wire reset,
// IN PORT
input wire [31:0] data_in,
input wire data_in_clock,
input wire data_in_enable,
input wire data_in_start,
input wire data_in_end,
// OUT PORT
output wire [31:0] data_out,
input wire ... |
/**
* This is written by Zhiyang Ong
* and Andrew Mattheisen
* for EE577b Troy WideWord Processor Project
*/
// IMPORTANT: This requires an input text file named "rf1.fill"
// Include definition of the control signals
`include "control.h"
// Non-synthesizable behavioral RTL model for the instruction memory
mo... |
module top (
input wire clk,
input wire rx,
output wire tx,
input wire [15:0] sw,
output wire [15:0] led
);
reg nrst = 0;
wire tx_baud_edge;
wire rx_baud_edge;
// Data in.
wire [7:0] rx_data_wire;
wire rx_data_ready_wire;
// Data out.
wire tx_data_ready;
wi... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; constexpr int MAXN = 5 + 50; constexpr ll INF = 1000000000000000002LL; namespace dsu { int f[MAXN], sz[MAXN]; void build(int n) { fill(sz, sz + n, 1); for (int i = (int)0; i < (int)n; ++i) f[i] = i; ... |
#include <bits/stdc++.h> using namespace std; const double pie = acos(-1); int n, m, i, N, f[1100000], t, s, j, k, chz[266], ans, a[4][1100000], b[4][1100000], gs[4], use[1100000]; char s1[1100000], s2[1100000]; struct fs { double x, y; } w[1100000], A[1100000], B[1100000], C[1100000], v, ww; fs... |
// Copyright 2020-2022 F4PGA 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 1000000; const int Inf = 0x3f3f3f3f; int n, m, k; pair<int, int> edge[Maxn + 5]; int a[Maxn + 5]; map<pair<int, int>, int> mp; int deg[Maxn + 5], sz[Maxn + 5], st[Maxn + 5], col[Maxn + 5]; vector<pair<int, int> > g[Maxn + 5]; int ans[Max... |
//register module to load values stored in registers
module register(clk, loada, loadb, write, readnum, reg0, reg1, reg2, reg3, reg4 ,reg5 ,reg6 ,reg7, A, B);
parameter width= 1;
input clk, loada, loadb, write;
input [2:0] readnum;
input [15:0] reg0, reg1, reg2, reg3, reg4 ,reg5 ,reg6 ,reg7;
output [15:0] A, ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int N; cin >> N; long long int A[N]; for (long long int i = 0; i < N; i++) cin >> A[i]; map<long long int, long long int> M; for (long long int i = 0; i < N; i++) { if (A[i] != 0) M[A[i]]++; } cout << M.size... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> adj[100005]; vector<int> vis(100005, 1); vector<int> ans; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int T = 1; for (int qq = 1; qq <= T; qq++) { cin >> n >> m; for (int i = 0; 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 law... |
// Copyright (C) 1991-2014 Altera Corporation
// 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 from any of the foregoing
// (including device programming or simulation files), and any
// associated docume... |
module export_master (
clk,
reset,
address,
read,
readdata,
readdatavalid,
write,
writedata,
burstcount,
byteenable,
waitrequest,
burstbegin,
export_address,
export_read,
export_readdata,
export_readdatavalid,
export_write,
export_writedata,
... |
#include <bits/stdc++.h> using namespace std; template <class T> using vv = vector<vector<T>>; template <class T> ostream &operator<<(ostream &os, const vector<T> &t) { os << { ; for (int(i) = 0; (i) < (t.size()); ++(i)) { os << t[i] << , ; } os << } << endl; return os; } tem... |
`timescale 1 ps / 1 ps
module alt_mem_ddrx_input_if
#(parameter
CFG_LOCAL_DATA_WIDTH = 64,
CFG_LOCAL_ID_WIDTH = 8,
CFG_LOCAL_ADDR_WIDTH = 33,
CFG_LOCAL_SIZE_WIDTH = 3,
CFG_MEM_IF_CHIP = 1,
CFG_AFI_INTF_PHASE_NUM = 2,
CFG_CTL_ARBITER_TYPE = "ROWCOL"
)
(... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, mn = INT_MAX, ans = INT_MAX; cin >> n; map<int, int> mp; map<int, int> mp_ans; for (int i = 1; i <= n; i++) { cin >> a; if (mp[a] == 0) mp[a] = i; else { if (a <= mn) { mn = a; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 7; int m, k; long long n, x, s, a[MAX], b[MAX], c[MAX], d[MAX]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> k >> x >> s; for (int i = 1; i <= m; ++i) { cin >> a[i]; } for (int i = 1; i <= m... |
/**
* 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 = 55; char a[maxn][maxn]; int vis[maxn][maxn]; int n, m; inline void go(int x, int y) { if (vis[x][y] == 1) return; if (a[x][y] != # ) return; vis[x][y] = 1; go(x - 1, y); go(x + 1, y); go(x, y - 1); go(x, y + 1); } ... |
#include <bits/stdc++.h> long long a[100005]; long long count[100005]; int vis[100005]; struct Element { long long l, r; Element(long long l, long long r) : l(l), r(r) {} }; Element getCount(long long k, int n) { long long lower = 0, upper = 0; int met = 0; for (int i = 1; i <= n; i++) {... |
//Legal Notice: (C)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 do... |
#include <bits/stdc++.h> using namespace std; int n, k; int n1; vector<long long> v; int c[20]; int a[20]; bool viz[20]; int f[20]; inline void get(int i) { int cif = 0; long long zece = 1; long long r = 0; for (zece = 1; i > 0; i >>= 1, zece *= 10LL) { ++cif; if ((i & 1) !... |
#include <bits/stdc++.h> using namespace std; int n, k[110], v[110][110], t[110][110], res, s, i, j; int ktra(long long &s1, long long &s2, long long f1, long long f2, int &p) { int res = ((s1 - s2) * (f1 - f2) < 0) || ((s1 == s2) && (p * (f1 - f2) < 0)); if (f1 > f2) p = 1; if (f1 < f2) p = -1; s... |
#include <bits/stdc++.h> using namespace std; bool bin(unsigned long long a, unsigned long long b) { return a > b; } int main() { int n, k; scanf( %d %d , &n, &k); long inp; queue<long> seg; map<long, long> cnt; set<long> once; for (int y = 0; y < k; y++) { scanf( %ld , &inp); ... |
// Library - static, Cell - th24, View - schematic
// LAST TIME SAVED: May 23 16:39:19 2014
// NETLIST TIME: May 23 16:39:23 2014
`timescale 1ns / 1ns
module th24 ( y, a, b, c, d );
output y;
input a, b, c, d;
specify
specparam CDS_LIBNAME = "static";
specparam CDS_CELLNAME = "th24";
specparam CDS... |
#include <bits/stdc++.h> using namespace std; template <typename T> void print(T a) { for (auto x : a) cout << x << ; cout << n ; } vector<pair<long double, long double> > lines1; vector<long double> dots1; long double intersection(pair<long double, long double> l1, ... |
module tb_memories
(
input wire clk_i,
input wire reset_i,
input wire [15:0] xpm_addr_i,
output reg [31:0] xpm_data_o,
input wire [15:0] xdm0_addr_i,
input wire [15:0] xdm0_data_i,
input wire xdm0_wr_en_i,
output reg [15:0] xdm0_data_o,
input wire [15:0] xdm1_addr_i,
input wire [15:0... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const long long llinf = (long long)3e18; const int N = (int)1e5 + 111; const long double PI = (long double)acos(-1); int main() { int n, cur, num, ans = 0; scanf( %d , &n); vector<int> a(n); vector<char> us(n, 0); fo... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, nn; cin >> n; nn = n * 2; vector<int> arr(nn); for (int i = 0; i < nn; ++i) cin >> arr[i]; sort(arr.begin(), arr.end()); long long ans, now; ans = arr[nn - 1] - arr[n]; ... |
// (C) 2001-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 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> using namespace std; int n, m, INF = 2e9; vector<vector<int>> value; void shift_column(int j, int k) { vector<int> res(n); for (int i = 0; i < n; i++) res[(i - k + n) % n] = value[i][j]; for (int i = 0; i < n; i++) value[i][j] = res[i]; } void run() { cin >> n >> m; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, l, m, n, cnt = 0, ans = 0; char a[8][8]; for (i = 0; i < 8; i++) for (j = 0; j < 8; j++) cin >> a[i][j]; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { if (a[i][j] == B ) cnt++; } if (... |
#include <bits/stdc++.h> using namespace std; int n, r1, r2, t1, t2, f1 = 1, f2 = 1, col[100010]; vector<vector<int>> graph; bool dfs(const int &v, const int &from, const int &color) { if (col[v] != color) return 0; for (auto &i : graph[v]) if (i != from) if (!dfs(i, v, color)) return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1; i < n + 1; i++) { for (int j = 1; j < m + 1; j++) { if (i % 4 == 2) { if (j == m) { cout << # ; } else ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } template <typename T> ... |
#include <bits/stdc++.h> using namespace std; const double pi = 3.141592653589793238463; int x[1009], y[1009], t[1009]; double p[1009]; double dp[1009][1009]; int n; double sol(int i, int prev) { if (i == n) return 0; if (dp[i][prev] == dp[i][prev]) return dp[i][prev]; bool can = true; if ... |
#include <bits/stdc++.h> using namespace std; const int maxx = 2e5 + 10; char s[maxx], t[maxx]; int l[maxx], r[maxx]; int main() { cin >> s >> t; int m = strlen(s); int n = strlen(t); int a = 0, b = 0; for (int i = 0; i < m; i++) { if (s[i] == t[a]) { l[a] = i; a++; ... |
//Legal Notice: (C)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 associate... |
// test_simulation_mux_16_test.v
module f1_test(input [15:0] in, input [3:0] select, output reg out);
always @( in or select)
case (select)
0: out = in[0];
1: out = in[1];
2: out = in[2];
3: out = in[3];
4: out = in[4];
5: out = in[5];
6: out = in[6];
7: out = in[7];
8... |
#include <bits/stdc++.h> using namespace std; struct Data { int64_t value; int64_t supports; int64_t supportedBy; }; bool isTop(map<pair<int64_t, int64_t>, Data> const& cubes, pair<int64_t, int64_t> const& pos) { bool top = true; for (int64_t i = -1; i <= 1; ++i) { map<pai... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 04/30/2015 11:43:21 AM
// Design Name:
// Module Name: quadrature_encoder_tb
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependenci... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) const int mod = 1e9 + 7; using ll = int64_t; using namespace std; template <int MOD_> struct modnum { static constexpr int MOD = MOD_; static_assert(MOD_ > 0, MOD m... |
// iverilog -y .. -o tb-DataFifoBypass.vvp tb-DataFifoBypass.v
// vvp tb-DataFifoBypass.vvp
`timescale 1ns/1ns
module tb;
localparam W = 8;
localparam CYC = 10;
reg clk, rst;
reg idata_vld;
wire idata_rdy;
reg [W-1:0] idata;
wire odata_vld;
reg odata_rdy;
wire [W-1:0] odata;
D... |
#include <bits/stdc++.h> using namespace std; long long tree[100002] = {0}; long long findcf(long long ind) { long long sum = 0; while (ind > 0) { sum += tree[ind]; ind -= (ind & (-ind)); } return sum; } void update(long long ind, long long val) { while (ind <= 100000) { ... |
#include <bits/stdc++.h> using namespace std; struct node { bool w, l; int a[26]; node() { w = false; l = false; memset(a, -1, sizeof a); } }; node a[100030]; long long cnt; char second[100010]; void insert(long long n) { int curr = 0; int i = 0; while (curr <... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1}; int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; vector<int> adj[300010], val(300010, 1), vis(300010, 0), dis1(300010, 0), dis2(300010, 0); int myrandom(i... |
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995/2009 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; const int inf = 1e9 + 10; const long long INF = 4e18 + 10; const int maxn = 1 * 1e5 + 5; const int maxe = maxn; int a[maxn]; int p[maxn]; int n, m; bool check(long long t) { for (int i = 1; i <= n; ++i) p[i] = a[i]; int j = n; for (int i = 0; i... |
#include <iostream> #include <vector> #include <algorithm> #include <math.h> using namespace std; #define fi first #define se second #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define mk make_pair #define tests int t; cin >> t; while(t--) #define forn(i, ... |
/*
# fsm_app.v - Finite state machine to send out an example test, and process inputs
#
# Description: Finite state machine to exercise the JTAG UART.
# Note that this ignores the full/empty signals, so don't fill the buffer!
#
# Copyright (C) 2014 Binary Logic (nhi.phan.logic at gmail.com).
#
# This file... |
/**
* 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... |
// Lab 6
// Created by David Tran
// Last Modified 02-13-2014
// extras
`timescale 1 ms /1 us
`include "mult_2_2_4.v"
// Testbench Module
module four_bit_multiplier_tb (A0, A1, B0, B1);
output A0, A1, B0, B1;
reg A0, A1, B0, B1;
wire C0, C1, C2, C3;
reg t_A0 [5000:0];
reg t_A1 [5000:0];
reg t_B0 [5000... |
#include <bits/stdc++.h> const int N = 1e5 + 50; using namespace std; int n, m, h, tot, mx, maxn, ans; int a[N], b[N], cnt[N], num[N]; int read() { int s = 0, t = 1; char c; while (c < 0 || c > 9 ) { if (c == - ) t = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { ... |
/**
* $Id: red_pitaya_dfilt1.v -01-24 12:58:17Z matej.oblak $
*
* @brief Red Pitaya equalization filter.
*
* @Author Matej Oblak
*
* (c) Red Pitaya http://www.redpitaya.com
*
* This part of code is written in Verilog hardware description language (HDL).
* Please visit http://en.wikipedia.org/wiki/Verilog
* ... |
#include <bits/stdc++.h> using namespace std; const int mN = 222222; int n; int a[mN], outa[mN], outb[mN], ge[mN]; vector<int> ans; struct Bit { int c[mN]; void clear() { memset(c, 0, sizeof(c)); } int lob(int x) { return x & (-x); } void add(int x, int dt) { while (x <= n) { c... |
//
///////////////////////////////////////////////////////////////////////////////////////////
// Copyright © 2011-2012, Xilinx, Inc.
// This file contains confidential and proprietary information of Xilinx, Inc. and is
// protected under U.S. and international copyright and other intellectual property laws.
//////////... |
/**
* 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() { int a1, a2, b1, b2, c1, c2; while (scanf( %d%d%d%d%d%d , &a1, &b1, &c1, &a2, &b2, &c2) != EOF) { if (a1 == 0 && b1 == 0 && c1 != 0) { printf( 0 n ); continue; } if (a2 == 0 && b2 == 0 && c2 != 0) { printf( 0... |
#include <bits/stdc++.h> using namespace std; mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count()); char mat[105][105]; void solve() { int n, m, horizontal; cin >> n >> m >> horizontal; int vertical = n * m / 2 - horizontal; int oxe = 0, nte = 0; char cc = e ; if (n ... |
#include <bits/stdc++.h> using namespace std; long long segs[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}; int n, m, k; long long a[200005]; vector<pair<int, int> > q; int res[200005]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) { ... |
`timescale 1ns / 1ps
module Processor(clk,Reset,inst,pss,wa,imme,dat, a, b,sb,add,val,rr);
input clk, Reset;
output [31:0] inst;
output [31:0] pss;
output [4:0] wa;
output [31:0] imme;
output [31:0] dat;
output [31:0] a,b;
output sb;
output [4:0] add;
output [31:0]val,rr;
reg [0:0] newClock;
reg [5... |
#include <bits/stdc++.h> using namespace std; int main() { int A1, B1, C1, A2, B2, C2; cin >> A1 >> B1 >> C1 >> A2 >> B2 >> C2; if (A1 * B2 != A2 * B1) cout << 1 << endl; else { if (A1 != 0 && A2 != 0 && A2 * C1 == A1 * C2) cout << -1 << endl; else if (A1 != 0 && A2 != 0) ... |
/*
* Copyright (c) 2014, Olof Kindgren <>
* All rights reserved.
*
* Redistribution and use in source and non-source forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this lis... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int i, j, temp, d = 0; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (a[i] > a[j]) { temp = a[j]; a[j] = a[i... |
/*
* Copyright 2017 Google 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 10:34:57 03/28/2014
// Design Name: shift
// Module Name: D:/XilinxProject/CPU/shift_test.v
// Project Name: CPU
// Target Device:
// Tool versions:
// Descripti... |
#include <bits/stdc++.h> using namespace std; int i, m; string a, s; int main() { cin >> a >> s; m = s.size(); sort(s.begin(), s.end()); for (m--; i < a.size(); i++) { if (a[i] < s[m]) a[i] = s[m--]; } cout << a; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int t = n % 4; int a = 0; for (int i = 0; i < 4; i++) { if ((i * 7) % 4 == t) a = i; } int b = -1, c; for (int j = (n - a) / 4 * 4 + a; j >= a; j -= 4) { if ((n - 7 * j) % 4 == 0 && (n - 7 * j >= ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.