text
stringlengths
59
71.4k
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.1 (lin64) Build 881834 Fri Apr 4 14:00:25 MDT 2014 // Date : Wed Apr 30 22:30:36 2014 // Host : macbook running 64-bit Arch Linux // ...
`timescale 1 ns / 1 ns ////////////////////////////////////////////////////////////////////////////////// // Company: Rehkopf // Engineer: Rehkopf // // Create Date: 01:13:46 05/09/2009 // Design Name: // Module Name: address // Project Name: // Target Devices: // Tool versions: // Description: Address logic w/ S...
module RetimeShiftRegister #( parameter WIDTH = 1, parameter STAGES = 1) ( input clock, input reset, input [WIDTH-1:0] in, output reg [WIDTH-1:0] out ); integer i; reg [WIDTH-1:0] sr[STAGES]; // Create 'STAGES' number of register, each 'WIDTH' bits wide /* synopsys dc_tcl_script_begin ...
/* * 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 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; const int N = 3e3 + 10; int n; int a[N], b[N]; long long dp[N][N]; long long solve(int idx = 0, int val = 0) { if (idx == n) return 0; if (val == n) return 1e18; long long &ret = dp[idx][val]; if (ret == -1) ret = min(solve(idx + 1, val) + ...
// // 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...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. //------------------------------------------------------------------------------ // SHARED CODE //------------------------------------------------------------------------------ // No shared code for ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2003 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; reg [15:...
/** * 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 dp[3000]; bool apare[1010]; int n, k, c; int main() { ios_base ::sync_with_stdio(0); cin >> n >> k; while (k--) { cin >> c; apare[c] = 1; } queue<int> q; vector<int> lungimi; for (int i(0); i < 1010; i++) { if (!ap...
#include <bits/stdc++.h> using namespace std; const long long max_N = 100003; const long long max_M = 200003; vector<pair<long long, long long> > briaunos[max_N]; bool nepavyko_uzdavinys = false; struct reiskinys { long long skaicius, a; long double a_reiksme; bool isreikstas; bool isvestas;...
module tb_comm_fpga_fx2_v2; reg clk_in; reg reset_in; wire fx2FifoSel_out; reg [7:0] fx2Data_in; wire [7:0] fx2Data_out; wire fx2Data_sel; reg fx2Read_out; reg fx2GotData_in; reg fx2Write_out; reg fx2GotRoom_in; reg fx2PktEnd_out; reg [6:0] chanAddr_out; reg [7:0] h2fData_out; reg h2fValid_out; reg h2fReady_in; reg [7...
//Legal Notice: (C)2014 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> int main() { double n2, a, b, c, n1; scanf( %lf %lf %lf , &a, &b, &c); n1 = ((-b + pow((b * b - 4 * a * c), 0.5)) / (a * 2)); n2 = ((-b - pow((b * b - 4 * a * c), 0.5)) / (a * 2)); if (n1 >= n2) printf( %lf %lf , n1, n2); else printf( %lf %lf , n2, n1); ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, k, par[N], siz[N]; bool inv[N]; multiset<int> S; struct dist { int val, id; }; dist tab[N]; bool cmp(dist x, dist y) { return x.val < y.val; } int Find(int x) { if (par[x] != x) par[x] = Find(par[x]); return par[...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #define ffor(i,a,b) for(int i=a;i<b;i++) #define bfor(i,a,b) for(int i=a-1;i>=b;i--) #define mp make_pair #define pb push_back #define ff first #define ss second #define mem(x,y) memset(x,y,sizeof(x)) #def...
// megafunction wizard: %FIFO%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo_mixed_widths // ============================================================ // File Name: rxlengthfifo_128x13.v // Megafunction Name(s): // dcfifo_mixed_widths // // Simulation Library Files(s): // altera_...
#include <bits/stdc++.h> using namespace std; long long n, res, dpa[4005][4005], s[4005], c[4005][4005]; long long combo(long long x, long long y) { if (c[x][y] != 0) return c[x][y]; if (y == 0 || x == y) return c[x][y] = 1; if (x == 0 || x < y) return 0; return c[x][y] = (combo(x - 1, y - 1) + co...
#include <bits/stdc++.h> using namespace std; const int N = 110; int T, mod = 1e9 + 7, n, k, deep[N], timer, sz; long long ans, fact[N], mem[N][N], vis[N][N]; vector<int> adj[N], v; map<int, int> mp[N]; void _clear() { ans = 0; for (int i = 1; i <= n; i++) adj[i].clear(); } long long po(long l...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 04.03.2016 14:20:17 // Design Name: // Module Name: LUT_Z // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revisio...
///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE Connection Matrix Priority Decoder //// //// //// //// ...
#include <bits/stdc++.h> using namespace std; void read(int& x) { bool fu = 0; char c; for (c = getchar(); c <= 32; c = getchar()) ; if (c == - ) fu = 1, c = getchar(); for (x = 0; c > 32; c = getchar()) x = x * 10 + c - 0 ; if (fu) x = -x; }; char getc() { char c; for (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...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, j, k, p, t, a = 0, b = 0; cin >> n; vector<long long int> vec; for (i = 0; i < n; i++) { cin >> p; if (p % 2 == 0) a++; else b++; vec.push_back(p); } if (a == 0 || b == 0) {...
//############################################################################# //# Function: 7:1 one hot mux # //############################################################################# //# Author: Andreas Olofsson # ...
module top; reg passed = 1'b1; wire out, cout0, cout1; reg sel, in_1, in_0; reg pout; assign cout0 = sel ? 1'bz : in_0; assign cout1 = sel ? in_1: 1'bz; assign out = sel ? in_1: in_0; task automatic check; input bit, in_1, in_0; input [63:0] comment; begin if (sel === 1'b1) begin ...
//*******************************************************************************************************************************************************/ // Module Name: control_matrix // Module Type: Moore State Machine // Author: Shreyas Vinod // Purpose: Control Matrix for Neptune I v3.0 // Description: A Moor...
module NIOSCar( //////////// CLOCK ////////// CLOCK_50, //////////// LED ////////// LED, //////////// KEY ////////// KEY, //////////// SW ////////// SW, //////////// SDRAM ////////// DRAM_ADDR, DRAM_BA, DRAM_CAS_N, DRAM_CKE, DRAM_CLK, DRAM_CS_N, DRAM_DQ, DRAM_DQM, DRAM_RAS_...
#include <bits/stdc++.h> using namespace std; const int N = 51; vector<int> g[N]; int n, sz[N], dp[N][N][N][N], s, m, ans = 1e9, cost[N][N], temp[N]; void dfs(int u, int p) { for (auto i : g[u]) if (i != p) dfs(i, u), sz[u] += sz[i]; } int calc(int from, int to, int behind, int front) { if (...
#include <bits/stdc++.h> using namespace std; const int N = 103, M = 998244353; const int mod = M - 1; struct matrix { int row, col; int a[N][N]; matrix() { memset(a, 0, sizeof a); } matrix(int r, int c) : row(r), col(c) { memset(a, 0, sizeof a); } matrix operator*(const matrix &p) { a...
#include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 5; const int mod = 998244353; inline long long fpm(long long a, long long p) { long long r = 1; while (p) { if (p & 1) r = r * a % mod; a = a * a % mod; p /= 2; } return r; } int k, n, m; int s[maxn][max...
`timescale 1ns/1ps module SensorFSM #( parameter DataWidth = 8 ) ( input Reset_n_i, input Clk_i, // top level input Enable_i, output reg CpuIntr_o, output [2*DataWidth-1:0] SensorValue_o, // to/from Measure-FSM ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// module weight(CLK ,RST,ED,START, DReal,DImag, DOReal, DOImag,RDY ); parameter total_bits = 32; input CLK; input RST; input ED; input START; output reg RDY; input [total_bits-1:0] DReal; input [total_bits-1:0] DIm...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int a = abs(x1 - x2); int b = abs(y1 - y2); int u = min(a, b); cout << u + abs(a - b); return 0; }
/////////////////////////////////////////////////////////////////////////////// // Title : alt_mem_ddrx_mm_st_converter // // File : alt_mem_ddrx_mm_st_converter.v // // Abstract : take in Avalon MM interface and convert it to single cmd and // multiple data Avalon ST // /////////...
#include <bits/stdc++.h> using namespace std; int n, k, a[((int)1001 * 1000)], maxi, mini; vector<int> v; int jaghool; bitset<((int)1001 * 1000)> dp, mark; int main() { scanf( %d%d , &n, &k); int k2 = k; for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) if (...
#include <bits/stdc++.h> using namespace std; int ans; int visited[1001]; int cc = 0; vector<int> arr[1001]; void dfs(int node) { visited[node]++; if (visited[node] == 2) { ans = node; return; } for (auto child : arr[node]) { if (visited[node] < 2) dfs(child); } } i...
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int n, m; int a[110], b[110]; int main() { while (~scanf( %d%d , &n, &m)) { mp.clear(); for (int i = 0; i < (n); ++i) scanf( %d , a + i); for (int i = 0; i < (m); ++i) { string s; cin >> s; mp[s]++...
/******************************************************************************* * * * Copyright (C) 2009 Altera Corporation * * ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const unsigned long long MAX = LONG_MAX; void fasterIO() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int sumDig(int a) { int sum = 0; while (a != 0) { sum += a % 10; a /= 10; } retur...
/* Este modulo esta encargado de ejecutar las operaciones principales que cada instruccion debe realizar ademas es el que envia los datos y la direccion a la memoria de datos para ser almacenados. */ module ALU( input wire[15:0] wInstruction, input wire[7:0] iA, input wire [7:0] iB, output reg oRamEnableWrit...
#include <bits/stdc++.h> using namespace std; int get() { char ch; while (ch = getchar(), (ch < 0 || ch > 9 ) && ch != - ) ; if (ch == - ) { int s = 0; while (ch = getchar(), ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0 ; return -s; } int s = ch - 0 ; while (ch ...
module gpio_tx( #( parameter GPIO_DATA_WIDTH = 8 ) ( //gpio_wr_interface output [GPIO_DATA_WIDTH-1:0] gpio_rd_data, output gpio_rd_par, input gpio_rd_err, output gpio_rd_req, input gpio_rd_ack, //gpio_fifo_interface input [GPIO_DATA_WIDTH-1:0] gpio_n2p_data, input gpio_n2p_...
`define WINDOW_SIZE ((2**WINDOW_WIDTH)) `define LARGE_CLOG2(x) clog2(x) `define MAXIMUM_ROLLING_SUM ((2**WIDTH)-1) `define MAXIMUM_ROLLING_SQUARES_SUM (pow(2,(WIDTH*2))-1) `include "math.v" module variance #( parameter WIDTH=14, // data input width parameter WINDOW_WIDTH=7 // window size will be 2^WINDOW_WIDTH...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `include "std_ovl_defines.h" `module ovl_never_unknown_async (reset, enable, test_expr, fire); parameter severity_level = `OVL_SEVERITY_DEFAULT; parameter width = 1; parameter propert...
`define bsg_mem_1rw_sync_mask_write_bit_macro(words,bits) \ if (els_p == words && width_p == bits) \ begin: macro \ hard_mem_1rw_bit_mask_d``words``_w``bits``_wrapper \ mem \ (.clk_i ...
#include <bits/stdc++.h> using namespace std; map<long long, int> cnt; int lp[100005]; long long p[100005][102]; void sieve() { for (int i = 2; i <= 100000; i++) { if (!lp[i]) { lp[i] = i; for (int j = i + i; j <= 100000; j += i) if (!lp[j]) lp[j] = i; } } } i...
#include <bits/stdc++.h> using namespace std; int n, root; vector<vector<int> > tree, par, sub; vector<vector<long long> > dp; void dfs(int u) { sub[root][u] = 1; for (int v : tree[u]) { if (v == par[root][u]) continue; par[root][v] = u; dfs(v); sub[root][u] += sub[root][v]; ...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 5; int n, k, a; int vis_time[MAX], vis_cnt[MAX], ans; struct data { int size, op; bool operator<(data b) const { if (size == b.size) return op > b.op; else return size < b.size; } }; priority_queue<...
/* * 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...
module fifo_address_gray ( input m_axis_aclk, input m_axis_aresetn, input m_axis_ready, output reg m_axis_valid, output [C_ADDRESS_WIDTH-1:0] m_axis_raddr_next, input s_axis_aclk, input s_axis_aresetn, output reg s_axis_ready, input s_axis_valid, output reg s_axis_empty, output [C_ADDRESS_WIDTH-1:0] s_axis...
/** * 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...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of ent_ac // // Generated // by: wig // on: Tue Jun 27 05:12:12 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../verilog.xls // // !!! Do not edit this file! Autogenerated by MIX !!! // $Author: w...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2018.2 // Copyright (C) 1986-2018 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11.06.2017 19:09:17 // Design Name: // Module Name: ALU // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision:...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; int main() { long long int t, n, ans = 0, count0 = 0, count1 = 0, count2 = 0, num0 = 0, num1 = 0, num2 = 0; t = 1; while (t--) { cin >> n; vector<long long int> A(n, 0); for (int ...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { double l, r; cin >> l >> r; if (l > r / 2) { cout << YES << endl; } else { cout << NO << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 5; int n, q, l[N], r[N], level[N], p[N][20]; pair<int, int> res[N]; int import[N], numCity, numVirus, node[N], total_num; vector<int> adj[N], newAdj[N]; struct T { int city, speed; }; T virus[N]; int cnt = 0; void dfs(int x, int...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int n, br; int p[MAXN], niz[MAXN], num[MAXN], bio[MAXN]; inline void ne() { printf( NO n ); exit(0); } void dfs1(int x) { if (bio[x]) return; bio[x] = br; num[br]++; dfs1(niz[x]); } void dfs2(int x) { if...
/** * 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 n, i, a, b, x, y, ans = 0; scanf( %d , &n); printf( YES n ); for (int i = 1; i <= n; i++) { scanf( %d %d %d %d , &a, &b, &x, &y); x = min(a, x); y = min(y, b); ans = abs(x) % 2; ans = ans * 2 + (abs(y) % 2);...
#include <bits/stdc++.h> using namespace std; int main() { int x = 0, y = 0; cin >> x >> y; int z = abs(x) + abs(y); if ((x > 0) && (y > 0)) cout << 0 << << z << << z << << 0; else if ((x < 0) && (y > 0)) cout << -z << << 0 << << 0 << << z; else if ((x > 0...
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; using ll = long long; namespace io { const int SIZE = (1 << 21) + 1; char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1; char getc() { return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), ...
// (C) 1992-2014 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> using namespace std; const int MAX = 1e6 + 6; long long int arr[2000005], brr[2000005], crr[2000005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, k, ans; cin >> n >> k; vector<pair<int, int> > v; for (int i = 1; i <= n...
#include <bits/stdc++.h> using namespace std; int a[505]; pair<int, int> query(set<int> s) { cout << ? ; for (auto e : s) { cout << e << ; } cout << endl; pair<int, int> res; cin >> res.first >> res.second; a[res.first] = res.second; return res; } int main() { io...
//***************************************************************************** // (c) Copyright 2008 - 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. // // This is a copy of t_param.v with the parentheses around the module parameters // removed. module t (/*AUTOARG*/ // Inputs clk ); parameter PAR...
#include <bits/stdc++.h> using namespace std; char a; int s, kh; int main() { while (cin >> a) { if (a == ( ) s++; else if (s > 0) { kh += 2; s--; } } cout << kh; }
#include <bits/stdc++.h> using namespace std; const int M = 50 * 1000 * 1000, LG = 40; int get(long long x, int y) { return (x >> y) & 1; } int main() { int n, p; cin >> n >> p; for (int i = 0; i < M; i++) { long long x = (long long)n - 1ll * p * i; if (x >= i && __builtin_popcount(x) <=...
//================================================= // // Hsiang-Yi Chung // March 2016 // // This Module is for estimating the // magnitude of complex numbers. // // Formula for estimating magnitude: // mag = max(|I|,|Q|) + 1/4*min(|I|,|Q|) - 1/16*max(|I|,|Q|) // //=============================================...
#include <bits/stdc++.h> using namespace std; struct p { int x; int i; } a[200123]; int cmp(p a, p b) { if (a.x != b.x) return a.x < b.x; else return a.i < b.i; } int main() { int n; int i, j; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &a[i].x); ...
// file: dacclk_mmcm.v // // (c) Copyright 2008 - 2011 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 // laws. // // DISCLAIMER // This disclaimer is not ...
#include <bits/stdc++.h> using namespace std; void upd(long long &x, long long y) { x += y; } struct node { int nxt; long long sta, v[10]; node() { nxt = 0; memset(v, 0, sizeof(v)); } }; struct state { vector<node> nodes; int head[100007]; state() { memset(head, -1, siz...
/// date:2016/3/3 /// engineer:ZhaiShaoMin /// module name:upload_fsm_datapath /// module function:combine fsm of upload and datapath of upload module upload_fsm_datapath(//input clk, rst, v_flits_in, o...
/** * 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:05:40 09/06/2015 // Design Name: // Module Name: Deco_Round_Mult // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Re...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005, INF = 1 << 31; struct A { int x, w; } a[MAXN]; int b[MAXN], c[MAXN], n, d[MAXN], f[MAXN]; bool cmp(const A &x, const A &y) { return x.x < y.x; } int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d%d , &a[i]....
#include <bits/stdc++.h> using namespace std; int N, ans[(int)20 + 7][(int)20 + 7], a[500]; set<pair<int, int> > st; map<int, int> mp; int main() { ios::sync_with_stdio(false); cin >> N; for (int i = 0; i < N * N; i++) { cin >> a[i]; mp[a[i]]++; } int idx = -1; map<int, int...
#include <bits/stdc++.h> using namespace std; vector<long long> erat; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long nd(long long a) { map<long long, long long> m; while (a != 1) { ++m[erat[a]]; a /= erat[a]; } long long co...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; int cnt = 0; reverse(s.begin(), s.end()); cnt += (s[0] - 0 ); for (int ...
#include <bits/stdc++.h> using namespace std; #define endl n #define ll long long #define fr(i,s,e) for(ll i=s;i<=e;i++) #define rfr(i,s,e) for(ll i=s;i>=e;i--) #define f(x,m) for(auto x : m) #define ff first #define ss second #define pb push_back #define pp pop_back #define pf push_fro...
`define CYCLE_TIME 50 `include "StateTable.v" module Cache_TestBench; integer i, outfile, outfile2, counter; parameter flush_cycle = 300; reg clk, rst, start; reg flag; reg [26:0] address; reg [23:0] tag; reg [4:0] index; wire [256-1:0] mem_cpu_data; wire mem_cpu_ack; wire [256-1:0...
#include <bits/stdc++.h> int map[2001][2001] = {0}; int ans[2001] = {0}; int n, m, k; char ss[2001]; void show() { int i, j; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { printf( %d , map[i][j]); } printf( n ); } } int main() { int i, j, k; scanf( %d %d...
`timescale 1ns / 1ps // -*- Mode: Verilog -*- // Filename : alucontrol.v // Description : Description of the ALU control logic for our simplified MIPS processor. // Author : Pallav Gupta // Created On : Wed Oct 22 21:43:19 2008 // Last Modified On: Time-stamp: <2008...
// -------------------------------------------------------------------- // Copyright (c) 2007 by Terasic Technologies Inc. // -------------------------------------------------------------------- // // Permission: // // Terasic grants permission to use and modify this code for use // in synthesis for all Ter...
#include <bits/stdc++.h> using namespace std; const int N = 2e5; vector<int> g[N]; int mn[N]; int mx[N]; int ans; void dfs(int u, int p) { bool leaf = true; mn[u] = 1e9; mx[u] = -1e9; for (int v : g[u]) if (v != p) { dfs(v, u); leaf = false; mn[u] = min(mn[u],...
/////////////////////////////////////////////////////////////////////////////// // // Project: Aurora Module Generator version 2.2 // // Date: $Date: 2004/11/08 16:19:31 $ // Tag: $Name: i+H-38+78751 $ // File: $RCSfile: standard_cc_module.ejava,v $ // Rev: $Revision: 1.1....
#include <bits/stdc++.h> using namespace std; const long long int N = 60 + 10, M = (1 << 16) + 10, MOD = 1e9 + 7, INF = 2e9 + 10; const long double PI = acos(-1); int n, a[N], in[N], fac[N], msk[N], all; long long int dp[M][N], ans = 1; vector<int> adj[N], S, T; bool mrk[N], ad[N][N]...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; bool t = false; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) t = true, ch = getchar(); while (ch <= 9 && ch >= 0 ) x = x * 10 + ch - 48, ch = getchar(); retu...
#include <bits/stdc++.h> using namespace std; double low = 0, high = 0, mid = 0; int binary_sear(const vector<int>& v, int x) { while (1) { mid = floor((low + high) / 2); if (low > high) break; if (v[mid] == x) { return mid; break; } else if (v[mid] < x) { low =...
#include <bits/stdc++.h> using namespace std; const int N = 4040, inF = 1e9; int n, a, b, c, dp[N]; int main() { cin >> n >> a >> b >> c; dp[0] = 0; for (int i = 1; i <= n; i++) { dp[i] = -inF; if (i >= a) dp[i] = max(dp[i], dp[i - a] + 1); if (i >= b) dp[i] = max(dp[i], dp[i - b] ...
#include <bits/stdc++.h> using namespace std; int n; long long a[1010]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } long long k; cin >> k; cin >> k; cin >> k; long long x = (long long)a[2] * a[1] / k; long double dx = x; long long ans = (long...
#include <bits/stdc++.h> using i64 = long long; std::vector<std::vector<int>> read_tree1(int v) { std::vector<std::vector<int>> graph(v); while (v-- > 1) { int x, y; std::cin >> x >> y; graph[x - 1].push_back(y - 1); graph[y - 1].push_back(x - 1); } return graph; } templa...
/* * 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_p4_odd.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 an...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int N, M; int pwr[MAXN], jump[MAXN], cnt[MAXN]; int len; void recalc(int pos) { int nxt = pos + pwr[pos]; if (nxt < N && (nxt / len) == (pos / len)) { jump[pos] = jump[nxt]; cnt[pos] = cnt[nxt] + 1; } else { ...