text
stringlengths
59
71.4k
//***************************************************************************** // (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 /...
// limbus_tristate_conduit_pin_sharer_0.v // This file was auto-generated from altera_tristate_conduit_pin_sharer_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module limbus_tristate_conduit_pin_sharer_0 ( input wire clk_cl...
#include <bits/stdc++.h> using namespace std; const int N = 4 * 1e5 + 5; vector<int> g[N]; int n, dp[N], res[N]; int dfs(int i, int p = -1) { dp[i] = 1; for (auto j : g[i]) { if (j != p) { dp[i] += dfs(j, i); } } return dp[i]; } int dfs2(int i, int p = -1) { for (au...
/* nand2tetris 的要求應該用下列方式實作,但是由於這樣元件太多會導致 icarus 編譯失敗, 出現下列訊息: D:\Dropbox\cccweb\db\n2t>iverilog ram_test.v -o ram_test This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. 所以我們在記憶體容量大的時候改用 verilog 的陣列型寫法,這樣就不會當機了。 */ `inclu...
#include <bits/stdc++.h> using namespace std; int main() { int x; scanf( %d , &x); printf( %d , x + 1 >> 1); }
#include <bits/stdc++.h> using namespace std; template <class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os << ( << v.first << , << v.second << ) ; } template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { os << [ ; for (int i = int(0); 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...
//------------------------------------------------------------------------------ // YF32 -- A small SOC implementation based on mlite (32-bit RISC CPU) // @Taiwan //------------------------------------------------------------------------------ //...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:37:23 10/06/2014 // Design Name: // Module Name: uart // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Re...
#include <bits/stdc++.h> using namespace std; int main() { int n = 0; int answer = 0; cin >> n; int last = -1; int xs = 0, ys = 0, x = 0, y = 0; for (int i = 0; i < n; i++) { int px = x, py = y; char c; cin >> c; if (c == L ) x--; else if (c == 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 la...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 100; int x[N], z[2 * N], n, m, k; struct node { int v, i; } y[N]; bool com(node k1, node k2) { return k1.v < k2.v; } bool f(int w) { int o = 0, i = 1, j = w, l; while (i <= n && j <= m) { if (x[i] <= y[j].v) z[++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...
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { return a > b ? a : b; } long long a[100005]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n)...
/* * Copyright (c) 2014, Franck Jullien <> * 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 li...
#include <bits/stdc++.h> using namespace std; const int MAXN = 300005; const int MAXINT = 1073741823; vector<int> neighbors[MAXN]; int a[MAXN]; int greater_right[MAXN]; int greater_left[MAXN]; int less_right[MAXN]; int less_left[MAXN]; int dp[MAXN]; stack<int> s; int main() { ios::sync_with_...
/** * 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 l, r; scanf( %d%d , &l, &r); if (l == r) printf( %d n , l); else puts( 2 ); return 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 la...
//Legal Notice: (C)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 do...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long n, k, ans = 1e11; string s; cin >> n; if (n == 1 || n == 2) { cout << No << endl; return 0; } cout << Yes << endl; set<l...
module top; reg pass, pass_f1, pass_f2, pass_f3, pass_f4, pass_f5; reg [8*30:1] res; initial begin pass = 1'b1; // Verify that the initial scope is correct. $swrite(res, "%m"); if (res != "top") begin $display("Failed initial, got \"%0s\"", res); pass = 1'b0; end // Test %m ...
#include <bits/stdc++.h> using namespace std; long long xl, xr, yu, yd; long long x, y; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long n; cin >> n; for (int i = 0; i < n; i++) { cin >> x >> y; if (i == 0) { xl = x; xr = x; yu = y;...
// // auto generated by mux_sel.py // // wire declaration module uop_temp_out ( {%-for output_name in output_lst%} output {{output_name}}, {%-endfor%} input wire [7:0] A0 , //src1 data input wire [7:0] A1 , //src1 data input wire [7:0] A2 , //src1 data input wire [7:0] A3 , //src1 data inpu...
/////////////////////////////////////////////////////////////////////////////// // $Id: ethernet_parser.v 1976 2007-07-20 00:59:57Z grg $ // // Module: ethernet_parser.v // Project: NF2.1 // Description: parses the Ethernet header for a 32 or 64 bit datapath // //////////////////////////////////////////////////////////...
/* * 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; template <class T> ostream& operator<<(ostream& out, const tuple<T>& a) { out << [ << get<0>(a) << ] ; return out; } template <class T, class U> ostream& operator<<(ostream& out, const tuple<T, U>& a) { out << [ << get<0>(a) << << get<1>(a) ...
#include <bits/stdc++.h> int main() { int num, i, j, k, p; double prob[110], temp, tot, high, temp2; scanf( %d , &num); i = 0; while (i < num) { scanf( %lf , &prob[i]); i++; } i = 0; while (i < num) { p = i + 1; while (p < num) { if (prob[p] > prob[i]) {...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
#include <bits/stdc++.h> using namespace std; long long a[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 103...
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int position[21] = {0}; for (int i = 0; i < n; i++) cin >> position[i]; int head = 0, tail = n - 1, cost = 0; while (head <= tail) { if (position[head] != 2 && position[tail] != 2 && (...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:26:25 11/01/2013 // Design Name: // Module Name: i2s_out // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const long long INFLL = 1e18 + 7; const long double EPS = 1e-9; const int MAXN = 1e5 + 17; mt19937 myRand(1337); mt19937_64 myRand64(1337); signed main(void) { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int k; cin ...
/** * 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 INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; const int MAX = 1e3 + 10; vector<int> g[MAX]; int qt[MAX]; int dfs(int i, int p = -1) { int ret = 1; for (int j : g[i]) if (j != p) ret += dfs(j, i); return qt[i] = ret;...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); long long n, k, ans = 0; cin >> n >> k; if (k >= n / 2) ans = (n * (n - 1)) / 2; else { ans = (n * (n - 1)) / 2 - (((n - k) * (n - k - 1)) / 2) + k * (n - 2 * k) + (k * (k - 1)) / 2; }...
// ============================================================================= // COPYRIGHT NOTICE // Copyright 2006 (c) Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // This confidential and proprietary software may be used only as authorised by // a licensing agreement from Latt...
#include <bits/stdc++.h> using namespace std; int dq[4040]; int st = 0; int dr = 0; int m[3030][3030]; int mn[3030][3030]; int N, M, K, L, X, Y, Z; long long ret = 0; void make() { for (int i = 1; i <= N; ++i) { int ind = 0; st = dr = 0; for (int j = 1; j <= M; ++j) { whi...
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 16) + 5, maxm = 125; int n, f[maxn][maxm], sa[maxn], sb[maxn], va, vb; struct node { int id, r, b; } a[20]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { char ch = getchar(); while (ch != R && ch !=...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2 * (1e5) + 10, inf = 2147483647; long long ans; int n, lastR, lastB, lastP, mxR, mxB; int main() { int x; char c; scanf( %d , &n); lastR = lastB = lastP = -inf; mxR = mxB = 0; for (int i = 1; i <= n; ++i) { scanf( %d...
#include <bits/stdc++.h> using namespace std; const int L = 1e5 + 1; long long sofar[L], out[L]; struct node { long long l, r, q; }; long long ans = 0, counter[3000002], k; bool comp(node x, node y) { return x.r < y.r; } void add(long long val) { ans += counter[val ^ k]; counter[val]++; ...
// Library - static, Cell - th54w322, View - schematic // LAST TIME SAVED: May 23 18:16:51 2014 // NETLIST TIME: May 23 18:22:16 2014 `timescale 1ns / 1ns module th54w322 ( y, a, b, c, d ); output y; input a, b, c, d; specify specparam CDS_LIBNAME = "static"; specparam CDS_CELLNAME = "th54w322"; s...
/** * 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 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...
// (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; const int N = 300000 + 10; const long long MOD = 1000000000 + 7; const long long INF = 10000000; vector<long long> Poi; unordered_map<long long, long long> koj; long long q, SEG[4 * N][2], lazy[4 * N]; vector<pair<int, pair<long long, long long>>> Q; void ...
#include <bits/stdc++.h> using namespace std; vector<int> d[2], f; vector<vector<bool> > nab; int n, len = -1; const int INF = 1 << 29; int calc(vector<bool> &a, vector<bool> &b) { vector<bool> c(a.size() + b.size() + 1); for (int i = 0; i < b.size(); ++i) c[i] = b[i]; for (int i = b.size(); i <...
#include <bits/stdc++.h> using namespace std; long long read() { long long a = 0; char c = getchar(); while (c > 9 || c < 0 ) c = getchar(); while ( 0 <= c && c <= 9 ) { a = a * 10 + c - 48; c = getchar(); } return a; } struct data { long long x, y, c; data(long ...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: stage1.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( O3 ) #pragma GCC target( avx ) const long long MOD = 1000000007; const long double PI = 3.1415926535898; const l...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 5; struct tree { int l, r, add, lv, rv; ll sum; } tr[N << 2]; int n, q, a[N]; void Add(int rt, int x) { tr[rt].lv = tr[rt].rv = tr[rt].add = x; tr[rt].sum = 1ll * (tr[rt].r - tr[rt].l + 1) * x; } vo...
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { template <class c...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 5500; int n, T; double p[MAX_N]; int t[MAX_N]; double dq[MAX_N]; int main() { scanf( %d%d , &n, &T); for (int i = 0; i < n; i++) { scanf( %lf%d , &p[i], &t[i]); p[i] /= 100; } vector<double> cur(T + 1), nxt(T + 1);...
#include <bits/stdc++.h> using namespace std; int power(int a, int b) { if (b == 0) return 1; else if (b % 2 == 0) return power((a * a) % 1000000007, b / 2); else return (a * power((a * a) % 1000000007, b / 2) % 1000000007); } int main() { std::ios_base::sync_with_stdio(false);...
/** * 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; template <class T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> inline T LCM(T a, T b) { if (a < 0) return LCM(-a, b); if (b < 0) return LCM(a, -b); return a * (b / gcd(a, b)); } vector<int> arr; const int N =...
/** * 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...
// (C) 2001-2016 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; struct rec { double x, y; } a[110], s, e, f[2]; int g[2], n, m, i; double ans; double XJ(rec a, rec b, rec c) { return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); } double dist(rec a, rec b) { return sqrt((a...
#include <bits/stdc++.h> using namespace std; template <class T1> void deb(T1 e) { cout << e << endl; } template <class T1, class T2> void deb(T1 e1, T2 e2) { cout << e1 << << e2 << endl; } template <class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << << e2 ...
/** * 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 / 1ns /****************************************************************************** * (C) Copyright 2016 AGH UST All Rights Reserved * * MODULE: clk_divider * DEVICE: general * PROJECT: stopwatch * * ABSTRACT: The clock divider module. Assuming 100MHz input clock * * HISTORY: * 1 Jan...
#include <bits/stdc++.h> using namespace std; int main() { { int t; cin >> t; long long int a[t]; for (int i = 0; i < t; i++) { cin >> a[i]; if (a[i] % 2 == 0 && a[i] != 0) cout << a[i] - 1 << ; else cout << a[i] << ; } } re...
#include <bits/stdc++.h> using namespace std; struct Point { long long x, y; int type; void get(int t) { cin >> x >> y; type = t; } }; int N, M; Point R[500], B[500], P[1000], pivot; bool used[500]; Point operator-(Point p1, Point p2) { return Point{p1.x - p2.x, p1.y - p2.y}; }...
#include <bits/stdc++.h> using namespace std; int main() { string table; string hand; getline(cin, table, n ); transform(table.begin(), table.end(), table.begin(), ::tolower); getline(cin, hand, n ); transform(hand.begin(), hand.end(), hand.begin(), ::tolower); if (hand.find(table[0]...
#include <bits/stdc++.h> using namespace std; long long s, x, a, ans = 1; void setup() { cin >> s >> x; a = s - x; if (a & 1) { cout << 0; exit(0); } a >>= 1; } void xuly() { long long k = a; while (x) { if (x & 1) { if (a & 1) { cout << 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; const int nax = 1e2 + 5; string s; int n, k; int bonus[26][26]; const int inf = 1e9; long long int cnt = 0; int dp[nax][26][nax]; int solve(int i, int prev, int changes) { if (i >= s.length()) return 0; if (dp[i][prev][changes] != -inf) return dp[i...
`timescale 1ns / 100ps /* This test module works by tickling various inputs over a sequence of time. * If the output waveforms graphically, each test scenario is uniquely * identified by a number on the `scenario_o` bus. */ module test(); reg clk_o; reg rst_o; reg [7:0] scenario_o; reg [1:0] mode_o; reg d_o; reg ...
/******************************************************************************* * Function: Packet-->Memory Mapped Transaction Converter * Author: Andreas Olofsson * License: MIT (see LICENSE file in OH! repository) * * Doc...
#include <bits/stdc++.h> using namespace std; using ll = long long int; const int N = 2e5 + 10; int n, k, a[N], b[N], idx[N], kp = -1; char lc = a - 1, res[N]; int main() { ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr); cin >> n >> k; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; long long int n, m, modu = 1e9 + 7, prod = 1, sum = 0; long long int power(long long int x, long long int y) { if (y == 0) return 1; if (y & 1) return (x * power((x * x) % modu, y >> 1)) % modu; return power((x * x) % modu, y >> 1); } long long int com...
/** * 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 (C) 2011 Kiel Friedt * * 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 p...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; set<char> st; for (int i = 0; i < s.size(); i++) { if (s[i] == s[i + 1]) { i++; } else { st.insert(s[i]); } } for (auto it : st) { cout << it; } cout << n ; } ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int val[maxn]; int sito[maxn]; int main() { ios::sync_with_stdio(false); for (int i = 0; i < maxn; i++) { sito[i] = true; } vector<int> v; sito[0] = sito[1] = false; for (int i = 2; i < maxn; i++) { if (...
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } long long int lcm(long long int a, long long int b)...
#include <bits/stdc++.h> using namespace std; void solve() { int n, i, u; cin >> n >> u; long long int a[n + 2]; bool pos = false; double res = 0; for (i = 0; i < n + 1; ++i) { cin >> a[i]; } int j = 0; for (int i = 0; i < n - 2; i++) { j = max(j, i + 2); while ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Wilson Snyder. bit global_bit; module t (clk); input clk; integer cyc=0; typedef struct packed { bit b1; bit b0; } strp_t; typedef struct packed...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; const int maxm = 100000 + 10; vector<int> adj[maxn]; int fa[maxn][18], dep[maxn]; void trans(int prev, int u) { dep[u] = dep[prev] + 1; fa[u][0] = prev; for (int i = 1; (1 << i) <= dep[u]; i++) { fa[u][i] = fa[fa[u...
/////////////////////////////////////////////////////////////////////////////// // // 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 Found...
/* # Seven-Segment Display Decoder # Decodes a single 4-bit word into the LED set to display it on a seven-segment display. The display format is below: ``` --6-- | | 1 5 | | --0-- | | 2 4 | | --3-- ``` */ module SevenSegment ( input wire [3:0] data, output reg [6:0] display ); ...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long re = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) flag = -1; ch = getchar(); } while (isdigit(ch)) re = (re << 1) + (re << 3) + ch - 0 , ch = getchar(); return re * flag;...
module MUX4_1_5bit(Sel,S0,S1,S2,S3,out); input [1:0] Sel; input [4:0] S0,S1,S2,S3; output [4:0]out; assign out = (Sel[1]?(Sel[0]?S3:S2) : (Sel[0]?S1:S0)); endmodule module MUX4_1_32bit(Sel,S0,S1,S2,S3,out); input [1:0] Sel; input [31:0] S0,S1,S2,S3; output [31:0]out; assign out = (Sel[1]?(Sel[0]?S3:S2) : (Sel[0]?...
#include <bits/stdc++.h> using namespace std; map<int, int> m; int main() { map<int, int>::iterator ptr; int n, i, x, a[3]; cin >> n; for (i = 0; i < n; i++) { cin >> x; m[x]++; } if (m.size() > 3) { cout << NO ; return 0; } if (m.size() <= 2) { cout ...
#include <bits/stdc++.h> using namespace std; const long long base = 139; const long long M = 1000012309; long long p[200007]; vector<pair<long long, char> > vp1; vector<pair<long long, char> > vp2; long long hashtable[200007], hv, cnt = 0; void pcal() { p[0] = 1; for (long long i = 1; i < 20000...
// Filename: channel_tb2.v // Author: Danny Dutton // Date: 03/23/15 // Version: 1 // Description: Module connecting transmit to receive. This uses a clock of // insufficent period to ensure that the parity gen cant keep up. `timescale 1ns/100ps module channel_tb2(); reg enable; // Enable fo...
#include <bits/stdc++.h> using namespace std; struct fenwick { int N; vector<int> sum; void init(int n) { N = n + 1; sum.assign(N, 0); } void add(int i, int x) { for (i++; i < N; i += i & -i) { sum[i] += x; } } int get(int i) { int tot = 0; for...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2008 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // Take CRC data and apply to test...
//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...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; string s1, s2; cin >> n >> s1 >> s2; long long count = 0; for (long long i = 0; i < n / 2; i++) { char a[4] = {s1[i], s1[n - i - 1], s2[i], s2[n - i - ...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; map<pair<long long, long long>, set<pair<long long, long long>>> mp; for (long long i = 1; i <= n; i++) { long long x, y, z; cin >> x >> y >> z; mp...
#include <bits/stdc++.h> using namespace std; const int N = 1000; const double eps = 1e-9; long long INF = 1e9; const int OO = 0x3f3f3f3f; int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}; int dy[] = {0, 0, 1, -1, 1, -1, -1, 1}; bool comp(pair<int, int> a, pair<int, int> b) { if (a.first < b.first) retu...
/** * 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 int MAX = 1e6 + 5; const int N = 2e5 + 5; const long long int mod = 1e9 + 7; const long long int mx = 1e16; bool comp(const int a, const int b) { return a > b; } const double PI = 2 * acos(0.0); long long int fac[N]; void pre() { fac[0]...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5, inf = 9e8; int n, a[N]; array<int, 3> vals[N]; void compress(int arr[]) { vector<int> all; for (int i = 1; i <= n; i++) all.push_back(arr[i]); sort(all.begin(), all.end()); for (int i = 1; i <= n; i++) arr[i] = lower_bo...
module Encoder(index, value); parameter window_width = 3; parameter full_win_bits = 4; input[window_width * window_width - 1 : 0] index; output[full_win_bits - 1 : 0] value; reg[full_win_bits - 1 : 0] reg_value; assign value = reg_value; generate case(window_width) 2 : always@(*) begin case(index)...
#include <bits/stdc++.h> using namespace std; template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for (typename map<T0, T1>::const_iterator p = v.begin(); p != v.end(); p++) { os << p->first << : << p->second << ; } return os; } templa...
#include <bits/stdc++.h> using namespace std; int n, m, a[1010], s; long long pw[1010], c[1010][1010], ans = 1; int main() { pw[0] = pw[1] = 1; for (int i = 2; i < 1010; i++) pw[i] = 2 * pw[i - 1] % 1000000007; for (int i = 0; i < 1010; i++) for (int j = 0; j <= i; j++) c[i][j] = ((!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...