text
stringlengths
59
71.4k
module ExtADC ( (* intersynth_port = "Reset_n_i" *) input Reset_n_i, (* intersynth_port = "Clk_i" *) input Clk_i, (* intersynth_port = "ReconfModuleIn_s", intersynth_conntype = "Bit" *) input Enable_i, (* intersynth_port = "ReconfModuleIRQs_s", intersynth_conntype = "Bit" *) output reg CpuIntr_o, (* i...
#include <bits/stdc++.h> using namespace std; int a[111]; int main() { int mx = 1000000000; int cnt, n; scanf( %d , &n); int sum = 0; cnt = 0; int k = 0; for (int i = 1; i < n * 2; ++i) { scanf( %d , &a[i]); sum += abs(a[i]); mx = ((mx) < (abs(a[i])) ? (mx) : (abs(a[i...
#include <bits/stdc++.h> using namespace std; int maps[1010][1010]; int n; int dir[8][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}}; int pre[8][1010][1010]; double sums[8][1010][1010]; void partial() { for (int i = 0; i < 8; i++) { for (int j = 0...
#pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #define _CRT_SECURE_NO_WARNINGS # include <iostream> # include <cmath> # include <algorithm> # include <stdio.h> ...
/* SPDX-License-Identifier: MIT */ /* (c) Copyright 2018 David M. Koltak, all rights reserved. */ /* * rcn bus master and slave (combined) interface - zero cycle read delay. * */ module rcn_master_slave_fast ( input rst, input clk, input [68:0] rcn_in, output [68:0] rcn_out, input cs, inp...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 1; long long n, a[maxn], b[maxn], f1, f2; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (long long i = 0; i < n; ++i) cin >> a[i]; for (long long i = 0; i < n; ++i) cin >> b[...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c =...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; map<int, int> f, val; int lastans; int read() { int x = 0, f = 1; char s; while ((s = getchar()) > 9 || s < 0 ) if (s == - ) f = -1; while (s >= 0 && s <= 9 ) x = (x << 1) + (x << 3) + (s ^ 48), s = getchar...
#include <bits/stdc++.h> using namespace std; int tree[2000004]; int A[500002]; long long modular_pow(long long base, long long exponent, long long modulus) { long long result = 1; while (exponent > 0) { if (exponent % 2 == 1) result = (result * base) % modulus; exponent = exponent >> 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...
// Problem: A. Searching Local Minimum // Contest: Codeforces - Codeforces Round #700 (Div. 1) // URL: https://codeforces.com/contest/1479/problem/A // Memory Limit: 512 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <iostream> #include <iosfwd> #...
#include <bits/stdc++.h> using namespace std; int n, m; int q; int in[100005], out[100005]; vector<int> g[100005]; long long ans; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) { int u, v; scanf( %d%d , &u, &v); if (u < v) swap(u, v); out[u]++; in[v]...
////////////////////////////////////////////////////////////////// // // // Error corrector and detector module // // // // ...
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265359; const long long MOD = (long long)998244353ll; const long long MAXN = (long long)2e5 + 10; const long long INF = (long long)2242545357980376863; const long double EPS = (long double)1e-8; long long su = 0; long long a[MAX...
#include <bits/stdc++.h> using namespace std; int a[100000]; char t[1000]; int main() { string s, sa; stack<int> sta; int i, j; while (cin >> sa) { s += sa; } int cnt = 0; for (i = 0; i < s.length(); i++) { if (s[i] != < ) continue; i++; for (j = 0; i < s.len...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Clifford Wolf <> * 2019 Eddie Hung <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permiss...
/** * 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; pair<int, int> a[111]; int m; long long p[111]; long long an; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d%d , &a[i].second, &a[i].first); sort(a + 1, a + 1 + n); scanf( %d , &m); for (int i = 1; i <= m; ++i) ...
`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:...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Fri Sep 22 16:52:24 2017 // Host : vldmr-PC running 64-bit Service Pack 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 law...
/** * bsg_crossbar_control_basic_o_by_i.v * * This module generates the control signals for bsg_router_crossbar_o_by_i. */ `include "bsg_defines.v" module bsg_crossbar_control_basic_o_by_i #(parameter `BSG_INV_PARAM(i_els_p) , parameter `BSG_INV_PARAM(o_els_p) , parameter lg_o_els_lp=`BSG_SAFE_CL...
#include <bits/stdc++.h> using namespace std; string employees; queue<int> d, r; int main() { int n; cin >> n >> employees; for (int i = 0; i < n; i++) { if (employees[i] == D ) d.push(i); else r.push(i); } while (!d.empty() && !r.empty()) { int idx_d = d.f...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> a(n); for (size_t i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end(), greater<int>()); int x = a[0], y = 0; for (size_t i = 0; i ...
//Legal Notice: (C)2017 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...
/* * Data Memory. * * 32-bit data with a 7 bit address (128 entries). * * The read and write operations operate somewhat independently. * * Any time the read signal (rd) is high the data stored at the * given address (addr) will be placed on 'rdata'. * * Any time the write signal (wr) is high the data on 'wda...
module fifo72togmii ( // FIFO input sys_rst, input [71:0] dout, input empty, output reg rd_en, output rd_clk, // GMII input gmii_tx_clk, output gmii_tx_en, output [7:0] gmii_txd ); assign rd_clk = gmii_tx_clk; //----------------------------------- // logic //------...
#include <bits/stdc++.h> using namespace std; int a, ta, b, tb, hh, mm, res1, res2; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> a >> ta >> b >> tb; char tmp; cin >> hh >> tmp >> mm; hh -= 5; mm += hh * 60; if (mm - tb >= 0) res1 = (mm - tb) / b + 1...
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int FFTMOD = 119 << 23 | 1; const int INF = (int)1e9 + 23111992; const long long LINF = (long long)1e18 + 23111992; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long...
#include <bits/stdc++.h> using namespace std; int main() { int w, h, h1, w1, h2, w2; cin >> w >> h >> w1 >> h1 >> w2 >> h2; for (int i = h; i >= 0; i--) { w += i; if (i == h1) w -= w1; if (i == h2) w -= w2; if (w < 0) w = 0; } cout << w << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i = 1; cin >> n >> k; if (k == 1) cout << n; else { vector<int> ans; while (ans.size() < k) { i = 2; while (n % i != 0 && i <= n + 1) i++; if (i >= n + 1) { cout << -1; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { vector<int> a(3); cin >> a[0] >> a[1] >> a[2]; sort(a.begin(), a.end()); int v = a[0]; int d = min(v, a[2] - a[1]); int ans = d; a[0] -= d; a[2] -= d; d = a[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...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // 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 2 of the License...
module qdiv #( //Parameterized values parameter Q = 15, parameter N = 32 ) ( input [N-1:0] i_dividend, input [N-1:0] i_divisor, input i_start, input i_clk, output [N-1:0] o_quotient_out, output o_complete, output o_overflow ); reg [2*N+Q-3:0] reg_working_quotient; // Our working copy of the quotie...
#include <bits/stdc++.h> using namespace std; long long int dp[100010]; long long int sum[100010]; int main() { int n; int k; int m; cin >> m >> k; dp[0] = 1; for (int i = 1; i < k; i++) { dp[i] = 1; } for (int i = k; i <= 100002; i++) { dp[i] = (dp[i - 1] + dp[i - k]...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; bool good[n]; for (int i = 0; i < n; i++) good[i] = 1; for (int i = 0; i < n; i++) { int isGood = 1; for (int j = 0; j < n; j++) { int dum; cin >> dum; if (dum == 1 || dum == 3) ...
#include <bits/stdc++.h> using namespace std; long long f[300005][2], g[300005]; vector<int> vec[300005]; long long powi(long long a, long long b) { long long p; if (!b) return 1; p = powi(a, b / 2); p = (p * p) % 998244353; if (b % 2) p = (p * a) % 998244353; return p; } long long m...
/* Copyright (c) 2019 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> #pragma warning(disable : 4996) using namespace std; const long double pi = acos(-1.0); const long double eps = 1e-5; const int INF = 0x3f3f3f3f; const long long INFLL = 0x3f3f3f3f3f3f3f3f; struct poi { double x, y; } p[200010]; int main() { ios::sync_with_stdio(0), ci...
////////////////////////////////////////////////////////////////////// // Created by Actel SmartDesign Sat Sep 27 00:31:13 2014 // Testbench Template // This is a basic testbench that instantiates your design with basic // clock and reset pins connected. If your design has special // clock/reset or testbench driver r...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(NULL); cout.tie(NULL); ios_base ::sync_with_stdio(false); int n; cin >> n; vector<pair<long long, long long>> news(n + 1); for (int i = 1; i <= n; i++) cin >> news[i].first; for (int i = 1; i <= n; i++) cin >> news[i]...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; int main() { string s; cin >> s; string ans; bool found{false}; for (int i = 0; i < (int)s.size(); i++) { if ((i == (int)s.size() - 1) && !found) continue; if (s[i] == 1 || found) ans += s[i]; ...
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b, c; cin >> a >> b >> c; long long flag = 0, temp; temp = b - a % b; for (long long i = temp; (i + a) <= c; i += b) { cout << i << ; flag = 1; } if (!flag) cout << -1 ; } int main() { ios_b...
#include <bits/stdc++.h> using namespace std; template <class T, class L> bool smax(T &x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T &x, L y) { return y < x ? (x = y, 1) : 0; } const int maxn = 1e5 + 17, S = 1e9 + 1, maxfen = S * 2; map<int, vector<pair<int...
#include <bits/stdc++.h> using namespace std; int n, p; long long fac[250005], ans; int main() { scanf( %d%d , &n, &p); fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p; for (int i = 1; i <= n; i++) ans = (ans + fac[n - i + 1] * (n - i + 1) % p * fac[i] % p) % p; pr...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Hasan Hassan // // Create Date: 08/24/2015 05:49:13 PM // Design Name: // Module Name: SHD_PE // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies:...
#include <bits/stdc++.h> using namespace std; const int sz = 1e5 + 5; vector<tuple<int, int, int> > q; vector<int> FWT[sz]; int mt[sz]; vector<int> mapt[sz]; void update(int idx, int v, int pn) { vector<int>& x = FWT[v]; while (idx < x.size()) { x[idx] += pn; idx = idx + (idx & -idx); ...
////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 07/22/2015 09:29:50 PM // Design Name: // Module Name: system_controller // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: // ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Wojtek Gumua // // Create Date: 13:56:00 05/19/2015 // Design Name: // Module Name: dilation3x3 // Project Name: // Target Devices: // Tool versions: // Description: // // Depe...
//----------------------------------------------------------------------------- // // (c) Copyright 2008, 2009 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2010 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 // // -------------------------------------------------------- // Bug Description: // // Issue: T...
#include <bits/stdc++.h> using namespace std; const int N = 5001; int n, m, x, y, c[N], p[N], A; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) p[i] = N; while (m-- && cin >> x >> y) c[x]++, p[x] = min(p[x], (y + n - x) % n); for (int i = 1; i <= n; i++) { A = 0; for (int j...
#include <bits/stdc++.h> using namespace ::std; int NEGINF = -1e9; int main() { ifstream fin( input.txt ); int n, l, r; cin >> n >> l >> r; vector<int> a(n), b(n), p(n), c(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> ppos(n); for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 505; const int maxm = 1e4 + 5; struct node { int pre[maxn]; void init() { for (int i = 0; i < maxn; ++i) { pre[i] = i; } } int Find(int x) { if (x != pre[x]) pre[x] = Find(pre[x]); return pre[x]; }...
#include <bits/stdc++.h> using namespace std; int n, m, flow[200100][2], dtion[200100], Eg[200100]; bool vis[200100]; queue<int> q; struct node { int v, d, i; node *next; } edge[200100 * 2]; node *cnt = &edge[0]; node *adj[200100]; void Addedge(int u, int v, int d, int i) { node *p = ++cnt...
// (c) Copyright 1995-2017 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 ...
// Copyright (c) 2001 Stephen Williams () // // 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; either version 2 of the License, or (at your option) // ...
// This is the toplevel module for the clock generator. The clock generator // internally contains a bsg_tag node, a ring oscillator, and a clock // downsampler as well as a external clock pass through. The ring oscillator // also has its own bsg_tag node. // To select between // the ring oscillator, the downsampled r...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int d[MAXN], s[MAXN]; vector<pair<int, int> > ans; set<pair<int, pair<int, int> > > ver; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> d[i] >> s[i]...
module pr_region_default_mm_bridge_0 #( parameter DATA_WIDTH = 32, parameter SYMBOL_WIDTH = 8, parameter HDL_ADDR_WIDTH = 10, parameter BURSTCOUNT_WIDTH = 1, parameter PIPELINE_COMMAND = 1, parameter PIPELINE_RESPONSE = 1 ) ( input wire clk, // clk....
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
#include <bits/stdc++.h> using namespace std; int main(void) { ios::sync_with_stdio(false); register int i; register priority_queue<int> Queue; register int N, T; cin >> N >> T; register int Ans; Ans = 0; for (i = 1; i <= N; i += 1) { while (!Queue.empty() && Queue.top() >= T -...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int arr[2 * n], maxi[2 * n], c = 1; vector<long long int> v; ...
// (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...
/* Copyright (c) 2019 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,...
// Crazy Small CPU version 2 // (c) 2017 Warren Toomey, GPL3 // Just a few notes on the Verilog implementation of the CSCv2. // // Firstly, the ram.v component waits a clock cycle before it // outputs when the address changes. So we give it a clock signal // twice the frequency of the main CPU clock signal. // // The ...
#include <bits/stdc++.h> namespace FastIO { bool IOerror = 0; inline char nc() { static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000; if (p1 == pend) { p1 = buf; pend = buf + fread(buf, 1, 100000, stdin); if (pend == p1) { IOerror = 1; 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...
//------------------------------------------------------------------- //-- prescaler_tb.v //-- Banco de pruebas para el prescaler //------------------------------------------------------------------- //-- BQ August 2015. Written by Juan Gonzalez (Obijuan) //--------------------------------------------------------------...
module top(input clk, stb, di, output do); localparam integer DIN_N = 256; localparam integer DOUT_N = 256; reg [DIN_N-1:0] din; wire [DOUT_N-1:0] dout; reg [DIN_N-1:0] din_shr; reg [DOUT_N-1:0] dout_shr; always @(posedge clk) begin din_shr <= {din_shr, di}; dout_shr <= {d...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; void dir(char& smb, int& x, int& y) { if (smb == L ) x--; else if (smb == R ) x++; else if (smb == U ) y++; else y--; } void solve() { int n; cin >> n; string s; cin >> 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 law...
#include <bits/stdc++.h> using namespace std; vector<int> prefix_function(const string &s) { int n = (int)s.size(); vector<int> p(n); p[0] = 0; for (int i = 1; i < n; i++) { p[i] = p[i - 1]; while (p[i] > 0 && s[p[i]] != s[i]) p[i] = p[p[i] - 1]; if (s[p[i]] == s[i]) p[i]++; } ...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e6 + 5; const int MAXN = 7e6 + 5; const long long INF = 0x3f3f3f3f3f3f3f3f; int n, q, s, first[MAX], nextt[MAXN], u[MAXN], v[MAXN], cnt; long long w[MAXN]; void add(int a, int b, long long c) { u[cnt] = a, v[cnt] = b, w[cnt] = c; nextt...
#include <bits/stdc++.h> std::pair<int, int> advance(std::pair<int, int> pos, int dir) { switch (dir) { case 0: return {pos.first + 1, pos.second}; case 1: return {pos.first + 1, pos.second + 1}; case 2: return {pos.first, pos.second + 1}; case 3: return {po...
// $Id: c_wf_alloc_dpa.v 5188 2012-08-30 00:31:31Z dub $ /* Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributio...
#include <bits/stdc++.h> using namespace std; char s[5005]; int main() { int i, j, k; scanf( %s , s); int len, n, m; len = strlen(s); int Q, D, ans; ans = 0; for (i = 0; i < len; i++) { Q = 0; D = 0; for (j = i; j < len; j++) { Q += s[j] == ( ; Q -= s...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, a, b; cin >> n >> a >> b; for (long long i = 0; i <= n; ++i) { if (a * i > n) { break; } long long cur = a * i; if (n - cur >= 0 && (n - cur) % b ...
/* * 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...
/* * File: demo_top.v * Project: pippo * Designer: kiss@pwrsemi * Mainteiner: kiss@pwrsemi * Checker: * Assigner: * Description: * top module for FPGA demo on XUP board * */ // synopsys translate_off `include "timescale.v" // synopsys translate_on `include "def_pippo.v" mo...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; template <typename A> ostream &operator<<(ostream &cout, vector<A> const &v); template <typename A, typename B> ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout << ( << p.first << , << p.second << ) ; ...
#include <bits/stdc++.h> using namespace std; struct line { long long m, b; int id; }; long long floordiv(long long a, long long b) { return a / b - (a % b && ((a < 0) ^ (b < 0))); } long long intersect(line a, line b) { return floordiv(b.b - a.b, a.m - b.m); } pair<int, int> org[262192 >> 1];...
#include <bits/stdc++.h> using namespace std; int a[100010]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int i = (n - 1) / 2, j = i + 1; while (i >= 0 || j <= n - 1) { if (i >= 0) cout...
#include <bits/stdc++.h> using namespace std; struct comp1 { bool operator()(const long long &a, const long long &b) { return (a > b); } }; typedef struct node { long long num; vector<node *> des; } node; int n; long long arr[8]; int best; node *root; vector<node *> imp; bool prime[100...
/* * video.v Fake video driver * * This is a temporary display engine that simply renders the content of the * screen buffer, ignoring the CRTC. This will be replaced by a proper render * when memory is available. * * Part of the CPC2 project: http://intelligenttoasters.blog * * Copyright (C)2017 * * This...
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { if (b == 0) return 1; long long int c = power(a, b >> 1); c = (c * c) % 1000000007; if (b & 1) return (a * c) % 1000000007; return c; } const int N = (int)1e5 + 5; const int Q = 301; int...
module tone_lut64 (input [5:0] tone, output [13:0] sixty_fourth_period); //these constants define the number of 100Mhz cycles needed to emulate each note frequency, divided by 64 to get //a 64th of the waveform, to use PWM accurately parameter REST= 14'd1000, // give a small delay between look-up table advanc...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b, i, j, arr[1005] = {0}; cin >> n >> m; for (i = 1; i <= m; i++) { cin >> a >> b; arr[a] = 1; arr[b] = 1; } for (i = 1; i <= n; i++) { if (arr[i] == 0) break; } cout << n - 1 << endl; for...
#include <bits/stdc++.h> using namespace std; int m[100100]; vector<int> diff[100100]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> m[i]; diff[i - m[i]].push_back(i); } long long sum = 0; int d = 0, tot = 1; for (int i = 2; i <= n; i++) { auto...
/* * 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> #pragma GCC optimize( Ofast ) using namespace std; void manupulate(string &str) { for (long long int i = 0; i < str.size(); ++i) str[i] -= 48; } bool isprime(long long int n) { if (n <= 1) return false; for (long long int i = 2; i * i <= n; ++i) if (n % i == 0) retur...
#include <bits/stdc++.h> using namespace std; char a[1000010]; char b[1000010]; int main() { cin >> a; int ind = 0; int ans = 0; int n = strlen(a); for (int i = 0; i < n; i++) { if (a[i] == [ || a[i] == < || a[i] == ( || a[i] == { ) { b[ind] = a[i]; ind++; ...
#include <bits/stdc++.h> using namespace std; int num[2005]; int sum[2005]; bool cmp(int a, int b) { return a > b; } int main() { int n, i, j, t; int temp; while (cin >> n) { memset(num, 0, sizeof(num)); for (i = 0; i < n; i++) { cin >> temp; num[temp]++; } ...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. `include "verilated.v" `define STRINGIFY(x) `"x`" `define ratio_error(a,b) (((a)>(b) ? ((a)-(b)) : ((b)-(a))) /(a)) `define checkr(gotv,expv) do if (`ratio_err...
#include <bits/stdc++.h> using namespace std; char st[100000 + 123]; bool inm[256]; int main() { scanf( %s , st); memset(inm, 0, sizeof(inm)); inm[ A ] = true; inm[ H ] = true; inm[ I ] = true; inm[ M ] = true; inm[ O ] = true; inm[ T ] = true; inm[ U ] = true; inm[ V ] =...
// registerfile_io32.v // This file was auto-generated as a prototype implementation of a module // created in component editor. It ties off all outputs to ground and // ignores all inputs. It needs to be edited to make it do something // useful. // // This file will not be automatically regenerated. You should ch...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MXN = 1e3 + 7; const int mod = 998244353; int n, m; int ar[MXN][MXN]; int br[MXN]; struct lp { int m, v; } A[MXN][MXN], B[MXN][MXN]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) { ...