text
stringlengths
59
71.4k
module serial_rx #( parameter CLK_PER_BIT = 50, parameter CTR_SIZE = 6 )( input clk, input rst, input rx, output [7:0] data, output new_data ); localparam STATE_SIZE = 2; localparam IDLE = 2'd0, WAIT_HALF = 2'd1, WAIT_FULL = 2'd2, WAIT_HIGH = 2'd3; reg [CTR_SIZE-1:0] ctr_d, ctr_q; reg [2:0...
#include <bits/stdc++.h> using namespace std; bool G[30][30]; int main() { int T; scanf( %d , &T); while (T--) { int n, p; scanf( %d%d , &n, &p); memset(G, 0, sizeof(G)); for (int i = 0; i < n; ++i) G[i][(i + 1) % n] = G[(i + 1) % n][i] = G[i][(i + 2) % n] = ...
#include <bits/stdc++.h> using std::bitset; using std::cerr; using std::cin; using std::complex; using std::cout; using std::deque; using std::endl; using std::ios_base; using std::iterator; using std::map; using std::max; using std::max_element; using std::min; using std::min_element; usi...
#include <bits/stdc++.h> using namespace std; int Gcd(int x, int y) { while (x > 0 && y > 0) { if (x > y) { x = x % y; } else { y = y % x; } } return x + y; } int Sign(int x) { return (x > 0) ? 1 : -1; } int Abs(int x) { return (x > 0) ? x : -x; } void ReduceFra...
/** * 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; typedef long long ll; ll n,m,pos,qwq,delta,a[1009],b[1009],p[1009][1009]; inline ll read(){ ll s = 0,w = 1; char ch = getchar(); while (ch > 9 || ch < 0 ){ if (ch == - ) w = -1; ch = getchar();} while (ch <= 9 && ch >= 0 ) s = (s << 1) + (s << 3) +...
#include <bits/stdc++.h> const double pi = acos(-1); using namespace std; vector<int> v; int c[1000000]; int main() { int n; double h; cin >> n >> h; double s = h / (2 * double(n)); for (int i = 1; i < n; i++) { printf( %.10f n , sqrt(s * 2 * h * i)); } return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; int s[2], t[200007][2]; int x[200007]; int n, m, st[200007]; int absi(int x) { return x > 0 ? x : -x; } int main() { cin >> n >> m; for (int i = 0; i < n; i++) scanf( %d , &x[i]); memset(s, 0, sizeof(s)); memset(t, 0, s...
#include <bits/stdc++.h> using namespace std; char c; int v[300], a; int main() { v[ > ] = 0; v[ < ] = 1; v[ + ] = 2; v[ - ] = 3; v[ . ] = 4; v[ , ] = 5; v[ [ ] = 6; v[ ] ] = 7; while (cin >> c) a = (a * 16 + 8 + v[c]) % 1000003; cout << a << 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 law...
/* * 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<iostream> #include<string> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #include<iomanip> #include<map> #include<cstdio> #include<stack> #include<set> using namespace std; #define endl n #define IOS ios::sync_with_stdio(false),cin.tie(0), cout.tie(0) typ...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { while (y > 0) { x %= y; swap(x, y); } return x; } template <class _T> inline _T sqr(const _T& x) { return x * x; } template <class _T> inline string tostr(const _T& a) { ostringstream ...
// DESCRIPTION: Verilator: Verilog Test module // // Copyright 2011 by Wilson Snyder. This program is free software; you can // redistribute it and/or modify it under the terms of either the GNU // Lesser General Public License Version 3 or the Perl Artistic License // Version 2.0. module t (/*AUTOARG*/ // Inputs ...
/* This file is part of JT12. JT12 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. JT12 program is distributed...
/* Cross Clock Module Tested and check * * Creates a FIFO that sits between two clock domains. Read and write are * both asynconous and can occur at the same time. The FIFO does check if * it is full/empty before writing/reading. * * Created by David Tran * Version 0.1.0.0 * Last Modified:05-03-2014 */ module...
//wishbone_interconnect.v /* Distributed under the MIT licesnse. Copyright (c) 2011 Dave McCoy () Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps mod...
#include <bits/stdc++.h> using namespace std; long long m; long long a[100005], b[100005], c[100005], ans[100005]; bool prime[100005]; vector<long long> pvec; long long modpow(long long a, long long n) { if (n == 0) return 1; if (n % 2) { return ((a % 998244353) * (modpow(a, n - 1) % 998244353...
/** * 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; typedef vector<vector<int>> graph; ifstream in( buffcraft.in , ios::in); ofstream out( buffcraft.out , ios::out); int main() { double m, R, ans = 0; cin >> m >> R; for (int x = 2; x < m; x++) ans += ((x - 1) * 2 + 2 * sqrt(2.0)) * 2 * (m - x); ...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const int K = 3; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int ans = -1; for (int i = 1; i <= n; ++i) { long long int x; cin >> x;...
#include <bits/stdc++.h> int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); int k; int a[n]; for (k = 0; k < n; k++) scanf( %d , &a[k]); int p = n - 2; int i, j; for (i = 0; i < p; i++) { for (j = i + 2; j < n; j++) { ...
#include <bits/stdc++.h> using namespace std; int a, b, c, s; vector<double> x, y11, z; double rx, ry, rz, mn = -1000000000; double mln(double x) { return log(x); } void upd(double nx, double ny, double nz) { if (nx + ny + nz > (s + 1e-7)) return; double cur = 0; if (a) cur += a * mln(nx); i...
// // Copyright 2011-2012 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 i...
// mbt 2-16-16 `include "bsg_defines.v" module bsg_rocket_core_fsb import bsg_fsb_packet::RingPacketType; #(parameter nasti_destid_p="invalid" , parameter htif_destid_p ="invalid" , parameter htif_width_p = 16 , parameter ring_width_lp=$size(RingPacketType)) (input clk_i , input reset_i ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: sctag_cpx_rptr_1.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 ...
// 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 Apr 09 07:02:41 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; map<int, int> mp; const int N = 1e5 + 3, M = 2e5 + 3; int b[N], st[N], tp, he[N], to[M], ne[M], d[N], a[N]; bool f[N]; void dfs(int x) { for (int i, j; i = he[x];) if (he[x] = ne[i], !f[j = i >> 1]) f[j] = 1, dfs(to[i]), st[++tp] = i; } int main() ...
#include <bits/stdc++.h> char ar[10][10]; int q[10 * 10 * 10 * 10][3]; bool forb[10][10][10 * 10]; bool used[10][10][10 * 10]; int dir[9][2] = {{1, 1}, {1, 0}, {1, -1}, {0, 1}, {0, 0}, {0, -1}, {-1, 1}, {-1, 0}, {-1, -1}}; void BFS(void) { int x = 8, y = 1; q[1][0] = x; q[1...
#include <bits/stdc++.h> using namespace std; const long long MODULO = 1000000007; void ftime() {} void print_arr(int n, bool arr[]) { for (int i = 0; i < n; i++) { cout << arr[i] << ; } cout << n ; } void print_arr(int n, int arr[]) { for (int i = 0; i < n; i++) { cout << a...
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { int n; unsigned int a[200]; unsigned int ans; scanf( %d , &n); ans = 0; for (int i = 0; i < n; i++) scanf( %u , &a[i]); for (int i = 0; i < n; i++) { unsigned int temp = a[i]; if (temp > ans) ans...
module ram( input clk, input we, input [ADDR_WIDTH - 1 : 0] waddr, input [DATA_WIDTH - 1 : 0] d, input re, input [ADDR_WIDTH - 1 : 0] raddr, output [DATA_WIDTH - 1 : 0] q ); parameter ADDR_WIDTH = 8; parameter DATA_WIDTH = 16; localparam DEP...
// Copyright 2020 The XLS 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 t...
/** * 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[100004], d[32]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < n; j++) { int x = a[j]; for (int i = 0; x > 0; i++) { d[i] += x % 2; x /= 2; } } in...
////////////////////////////////////////////////////////////////////// //// //// //// Generic Single-Port Synchronous RAM //// //// //// //// This file is part of memory li...
module top; reg pass; integer result; reg [3:0] expr; reg bval; initial begin pass = 1'b1; result = $countbits(1'bx, 1'bx); if (result != 1) begin $display("FAILED: for 1'bx/x expected a count of 1, got %d", result); pass = 1'b0; end result = $countbits(2'bxx, 1'bx); if ...
#include <bits/stdc++.h> using namespace std; bool primes[1000007]; void sieve(int n) { for (long long i = 2; i <= n; i++) { if (primes[i]) continue; for (long long j = i * i; j <= n; j += i) { primes[j] = 1; } } } int main() { int n; cin >> n; sieve(1e6); whi...
/* Copyright (c) 2014 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,...
#include <bits/stdc++.h> using namespace std; long long int fib[51]; vector<long long int> calc(long long int n, long long int k) { vector<long long int> res; if (!n) return res; if (n == 1) { res.push_back(1); return res; } if (k <= fib[n - 1]) { res.push_back(1); vect...
/////////////////////////////////////////////////////////////////////////////// // 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 // //...
module DataPath ( input wire b_sel, input wire a_sel, input wire add_sel, input wire prod_sel, input wire [31:0]Data_A, input wire [31:0]Data_B, input wire Shift_Enable, input wire Clock, input wire Reset, output reg [63:0]Prod, output wire oB_LSB ); //-------------PARA B-----------------// wire [31:0]Mux_...
#include <bits/stdc++.h> using namespace std; const long long N = 10000000; long long n, a, b; long long dp[N + 1]; signed main() { cin >> n >> a >> b; dp[0] = 0; for (long long i = 1; i <= n; i++) if (i & 1) dp[i] = min(dp[i - 1] + a, dp[i + 1 >> 1] + a + b); else dp[i...
// // Paul Gao 02/2021 // // This module generates 180-degree-phase-shifted clock (inverted clock) // // Input clock runs at 1x speed // Output clock is generated with XOR logic // Waveform below shows the detailed behavior of the module // // THIS MODULE SHOULD BE HARDENED TO IMPROVE QUALITY OF CLK_O // /...
#include <bits/stdc++.h> using namespace std; vector<string> solve(int k) { vector<string> s; if (k == 0) { s.push_back( + ); return s; } vector<string> prev = solve(k - 1), rev; for (int i = 0; i < prev.size(); i++) { string temp; for (int j = 0; j < prev.size(); j++) { ...
//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...
// (C) 1992-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 simulati...
#include <bits/stdc++.h> struct event { int t, time, L, R, idx; event() {} event(int t, int time, int L, int R, int idx) : t(t), time(time), L(L), R(R), idx(idx) {} bool operator<(const event& a) const { return (time < a.time || (time == a.time && t < a.t)); } } e[200005 * 23]; i...
////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, All Rights Reserved // // 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 ...
/** * 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, arr[100000], r, arr1[100000], z; bool boo[100000]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> r; arr[i] = r; } for (int i = 0; i < n; i++) arr1[i] = arr[i]; reverse(arr1, arr1 + n); z = arr1[0]; boo[0] ...
`include "../../../rtl/verilog/gfx/gfx_rasterizer.v" `include "../../../rtl/verilog/gfx/gfx_line.v" `include "../../../rtl/verilog/gfx/gfx_triangle.v" `include "../../../rtl/verilog/gfx/div_uu.v" module raster_bench(); parameter point_width = 16; parameter subpixel_width = 16; reg clk_i; reg rst_i; reg clip_ack_i; 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 law...
#include <bits/stdc++.h> using namespace std; const int N = 505; const int mod = 1000000007; int a, b, c, d, e, f, g, h, i, j; int Mi[N * N]; int F[N][N], K; void Work() { Mi[0] = 1; for (int ii = 1; ii <= a * a; ii++) Mi[ii] = (Mi[ii - 1] << 1) % mod; F[0][0] = 1; for (int ii = 1; ii <= a...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2012 by Iztok Jeras. module t (/*AUTOARG*/ // Inputs clk ); input clk; // parameters for vector sizes localparam WA = 8; // address dimension size localparam ...
module test( input clk, wen, input [7:0] uns, input signed [7:0] a, b, input signed [23:0] c, input signed [2:0] sel, output [15:0] s, d, y, z, u, q, p, mul, div, mod, mux, And, Or, Xor, eq, neq, gt, lt, geq, leq, eqx, shr, sshr, shl, sshl, Land, Lor, Lnot, Not, Neg, pos, Andr, Orr, Xorr, Xnorr, Reduce_bool, ...
/** * 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 fsm ( clock, reset, req_0, req_1, gnt_0, gnt_1 ); input clock,reset,req_0,req_1; output gnt_0,gnt_1; wire clock,reset,req_0,req_1; reg gnt_0,gnt_1; parameter SIZE = 3; parameter IDLE = 3'b001; parameter GNT0 = 3'b010; parameter GNT1 = 3'b100; parameter GN...
#include <bits/stdc++.h> using namespace std; const int N = 8e5 + 100; struct Bit { int bit[N], n; int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i, int x) { while (i <= n) { bit[i] += x; ...
#include <bits/stdc++.h> using namespace std; int nn, n, b, q; vector<pair<int, int> > d; int main() { d.push_back(make_pair(0, 0)); scanf( %d%d%d , &n, &b, &q), nn = n; d.push_back(make_pair(b, n)); for (int i = 1; i <= q; i++) scanf( %d%d , &b, &n), d.push_back(make_pair(b, n)); sort...
/*--------------------------------------------------------------------------------------------------------------------- -- Author: Peter Hasza, -- -- Create Date: 04/02/2017 -- Module Name: apb_reg_if -- Project Name: AXI_SPI_IF -- Description: -- APB Slave module for register interfa...
#include <bits/stdc++.h> using namespace std; long long a[200010]; long long l[200010]; long long r[200010]; int main() { ios_base::sync_with_stdio(0); long long n, h; cin >> n >> h; vector<long long> rast2(n + 1, 0); for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; rast2[i]...
#include <bits/stdc++.h> using namespace std; template <class T> const T& max(const T& a, const T& b, const T& c) { return max(a, max(b, c)); } template <class T> const T& min(const T& a, const T& b, const T& c) { return min(a, min(b, c)); } void sc(int& a) { scanf( %d , &a); } void sc(long lo...
module OK_WB_Bridge( input wire [30:0] ok1, output wire [16:0] ok2, input wire ti_clk, input wire clk_i, input wire rst_i, input wire stb_i, input wire [7:0] adr_i, input wire we_i, input wire [31:0] dat_i, output wire [31:0] dat_o ); // Wire declarations wire OKfifow...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { return !b ? a : gcd(b, a % b); } template <typename T> T lcm(T a, T b) { return a * (b / gcd(a, b)); } template <typename T> T sqr(T a) { return a * a; } template <typename T> T cube(T a) { retu...
#include <bits/stdc++.h> using namespace std; int maxPrime[10000005]; long long cnt_prime[10000005]; int primes[10000005]; int cnt_p; void init() { for (int i = 2; i < 10000005; i += 2) maxPrime[i] = 2; for (int i = 3; i * i < 10000005; i += 2) { if (maxPrime[i] == i || maxPrime[i] == 0) { ...
#include <bits/stdc++.h> using namespace std; const long double pi = 3.1415926535897932384626433832795l; template <typename T> inline auto sqr(T x) -> decltype(x * x) { return x * x; } template <typename T1, typename T2> inline bool umx(T1& a, T2 b) { if (a < b) { a = b; return 1; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
//================================================================================================== // Filename : uart_tx.v // Created On : 2015-01-08 19:21:16 // Last Modified : 2015-05-24 21:04:24 // Revision : 1.0 // Author : Angel Terrones // Company : Universidad Simón Bolívar // ...
/* * 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...
`timescale 1 ns / 1 ps //Input clock 125 MHz module dac_control ( input clk, input enable_update, input enable, input [7:0]dbA, input [7:0]dbB, input [7:0]dbC, input [7:0]dbD, output reg [7:0]db, output wire clr_n, output wire pd_n, output reg cs_n, output reg wr_n, output reg [1:0]A, output...
#include <bits/stdc++.h> int main() { int cnt = 0, f[4], i, j, x[200], y[200], n; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d %d , &x[i], &y[i]); } for (i = 0; i < n; i++) { f[1] = 0; f[2] = 0; f[3] = 0; f[0] = 0; for (j = 0; j < n; j++) { if (j...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; for (int i = 0; i < t; i++) { long long n, k; cin >> n >> k; if (n < k * k) { cout << NO << n ; } else if (n % 2 != k % 2) { cout << NO <...
#include <bits/stdc++.h> using namespace std; int num[500005]; int maps[500005]; int to[500005]; int main() { ios::sync_with_stdio(0); int n, m; int l, r; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &num[i]); to[num[i]] = i; } for (int i = 1; i <= ...
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int dx[] = {0, 0, 1, -1}; long long int dy[] = {1, -1, 0, 0}; long long int m = 0, n, res = 0, k; string s2, ch = , s, t, s1 = ; vector<pair<string, long long int> > vm; vector<pair<pair<long long int, long long int...
#include <bits/stdc++.h> using namespace std; int main() { long long n; scanf( %lld , &n); long long a, b, c; scanf( %lld , &a); scanf( %lld , &b); scanf( %lld , &c); if (a <= (b - c)) { printf( %lld n , n / a); } else { n -= b; long long x = 0; if (n >= 0) { ...
//----------------------------------------------------------------------------- // // (c) Copyright 2009-2010 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...
// // Copyright 2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
#include <bits/stdc++.h> using namespace std; void solve(string s) { int n = s.size(); s = # + s; vector<int> pi(n + 1); pi[0] = 0, pi[1] = 0; for (int i = 2; i <= n; i++) { int j = pi[i - 1]; while (j > 0 && s[i] != s[j + 1]) j = pi[j]; if (s[i] == s[j + 1]) j++; pi[i]...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ /** * Reference: * Nestoras Tzartzanis, EE 577B Verilog Example, Jan 25, 1996 * http://www-scf.usc.edu/~ee577/tutorial/verilog/counter.v */ // Behavioral model for the 32-bit program counter module ...
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) { cerr << n ; } template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << setw(2) << *it << = << setw(2) << a << ; err(++it, args...); } void solve() { in...
#include <bits/stdc++.h> const int MN = 1e5 + 4, INF = 0x3f3f3f3f; int N, R, M, ans, D, A[MN], depth[MN], ord[MN], ecnt, ein[MN], eout[MN], st[MN]; std::vector<int> adj[MN]; struct nd { int l, r, val; nd *ch[2]; nd() : l(0), r(0), val(INF), ch{0} {} } * sgt[MN]; void dfs(int src, int p, int d) {...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int t; cin >> t; while (t--) { int n; cin >> n; int ar[n]; for (int i = 0; i < n; i++) { cin >> ar[i]; --ar[i]; } ...
#include <bits/stdc++.h> using namespace std; long long int dx[4] = {-1, 0, 0, +1}; long long int dy[4] = {0, -1, +1, 0}; const long long int LINF = 1e18; const long long int INF = 1e9; const long long int mod = 1e9 + 7; long long int power(long long int a, long long int b, long long int m) { if (b ==...
//****************************************************************************/ // AMBA conponents // RTL IMPLEMENTATION, Synchronous Version // // Copyright (C) yyyy Ronan Barzic - // Date : Mon Nov 9 10:03:03 2015 // // This program is free software; you can redistribute it and/or // modify it un...
#include <bits/stdc++.h> using namespace std; int n, a, b, x, r; int main() { for (cin >> n >> a >> b, r = n; x * a <= n; x++) r = min(r, (n - x * a) % (5 * b)); cout << r; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 100; int n, x, a; int f[MAXN + 1]; int main() { cin >> n >> x; memset(f, 0, sizeof f); for (int i = 0; i < n; i++) { cin >> a; f[a] = 1; } int ans = 0; for (int i = 0; i < x; i++) { if (f[i] == 0) ans++; ...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; namespace Xrocks {} using namespace Xrocks; namespace Xrocks { class in { } user_input; class out { } output; in& operator>>(in& X, int& Y) { scanf( %d , &Y); return X; } in& operator>>(in& X, char* Y) { sc...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
#include <bits/stdc++.h> using namespace std; template <typename T> T in() { char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == - ) { ng = true; ch = getchar(); break; } if (ch >= 0 && ch <= 9 ) break; } while (1) { ...
#include <bits/stdc++.h> using namespace std; int n, m, dp[30010][210][4], num[30010]; int main() { int i, j; cin >> n >> m; for (i = 1; i <= n; i++) scanf( %d , &num[i]); memset(dp[0], -0x3f, sizeof(dp[0])); for (i = 0; i < 4; i++) dp[0][0][i] = 0; for (i = 1; i <= n; i++) { for (j ...
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, m; cin >> n >> m; long long int n1, m1; cin >> n1 >> m1; long long int a[n], b[m]; for (long long int i = 0; i < n; i++) cin >> a[i]; for (long long int i = 0; i < m; i++) cin >> b[i]; if (a[n1 - 1] < b[m -...
#include <bits/stdc++.h> using namespace std; const int N = 11; const long long MOD = 1000000007LL; int dp[N][N][3]; long long t[N][N]; int cnt[N], c[N]; int n; string s; long long ans = 0; void init() { for (int i = 0; i <= n; ++i) { for (int k = 1; k <= 6; ++k) { if (cnt[i] < k) ...
`include "defines.v" module cp0_reg( input wire clk, input wire rst, input wire we_i, input wire[4:0] waddr_i, input wire[4:0] raddr_i, input wire[`RegBus] data_i, input wire[31:0] excepttype_i, input wire[5: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...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: pcx_buf_fpio.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 and/...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; vector<long long int> graph[250]; long long int n, a[250]; long long int visit[250]; long long int sol(long long int pos) { memset(visit, 0, sizeof(visit)); long long int ans = 0; long long int c = 0; while (c <= n) { long long int f = 0; ...
module EX( input [31:0] PC_ID_EX_out, input [31:0] PC_IF_ID, input [1:0] ExResultSrc, input ALUSrcA, input ALUSrcB, input [3:0] ALUOp, input [1:0] RegDst, input ShiftAmountSrc, input [1:0] ShiftOp, input [31:0] A_in, input [31:0] B_in, input [4:0] Rs,Rt,Rd, input [31:0] Imm32, input [4:0] Shamt, input [7:0] A_in_sel, ...