text
stringlengths
59
71.4k
// patterngenerator.v `timescale 1ns / 1ps module patterngenerator ( // avalon clock interface input csi_clock_clk, input csi_clock_reset, // avalon mm slave: status/control input avs_ctrl_address, input avs_ctrl_read, output [31:0]avs_ctrl_readdata, input avs_ctrl_write, input [31:0...
module processor( input wire mclk, // For Physical EPP Memory Interface /*input wire epp_astb, input wire epp_dstb, input wire epp_wr, output wire epp_wait, inout wire[7:0] epp_data,*/ // For Simulated Memory Interface input wire core_stall, output wire memory_read, output wire memory_write, output wire...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2014 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc = 0; reg [6...
#include <bits/stdc++.h> using namespace std; bool isprime(long long int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } vector<lo...
#include <bits/stdc++.h> using namespace std; int a[100000]; int m[100001]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } m[n] = 1e9 + 1; for (int i = n - 1; i >= 0; i--) { m[i] = min(m[i + 1], a[i]); } for (int i = 0; i < n; i++) { ...
`timescale 1 ns/1 ps module someTwoPortVendorMem_4096_32_0 (QA, CLKA, CENA, WENA, AA, DA, OENA, QB, CLKB, CENB, WENB, AB, DB, OENB); output [31:0] QA;...
/** * 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; inline int read(int f = 1, int x = 0, char ch = ) { while (!isdigit(ch = getchar())) if (ch == - ) f = -1; while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return f * x; } const int N = 2e5 + 5; int m, n, T, s[2][N], c[2], f[2], ans...
/*+-------------------------------------------------------------------------- Copyright (c) 2015, Microsoft Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code ...
/** * 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 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.4 (lin64) Build Wed Nov 18 09:44:32 MST 2015 // Date : Sat Jun 4 16:53:15 2016 // Host : Dries007-Arch running 64-bit unknown // Com...
#include <bits/stdc++.h> using namespace std; const int Max = 1e5 + 10; int fw[Max][26]; int bw[Max][26]; int gs[Max][26]; int ge[Max][26]; int n; int A[Max]; int mex(vector<int> vec); void CalcGS(int i, int c); void CalcGE(int i, int c); int mex(vector<int> vec) { sort(vec.begin(), vec.end(...
module PressCountFPGA(clock,reset,countu,countd,nr_presses,vga_hsync,vga_vsync,vga_r,vga_g,vga_b); input wire clock; input wire reset; input wire countu; input wire countd; output wire [7:0] nr_presses; output wire vga_hsync; output wire vga_vsync; outpu...
#include <bits/stdc++.h> using namespace std; const long double PI = 3.141592653589793238462643l; void solve(); int main() { solve(); return 0; } long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } void solve() { long long a, b, x1, y1, x2, y2; cin >> a >> b >> x1 >> ...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2015.4 // Copyright (C) 2015 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1ns/1ps module ...
#include <bits/stdc++.h> char _; using namespace std; int N, C, D; pair<int, int> A[400000]; long long Z, ZO, ZOZ, O, OZ, OZO; inline bool cmp(const pair<int, int>& a, const pair<int, int>& b) { if ((b.second < 0) ^ (a.second < 0)) return 1LL * a.first * b.second > 1LL * b.first * a.second; re...
/* * 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 main() { long long int n; cin >> n; long long int max1 = 0, max2 = 0, min1 = (1000000000 + 9), min2 = (1000000000 + 9); for (int i = 0; i < n; i++) { long long int x, y; cin >> x >> y; if (y < min1) { min1 ...
/* * 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; long long in() { long long re = 0, f = 1; char x = getchar(); while (x < 0 || x > 9 ) { if (x == - ) f = -1; x = getchar(); } while (x >= 0 && x <= 9 ) re = re * 10 + x - 48, x = getchar(); return re * f; } void out(long lo...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int k[n][n]; for (int j = 0; j < n; j++) for (int i = 0; i < n; i++) k[i][j] = (i)*n + j + 1; for (int i = 0; i < n; i += 2) reverse(k[i], k[i] + n); for (int j = n - 1; j >= 0; j--) { for (int i = 0; i <...
#include <bits/stdc++.h> using namespace std; int luat_tot(vector<int>& attack, vector<int>& defense, multiset<int> carti); int luare(vector<int>& attack, multiset<int> carti); int main() { int n, m, c; char s[10]; vector<int> attack, defense; multiset<int> carti; cin >> n >> m; for (int...
/** * 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> #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) using namespace std; constexpr long long mod = 998244353; const long long INF = mod * mod; const long double eps = 1e-12; const long double pi = acosl(-1.0); long long mod_pow(long long x, long long n, long long m =...
#include <bits/stdc++.h> using namespace std; const int SIZE = 500 + 10; int data[SIZE]; map<int, int> all_nums; int n; bool used[SIZE * SIZE]; int gcd(int a, int b) { if (a % b == 0) return b; return gcd(b, a % b); } void make_data() { srand(time(0)); int n = 5; int data[SIZE]; ...
#include <bits/stdc++.h> using namespace std; vector<long long> ad[200009]; long long vis[200009]; long long cnt, ans; void dfs(int u) { vis[u] = 1; cnt++; for (auto x : ad[u]) { if (!vis[x]) dfs(x); } } int main() { long long i, j, k, l, m, n, u, v; cin >> n >> k; for (i...
#include <bits/stdc++.h> using namespace std; int n, m, q; int nxt[100001]; char s[100001], t[100001]; int temp[100001]; int l, r; bool check(int u) { for (int i = 0; i < m; ++i) { if (s[u + i] != t[i]) return 0; } return 1; } void pre_do() { for (int i = 1; i <= n - m + 1; i++) ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:12:26 04/22/2016 // Design Name: // Module Name: alarm // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // R...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; long long sum = 0; vector<long long> a(n); for (long long i = 0; i < n; ++i) { cin >> a[i]; sum += a[i]; } vector<long long> pr...
//************************************************************ // CHECKS // ______ _ _ _______ ______ _ _ _ // / _____) | | (_______) _____) | / ) | | // | / | |__ | |_____ | / | | / / \ \ // | | | __)| | ___)| | | |< < \ \ // | \_____| | | | |____...
#include <bits/stdc++.h> using namespace std; vector<long long> z; const long long N = 5e3 + 7, M1 = 1e9 + 7, M2 = 1e9 + 9, b1 = 127, b2 = 239; long long maxi1[N], maxi2[N], maxx[N]; pair<long long, long long> h1[N], h2[N]; pair<long long, long long> poww[N]; string best; long long mod(long long x, long...
#include <bits/stdc++.h> using namespace std; bool vis[200005]; vector<int> v[200005], ak, d1, dn; vector<int> bfs(int n) { queue<int> q; vector<int> dis(200005); q.push(n); vis[n] = true; dis[n] = 0; while (!q.empty()) { int x = q.front(); q.pop(); for (int i = 0; i < ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y; cin >> n >> x >> y; long long chis = y - n + 1; if (n - 1 + chis * chis >= x && chis > 0) { for (long long i = 0; i < n - 1; i++) cout << 1 << n ; cout << chis; } else cout << -1 ; 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...
//----------------------------------------------------------------------------- // Copyright (C) 2014 iZsh <izsh at fail0verflow.com> // // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. //--------...
/** * 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; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vpii = vector<pair<int, int>>; using vc = vector<char>; using vvc = vector<vc>; long long binpow(long long a, long long n) { long long res = 1; while (n) { if (n & 1) r...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Jafet Chaves Barrantes // // Create Date: 21:28:51 04/04/2016 // Design Name: // Module Name: contador_AD_HH_2dig // Project Name: // Target Devices: // Tool versions: // Descri...
// *************************************************************************** // *************************************************************************** // 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; const int N = 20 * 1000 + 200; const int INF = 1000 * 1000 * 1000; int d[N]; int n, m; inline void read() { scanf( %d %d , &n, &m); } inline void solve() { for (int i = 0; i < N; i++) d[i] = INF; queue<int> q; q.push(n); d[n] = 0; while (!q...
module top(CLCK, SCL, SDA, CNT1A, CNT1B, CNT2A,CNT2B, CNT3A, CNT3B, CNT4A, CNT4B); input CLCK; input SCL; inout SDA; input CNT1A; input CNT1B; input CNT2A; input CNT2B; input CNT3A; input CNT3B; input CNT4A; input CNT4B; wire[15:0] CNTR1; wire[15:0] CNTR2; wire[15:0] CNTR3; wire[15:0] CNTR4; wire[7:...
#include <bits/stdc++.h> using namespace std; struct second { int l, r, x, id; bool operator<(const second a) const { if (r < a.r) return 1; if (r > a.r) return 0; return id < a.id; } } s[10005]; int cmp(const second a, const second b) { if (a.l != b.l) return a.l < b.l; re...
/** * 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 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Fri Oct 27 10:19:56 2017 // Host : Juice-Laptop running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; int n, k; long long m, f[1005][105][2]; long long dfs(int Index, int y, int now, int flag) { if (Index > n) return (flag == 0); if (f[Index][y][flag] != -1) return f[Index][y][flag]; int st = Index == n ? 1 : 0, y1; long long res = 0; for (int i ...
// Copyright (C) 1991-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 from any of the foregoing // (including device programming or simulation files), and any...
#include <bits/stdc++.h> using namespace std; using dd = long double; struct Tree { struct Node { dd mul; dd add; dd sum; Node() : mul(1), add(0), sum(0) {} }; int S; vector<Node> drz; void update(int v) { drz[v].sum = drz[2 * v].sum + drz[2 * v + 1].sum; } Tree(con...
/** * 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; pair<int, int> pairs[2 * 100000 + 10]; vector<int> adj[100000 + 10]; bool done[100000 + 10]; int result[100000 + 10]; void check(int N) { bool adj[N + 2][N + 2]; memset(adj, false, sizeof(adj)); for (int i = 1; i <= 2 * N; i++) { scanf( %d %d ,...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, mod = 1e9 + 7; int head[N], nxt[N << 1], to[N << 1], num = 0, n, b[N], fa[N], q[N], DFN = 0, k[N], in[N]; inline void link(int x, int y) { nxt[++num] = head[x]; to[num] = y; head[x] = num; ...
/** * 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...
/** NOTE: Code borrowed heavily from Pranav Kaundinya, et. al. (2012). */ module ntsc_to_bram(clk, vclk, fvh, dv, din, ntsc_addr, ntsc_data, ntsc_we, sw); input clk; // system clock input vclk; // video clock from camera input [2:0] fvh; input dv; input [29:0] din; input sw; output...
#include <bits/stdc++.h> using namespace std; struct node { int x, y; } p[8]; int cmp(node a, node b) { if (a.x == b.x) return (a.y < b.y); return a.x < b.x; } int main() { while (scanf( %d %d , &p[0].x, &p[0].y) != EOF) { int cnt1 = 0; int cnt2 = 0; int cnt3 = 0; int...
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long po(long long x, long long y, long long p) { long long res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } ...
/* * 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 object_store( input wire mclk, input wire stall, input wire reset, output reg[31:0] mem_address = 0, output reg[31:0] mem_din, input wire[31:0] mem_dout, output reg mem_re = 0, output reg mem_we = 0, input wire [4:0] slot_index, output wire[31:0] slot_value, output reg initialized = 0 ); parameter st...
//================================================================================================== // Filename : FSM_input_enable.v // Created On : 2016-10-04 09:10:38 // Last Modified : 2016-10-04 09:45:50 // Revision : // Author : Jorge Sequeira Rojas // Company : Instituto Tecnologi...
#include <bits/stdc++.h> using namespace std; int M = 1e9 + 7; int incr(string &s) { int i, n = s.length(); for (i = n - 1; i >= 0; --i) { if (s[i] != 9 ) { s[i]++; return 0; } s[i] = 0 ; } for (i = n - 1; i >= 0; --i) { s[i] = 0 ; } s = 1 + s; ...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { long long n, k; cin >> n >> k; long long cur = 1, now = 1, ans = 0; while (now <= k && cur < n) { cur += now; now <<= 1; ans++; } if (cur < n) { a...
#include <bits/stdc++.h> using namespace std; int n, m, fre[11], fre1[11]; string tot, no, cm = , cm1 = ; bool belongs(int x) { int tmp = x, len = 0, i; int tmf[11] = {}; while (tmp > 0) { tmf[(tmp % 10)]++; tmp /= 10; len++; } if (n - len == x) { for (i = 0; i < ...
// Copyright (c) 2012-2013 Ludvig Strigeus // This program is GPL Licensed. See COPYING for the full license. module Rs232Tx(input clk, output UART_TX, input [7:0] data, input send, output reg uart_ovf, output reg sending); reg [9:0] sendbuf = 9'b000000001; //reg sending; reg [13:0] timeout; assign UART_TX = s...
// Register file modeled off HW6 solutions #3 module reg_file( input clk, input regWrite, //input wire regInit, input [4:0] readReg1, input [4:0] readReg2, input [4:0] writeReg, input [31:0] writeData, output reg [31:0] readData1, output reg [31:0] readData2 ); reg [31:0] regFi...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 5; int n, q; ll a[N], tree[N << 2], lz[N << 2]; void push(int node, int s, int e) { tree[node] += lz[node]; if (s != e) { lz[node << 1] += lz[node]; lz[node << 1 | 1] += lz[node]; } lz[node] =...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long cnt, n, pre, i, j, k, l, x, y, z, a[310][310]; cin >> n; pre = 0; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { cin >> a[i][j]; pr...
`default_nettype none module CCU2C(input CIN, A0, B0, C0, D0, A1, B1, C1, D1, output S0, S1, COUT); parameter [15:0] INIT0 = 16'h0000; parameter [15:0] INIT1 = 16'h0000; parameter INJECT1_0 = "YES"; parameter INJECT1_1 = "YES"; // First half wire LUT4_0, LUT2_0; LUT4 #(.INIT(INIT0)) lut4_0(.A(A0), ...
#include <bits/stdc++.h> using namespace std; struct LINE { int start; int end; }; int ans = 0; vector<int> res; string shift(string s, int p1, int p2) { char t; for (int f = p2; f > p1; f--) { ans++; res.push_back(f); t = s[f]; s[f] = s[f - 1]; s[f - 1] = t; ...
#include <bits/stdc++.h> using namespace std; const int N = 123456; char buffer[N]; string solve(string s, int k) { const int n = s.size(); sort(s.begin(), s.end()); string res; int ptr = 0; while (ptr < n) { int p = ptr; char mini = ~ ; char maxi = 0 ; assert(mini...
#include <bits/stdc++.h> long long srf(int a, int b, int c) { std::cout << 1 << (a + 1) << << (b + 1) << << (c + 1) << std::endl; long long val; std::cin >> val; return val; } bool scl(int a, int b, int c) { std::cout << 2 << (a + 1) << << (b + 1) << << (c + 1) << std::en...
#include <bits/stdc++.h> using namespace std; const int maxn = 3079; int r, c, n, k; vector<int> nx(maxn, -1), pv(maxn, -1), kth(maxn, -1); vector<vector<int> > my(maxn); class point { public: int x, y; }; bool cmp(point& a, point& b) { return (a.y == b.y ? a.x < b.x : a.y < b.y); } vector<poin...
#include <bits/stdc++.h> using namespace std; string ls[] = { , one , two , three , four , five , six , seven , eight , nine }; string fr[] = { , , twenty , thirty , forty , fifty , sixty , seventy , eighty , ninety }; int main() { ios_...
/**************************************** Adder for MIST32 Processor Takahiro Ito @cpu_labs ****************************************/ `default_nettype none `include "core.h" module execute_adder #( parameter P_N = 32 )( //iDATA input wire [P_N-1:0] iDATA_0, input wire [P_N-1:0] iDATA_1, input wire [4:0] i...
// // Copyright (c) 2015 Jan Adelsbach <>. // 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 Foundation, either version 3 of the License, or // (at your optio...
`timescale 1ns / 1ps `define READ 2'b01 `define WRITE 2'b10 `define DO_NOTHING 2'b00 `define INVALID 2'b11 `define DATA_VALID 1'b1 `define DATA_INVALID 1'b0 `define FIFO_FULL 1'b1 `define FIFO_NOT_FULL 1'b0 `define FIFO_EMPTY 1'b1 `define FIFO_NOT_EMPTY 1'b0 `define LOG2(width) (width<=2)?1:\ (widt...
#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 =...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:55:04 12/14/2010 // Design Name: // Module Name: msu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // R...
////////////////////////////////////////////////////////////////////// //// //// //// eth_clockgen.v //// //// //// //// This file is part of the Ether...
#include <bits/stdc++.h> using namespace std; long long int dp[4011][4011]; long long int b[2000000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; long long int a[n]; set<long long int> st; for (int i = 0; i < n; i++) { cin >> a[i]; ...
#include <bits/stdc++.h> using namespace std; long long n, k, a[200], m; int main() { cin >> n >> m; k = n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); while (m > 0) m -= a[n--]; if (n < 0) n = 0; cout << k - n << endl; 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 law...
/* * * Copyright (c) 2011-2012 * * * * 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 distributed in...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 10; const long long mod = 998244353; const long long inf = (long long)4e17 + 5; const int INF = 1e9 + 7; const double pi = acos(-1.0); long long inv(long long b) { if (b == 1) return 1; return (mod - mod / b) * inv(mod % b) % mod...
module QcmMasterControllerWithFCounterMain(clk, sig, codeSer, codePar, enableSer, enablePar, ioPowerEnable, clkEnable); /* This is the master controller module which instantiates the sub-modules responsible for master controller operation: counter=frequency counter (really, a period counter with inversion) for determ...
#include <bits/stdc++.h> using namespace std; const long long INF = LLONG_MAX; const int mxn = 1011; bool DEBUG = 0; string s[mxn]; bool grid[mxn][mxn], chg[mxn][mxn]; long long dist[mxn][mxn]; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1}; int n, m; bool check(int x, int y) { ...
`timescale 1 ns / 1 ps module axis_delay # ( parameter integer AXIS_TDATA_WIDTH = 32, parameter integer CNTR_WIDTH = 32 ) ( // System signals input wire aclk, input wire aresetn, input wire [CNTR_WIDTH-1:0] cfg_data, input wire [CNTR_WIDTH-1:0] ...
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int sum[1111], cnt, po[1111], Sum[1111]; char s[1111][1111], ss[1111][1111]; int a[1111]; int find(char *s) { if (mp[s]) return mp[s]; mp[s] = ++cnt; strcpy(ss[cnt], s); return cnt; } int main() { int n; while (sc...
#include <bits/stdc++.h> using namespace std; int m, n; int main() { cin >> n >> m; if (m * n % 2 || ((min(m, n) == 1) && max(m, n) > 2)) { cout << 1 << n ; cout << n << << m << << 1 << << 1 << n ; for (int i = 1; i <= m; ++i) { if (i % 2) { for (int 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...
module zeowaa ( input clk_50, input [ 5:2] key, input [ 7:0] sw, output [11:0] led, output [ 7:0] hex, output [ 7:0] digit, output buzzer ); // wires & inputs wire clkCpu; wire clkIn = clk_50; wire rst_n = key[4]; wir...
// 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 : Thu Sep 14 10:54:36 2017 // Host : PC4719 running 64-bit Service Pack 1 (...
#include <bits/stdc++.h> using namespace std; struct T { int lz, sz; int v[2], t[2], f1[2], f2[2]; T(int x = 1) { lz = 0, sz = x; for (int i = 0; i < 2; i++) { v[i] = f1[i] = x; t[i] = f2[i] = 0; } } void upd() { for (int i = 0; i < 2; i++) t[i] ^= 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...
`include "datapath/pc.v" `include "datapath/alu.v" `include "datapath/dm.v" `include "datapath/ext.v" `include "datapath/im.v" `include "datapath/npc.v" `include "datapath/rf.v" `include "datapath/mux.v" `include "control/ctrl.v" module mips (clk, rst); input clk; input rst; wire [31:0] pc_next; wire [31:0] p...
//----------------------------------------------------------------- // FPGA Audio Project SoC IP // V0.1 // Ultra-Embedded.com // Copyright 2011 - 2012 // // Email: // // License: LGPL // // If you wo...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n], vis[200005] = {0}; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] <= n) vis[arr[i]]++; } sort(arr, arr + n); vector<in...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b != 0) return gcd(b, a % b); else return a; } long long int power(long long int a, long long int b) { if (b == 0) return 1; if (b == 1) return a; if (b % 2 == 0) { long ...
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 5; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long r; cin >> r; for (long long i = 1; i * i <= r; i++) { long long y = r - i * i - i - 1; if (y > 0 && y %...
//================================================================================================== // Filename : antares_cloz.v // Created On : Thu Sep 3 16:03:13 2015 // Last Modified : Sat Nov 07 11:49:40 2015 // Revision : 1.0 // Author : Angel Terrones // Company : Universidad Sim...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, i, j, k, cnt, tot, f[maxn]; char s[maxn]; int main() { scanf( %d%s , &n, s + 1); if (n & 1) return puts( 0 ), 0; tot = n >> 1; f[0] = 1; for (i = 1; i <= n; i++) { if (s[i] == ? ) for (j = i >> 1, ...