text
stringlengths
59
71.4k
/** * 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 infinity = 1e9; int N, M; int A[509][509]; int P[509][509]; int squaresum(int cx, int cy, int k) { int ax = cx - k / 2; int ay = cy - k / 2; int bx = cx + k / 2; int by = cy + k / 2; return P[bx][by] - P[ax - 1][by] - P[bx][ay - 1] ...
#include <bits/stdc++.h> using namespace std; bool graf[100][100]; int n, m; bool visited[100]; bool spoken[100]; int stupid; int tab[100]; int main() { ios::sync_with_stdio(false); cin >> n >> m; for (int i = 0; i < n; i++) { int x; cin >> x; if (x == 0) stupid++; fo...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:14:47 01/16/2015 // Design Name: // Module Name: vga_640_480_stripes // Project Name: // Target Devices: // Tool versions: // Description: //...
/* * 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) 2015 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; int n, m, color[510]; bool g[510][510]; vector<int> nbr[510]; bool dfs(int x, int c) { color[x] = c; for (int i = 0; i < nbr[x].size(); i++) { int y = nbr[x][i]; if (color[y] == c) return 0; if (color[y] == 0 && dfs(y, 3 - c) == 0) return...
// Check that the signedness of methods on the built-in enum type is handled // correctly when calling the method with parenthesis. module test; bit failed = 1'b0; `define check(x) \ if (!(x)) begin \ $display("FAILED(%0d): ", `__LINE__, `"x`"); \ failed = 1'b1; \ end int unsigned x = 10; ...
#include <bits/stdc++.h> using namespace std; struct node { double x, y, t, val; } pnt[2050]; struct Edge { int u, v, next; } edge[2050 * 2050]; int head[2050], tot = 0; void add(int u, int v) { edge[tot].u = u; edge[tot].v = v; edge[tot].next = head[u]; head[u] = tot++; } doub...
#include <bits/stdc++.h> int main() { int arr[1001] = {0}; int n, i, others, temp; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &temp); arr[temp]++; } for (i = 0; i < 1001; i++) { if (!arr[i]) continue; others = n - arr[i]; if (arr[i] - others > 1) { ...
module cpu(CLK, RESET, EN_L, Iin, Din, PC, NextPC, DataA, DataB, DataC, DataD, MW); input CLK; input RESET; input EN_L; input [15:0] Iin; input [7:0] Din; output [7:0] PC; output [7:0] NextPC; output [7:0] DataA; output [7:0] DataB; output [7:0] DataC; output [7:0...
module test_serial_device(reset, clk, data, tx, rts, cts, end_flag); input reset; input clk; output tx; output [7:0] data; output rts; input cts; output end_flag; reg tx; reg [7:0] data; wire rts; reg end_flag; reg [7:0] buffer; reg [3:0] data_cnt; reg [4:0] multi_cnt; reg sending; reg start_bit; r...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tt, c = 0; cin >> tt; while (tt) { int n = tt; set<int> data; while (n % 2 == 0) { data.insert(2); n = n / 2; } for (i...
// hub /* ------------------------------------------------------------------------------- Copyright 2014 Parallax Inc. This file is part of the hardware description for the Propeller 1 Design. The Propeller 1 Design is free software: you can redistribute it and/or modify it under the terms of the GNU General Public ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t (clk); input clk; tpub p1 (.clk(clk), .i(32'd1)); tpub p2 (.clk(clk), .i(32'd2)); integer cyc; initial cyc=1; always @ (posedge clk) b...
#include <bits/stdc++.h> using namespace std; template <typename T> inline void gg(T &res) { res = 0; T fh = 1; char ch = getchar(); while ((ch > 9 || ch < 0 ) && ch != - ) ch = getchar(); if (ch == - ) fh = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) res = res * 10 + ch - 0 ,...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. `ifdef OVL_XCHECK_OFF //Do nothing `else `ifdef OVL_IMPLICIT_XCHECK_OFF //Do nothing `else wire valid_test_expr; assign valid_test_expr = ~((^test_expr) ^ (^test_expr)); `endif // OV...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long s = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) f *= c == - ? -1 : 1, c = getchar(); while (c >= 0 && c <= 9 ) s = s * 10 + c - 0 , c = getchar(); return s * f; } struct edge { int from, ...
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { if (b == 0) return a; return (a % b == 0 ? b : GCD(b, a % b)); } long long POW(long long base, long long exp) { long long val; val = 1; while (exp > 0) { if (exp % 2 == 1) { val = (val * bas...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 7; const long long inf = 0x3f3f3f3f3f3f3f; const long long mod = 20000311; int n; vector<int> a(100), b(100); vector<int> step[100], ves[100]; void solve(int n) { int st = 0; for (int i = 0; i < step[n].size(); 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 MAXN = (int)1010; set<int> ans; int n, m; char a[MAXN][MAXN]; int posk[MAXN]; int posG[MAXN]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; if (a[i][j] == S ) ...
#include <bits/stdc++.h> using namespace std; int n, m; string s[55]; vector<int> getRow(int x) { vector<int> R; for (int i = 1; i <= m; i++) if (s[x][i] == # ) R.push_back(i); return R; } vector<int> getCol(int x) { vector<int> C; for (int i = 1; i <= n; i++) if (s[i][x] ==...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << ( << p.first << , << p.se << ) ; } template <typename T1, typename T2> inline ostream& operator<<(ostream& os, const map<T1, T2>& c) { ...
module Computer_ControlUnit_InstructionMemory( output reg [WORD_WIDTH-1:0] INSTR_out, input [COUNTER_WIDTH-1:0] COUNTER_in ); parameter WORD_WIDTH = 16; parameter DR_WIDTH = 3; parameter SB_WIDTH = DR_WIDTH; parameter SA_WIDTH = DR_WIDTH; parameter OPCODE_WIDTH = 7; parameter CNTRL_WIDTH = DR_WIDTH+SB_WIDTH+SA_WIDT...
/** * testbench.v * */ module testbench(); localparam width_p = 32; localparam ring_width_p = width_p + 1; localparam rom_addr_width_p = 32; logic clk; logic reset; bsg_nonsynth_clock_gen #( .cycle_time_p(10) ) clock_gen ( .o(clk) ); bsg_nonsynth_reset_gen #( .reset_cycles_lo_p(4) ,.reset_cycles_hi_p(...
#include <bits/stdc++.h> using namespace std; char a[100][40]; char b[100][40]; int at[1445], use[100], ok[100], idx[100], pos[100], sum[100], cnt; int dp[43205], ans_dd, ans_hh, ans_mm; int pt[43205][100]; void run_to(int t) { while (1) { int next_dd = ans_dd; int next_hh = ans_hh; ...
#include <bits/stdc++.h> int main() { int t, a, b, i, temp; scanf( %d , &t); for (i = 1; i <= t; i++) { scanf( %d %d , &a, &b); if (b > a) { temp = a; a = b; b = temp; } while ((a * a) < 2 * a * b) { a++; } printf( %d n , a * a); } ...
// Certain arithmetic operations between a signal of width n and a constant can be directly mapped // to a single k-LUT (where n <= k). This is preferable to normal alumacc techmapping process // because for many targets, arithmetic techmapping creates hard logic (such as carry cells) which often // cannot be optimized...
#include <bits/stdc++.h> using namespace std; long long cnt, prime[100], pcnt; long long flg; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long long search(long long a, long long b) { if (!b) return 0; long long d = gcd(a, b); a /= d; b /= d; ...
// Nexys2 version of rautanoppa, teknohog's hwrng `include "main_pll.v" `include "../common_hdl/hwrandom_core.v" `include "../common_hdl/uart_transmitter.v" `include "../common_hdl/ringosc.v" `ifdef DISPLAY `include "raw7seg.v" module hwrandom (osc_clk, TxD, reset, segment, anode, disp_switch); `else module hwrandom ...
#include <bits/stdc++.h> using namespace std; long long b[200005]; int main() { int t; cin>>t; while(t--) { map<long long ,int >q; int n; scanf( %d ,&n); for(int i=1;i<=n+2;i++) { scanf( %lld ,&b[i]); q[b[i]]++; } sort(b+1,b+1+2+n); long long sum=0; for(...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int i, n, fl = 0; cin >> n; int *a = new int[n]; for (i = 0; i < n; ++i) { cin >> a[i]; } sort(a, a + n); for (i = 1; i < n; ++i) { if (a[i] == a[i - 1]) { ...
#include <bits/stdc++.h> using namespace std; long long mod_factorial[100005]; long long mod_inv_factorial[100005]; long long binpow(long long a, long long b) { long long res = 1LL; while (b) { if (b & 1) { res = (res * a); } a = (a * a); b >>= 1; } return res; ...
#include <bits/stdc++.h> using namespace std; int n, _m, ans = 0; map<string, int> m; string s[1010], u[1010], v[1010]; int main() { cin >> n >> _m; for (int i = 1; i <= n; i++) cin >> s[i]; sort(s + 1, s + n + 1); for (int i = 1; i <= n; i++) m[s[i]] = i - 1; for (int i = 1; i <= _m; i++)...
//---------------------------------------------------------------------------- // bfm_system_tb.v - module //---------------------------------------------------------------------------- // // *************************************************************************** // ** Copyright (c) 1995-2012 Xilinx, Inc. All...
`timescale 1 ns / 1 ps module axis_accumulator # ( parameter integer S_AXIS_TDATA_WIDTH = 16, parameter integer M_AXIS_TDATA_WIDTH = 32, parameter integer CNTR_WIDTH = 16, parameter AXIS_TDATA_SIGNED = "FALSE", parameter CONTINUOUS = "FALSE" ) ( // System signals input wire ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx2,tune=native ) #pragma GCC optimize( unroll-loops ) using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using pi = pair<ll, ll>; const int mod = 1e9 + 7; co...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; int n, m, k, t, mx, mi, x, y, dx, dy, idx, cnt, tot, sum, res, flag, st; vector<int> e[maxn]; void dfs(int u, int pre, int dep, int op) { if (dep > mx) { mx = dep; ...
// // fixed for 9.1 jan 21 2010 cruben // `include "timescale.v" `include "i2c_master_defines.v" module i2c_opencores ( wb_clk_i, wb_rst_i, wb_adr_i, wb_dat_i, wb_dat_o, wb_we_i, wb_stb_i, /*wb_cyc_i,*/ wb_ack_o, wb_inta_o, scl_pad_io, sda_pad_io, spi_miso_pad_i ); parameter dedicated_spi = 0; // Common bus signa...
module multiplexor_2x1#(parameter BIT_WIDTH = 32) (input control, input[BIT_WIDTH - 1:0] in0, input[BIT_WIDTH - 1:0] in1, output[BIT_WIDTH - 1:0] out); wire neg_control; wire[BIT_...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int N = 1e6 + 6; struct segt { vector<int> t; int d; segt(vector<int> &a) { int n = a.size(); for (d = 2; d < n; d <<= 1) ; t.assign(d * 2, 0); for (int i = 0; i < n; +...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * ------------------------------------------------------------------------------- * * PL allocator * * Allocates new vi...
// (C) 2001-2011 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...
#include <bits/stdc++.h> using namespace std; FILE* in = stdin; FILE* out = stdout; const int MAX = 100001; int n, k; int a[MAX]; int color[256]; void solve() { memset(color, -1, sizeof(color)); color[0] = 0; for (int i = 0; i < n; i++) { if (color[a[i]] != -1) continue; int left...
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int testcases; cin >> testcases; while (testcases--) { long long int n, m; cin >> n >> m; char a[n][m]; for (long long int(i) = 0; (i) ...
#include <bits/stdc++.h> using namespace std; int main() { int n, t[90]; bool ans = false; cin >> n; for (int i = 0; i < n; i++) { cin >> t[i]; } if (t[0] > 15) { cout << 15; ans = true; } for (int i = 0; i < n - 1 && ans == false; i++) { t[i] += 15; if ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; int main() { int n; scanf( %d , &n); if (n % 2 == 0) { printf( -1 n ); return 0; } for (int i = 0; i < n; ++i) { printf( %d , i); } printf( n ); for (int i = 0; i < n; ++i)...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/06/07 13:20:30 // Design Name: // Module Name: _3bit_binary_multiplier_control_unit // Project Name: // Target Devices: // Tool Versions: // Description: // /...
#include <bits/stdc++.h> using namespace std; int n, m; struct column { int a[13]; int x; }; column c[2001]; bool cmp(column p, column q) { return p.x > q.x; } int s[13][4096], f[13][4096]; int mian() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++...
/** * 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 double PI = acos(-1.0); const int inf = 0x3f3f3f3f; int n, k, a[510][510]; int main() { while (~scanf( %d%d , &n, &k)) { int top = 1, ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j < k; j++) { a[i][j] = top++; ...
//---------------------------------------------------------------------------- //-- Ejemplo 2 de puertas tri-estado //-- Hay 3 biestables con sus salidas conectas a un bus de 1 bit //-- Este bus se saca por un led, para conocer su estado //-- Con un registro de desplazamiento se selecciona que registro //-- se conecta ...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) const char nl = n ; using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using str = string; str to_string(char c) { return st...
/* * dat_i_arbiter - arbitrate data coming into the CPU * * Part of the CPC2 project: http://intelligenttoasters.blog * * Copyright (C)2017 * * 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 Found...
// // Generated by Bluespec Compiler (build 0fccbb13) // // // Ports: // Name I/O size props // RDY_server_reset_request_put O 1 reg // RDY_server_reset_response_get O 1 // read_rs1 O 64 // read_rs1_port2 O 64 // read_rs2 ...
// (c) Copyright 1995-2015 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 a license and does not grant ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; long double f; int i; cin >> n; long long int m = n; for (i = 1; n / pow(10, i) >= 1; ++i) ; i--; f = n / pow(10, i); if (ceil(f) == f) f++; f = ceil(f); n = f * pow(10, i); cout << n - ...
#include <bits/stdc++.h> using namespace std; int n, a[1005][1005], q, opr, xi; int row_sum[1005], col_sum[1005], total_row_add, total_col_add; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf( %d , &a[i][j]); for (int i = 0; i < n; i++) for (in...
/** * 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 adsr32( clk, GATE, A, D, S, R, sout/*, SEG */); output reg [31:0] sout; // This is the accumulator/integrator for attack, decay and release input wire clk; // 50 MHz input wire GATE; // GATE signal input wire [31:0] A; // attack rate input wire [31:0] D; // decay rate input wire...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int mx = 999999; int n, k, q; long long f[6], dp[N]; int main() { scanf( %d , &k); for (int i = 0; i < 6; ++i) scanf( %d , &f[i]); for (int i = 1; i <= mx; ++i) { int tmp = i, ct = 0; while (tmp) { in...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; if (a > b || (b - a) % 2) { cout << -1; return 0; } if (a == b) { if (a == 0) cout << 0; else cout << 1 << n << a; } else if (((a + (b - a) / 2) ^ ((b - a) / 2...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2013-2021 Robert Newgard * * This file is part of fcs. * * fcs 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. ...
#include <bits/stdc++.h> using namespace std; long long int M, tp, xx, lll, cc, ndl = 0, N, dl, nf, nef, T; struct bl { long long int type; long long int l, c, x; }; bl t; vector<bl> B; vector<long long int> C; map<long long int, long long int> MP; ifstream in( input.txt ); long long int fin...
#include <bits/stdc++.h> using namespace std; struct node { int l, r, mx, pre, suf; }; vector<node> T; vector<pair<int, int> > ht; int n, m, a[100055], root[100055], first, second, z; int init(int l, int r) { int ind = T.size(); if (l == r) { T.push_back({-1, -1, 1, 1, 1}); return ...
/* * 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 read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + ch - 0 ; ch = getchar(); } return x * f; } int n,...
#include <bits/stdc++.h> using namespace std; char a[10][10]; int main(void) { for (int i = 0; i < 8; i++) { cin >> a[i]; } int b = 10, w = 10; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (a[i][j] == B ) { int f = 0; for (int k = i + 1; k...
//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995-2011 Xilinx, Inc. All rights reserved. //////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor: Xilinx // \ \ \/ Version : ...
/** * 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 = 222222; const int inf = 1e9 + 7; vector<int> adj[MAXN], radj[MAXN]; int vis[MAXN], q[MAXN], qn, C; int cost[MAXN], mn[MAXN], cnt[MAXN]; void dfs(int u) { vis[u] = 1; for (auto v : adj[u]) { if (vis[v] == 1) continue; dfs(v)...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n, m; scanf( %d%d , &n, &m); int x, ans = 0; for (int i = 0; i < n; i++) { scanf( %d , &x); ans += x; } if (ans == m) printf( YES n ); el...
#include <bits/stdc++.h> using namespace std; const int max_n = 20010; int lf[max_n]; int rf[max_n]; int main() { long long sum = 0; int n; int x, y; memset(lf, 0, sizeof(lf)); memset(rf, 0, sizeof(rf)); scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d%d , &x, &y); ...
//Legal Notice: (C)2012 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; int n, m, s, ans; int ar[5005]; int cnt[5005]; int ar2[5005]; vector<pair<pair<int, int>, pair<int, int> > > v; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) ar[i] = 1000000000; for (int i = 0; i < m; i++) { int t, l, r, x;...
#include <bits/stdc++.h> using namespace std; int n; long long a[1111], b[1111]; int main() { cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) cin >> b[i]; long long ans = 0; for (int i = 1; i <= n; ++i) { long long cur1 = 0, cur2 = 0; for (int j =...
`timescale 1ns / 1ps /* Group Members: Kevin Ingram and Warren Seto Lab Name: Traffic Light Controller (Lab 3) Project Name: eng312_proj3 Design Name: Traffic_Test_D_eng312_proj3.v Design Description: Verilog Test Bench to Implement Test D (11 AM) */ module Traffic_Test; // Inputs...
//***************************************************************************** // (c) Copyright 2008 - 2013 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 /...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq * * 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, version 3 of the License. * * This program is dis...
`timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit must be 1 10 or 100 * -base is the time base for each unit, ranging from seconds * to femtoseconds, and must be:...
//Com2DocHDL /* :Project FPGA-Imaging-Library :Design ErosionDilationBin :Function Erosion or Dilation for binary images. It will give the first output after pipe_stage cycles while in_enable enable. :Module Main module :Version 1.0 :Modified 2015-05-24 Copyright (C) 2015 Tianyu Dai (dtysky) <> This library is...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\controllerHdl\controllerHdl_Detect_Change.v // Created: 2014-09-08 14:12:04 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ------------------------------------------------------------- ...
#include <bits/stdc++.h> using namespace std; int fir[5000]; int sec[5000]; int init(int x, int y) { printf( ? %d %d n , x, y); fflush(stdout); scanf( %d , &x); return x; } void print(int sch, const vector<int> &ans) { printf( ! n ); fflush(stdout); printf( %d n , sch); fflus...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const long long mod = 998244353; long long qpow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % mod; a = a * a % mod; b /= 2; } return ans; } long long b[maxn], in...
#include <bits/stdc++.h> using namespace std; long long maps[105][105]; int main() { long long a, b, c, d, i, j, k, l, t, n, m; scanf( %lld , &t); while (t--) { scanf( %lld , &a); for (i = 2; i * i <= a; i++) { if (a % i) { b = a % i; c = a - b; break;...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; vector<int> v[maxn], w[maxn]; long long a[maxn]; bool d[maxn]; long long c[maxn][5]; long long n, m; bool mark[maxn][2]; void dfs1(long long i) { c[i][0] = 1; mark[i][0] = 1; for (long long y = 0; y < v[i].size(); y+...
#include <bits/stdc++.h> using namespace std; const int MAXK = 1 << 12; const int P = 7340033; const int G = 3; const int MAXH = 30; int dp[MAXH + 7][MAXK + 7], buff[MAXK + 7]; int qpow(int a, int b) { if (b == 0) return 1; if (a == 0) return 0; int aux = qpow(1LL * a * a % P, b >> 1); if ...
// AJ, Beck, and Ray // SRAM testbench // 4/21/15 `include "SRAM2Kby16.v" module SRAMtest(); // localize variables wire clk, WrEn; wire [10:0] adx; wire [15:0] data; // declare an instance of the module SRAM2Kby16 SRAM (clk, adx, WrEn, data); // Running the GUI part of simulation SRAMtester ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: cpx_databuf_ca.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; int fen[100100]; int n, ans = -1, a[100100]; int calc(int ind) { int ans = 0; for (int i = ind; i >= 1; i -= i & (-i)) ans ^= fen[i]; return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; memset(fen, 0...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.1 (win64) Build Fri Apr 14 18:55:03 MDT 2017 // Date : Mon Aug 14 17:02:30 2017 // Host : ACER-BLUES running 64-bit major release (b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5; const int MAXM = 5e6; int N; pii A[MAXN+10]; pii B[MAXM+10], C[MAXM+10]; int main() { scanf( %d , &N); for(int i=1; i<=N; i++) scanf(...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Wilson Snyder. module t (/*AUTOARG*/ // Outputs q0, q1, q2, q3, q4, q5, q6a, q6b, // Inputs clk, d, rst0_n ); input clk; input d; // OK -- from primar...
#include <bits/stdc++.h> using namespace std; int val{0}; struct Triplet { char letter; int onePosn; int otherPosn; }; int findContinuous(string s) { int j{0}; for (auto i = 0; i < s.length() - 2; i++) { if (s[i] == Q && s[i + 1] == A && s[i + 2] == Q ) { j++; } ...
#include <bits/stdc++.h> using namespace std; const int N = 100100; int segTree[N * 4], n, x, y, z, l, r, val; map<int, int> TMp, NMp; vector<pair<int, int>> vv; vector<int> v, numm[N]; struct Query { int type, tim, num, ind; }; Query q[N]; void update(int i, int j, int pos) { if (i > r || j...
/*********************************************************************** * * Copyright (C) 2011 Adrian Wise * * 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; eit...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int len, S, T; bool o[N * 40][15]; char str[N]; long long n, Ans; struct matrix { long long f[4][4]; matrix() { memset(f, 63, sizeof(f)); } } Trans, bin[70], X; void cmin(long long& x, long long y) { x = x < y ? x : y; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n, a, flag = 0; vector<int> A, B; map<int, int> store; store.clear(); scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a); if (store[a] < 2) { if (store[a] == 0) { A.push_back(a); ...