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 law...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { if (x < y) swap(x, y); while (y > 0) { T f = x % y; x = y; y = f; } return x; } struct Node { Node *l, *r; long long a, b; Node() : l(NULL), r(NULL), a(0), b(0) {} }; Node* m...
// ------------------------------------------------------------- // // File Name: hdlsrc\qpsk\Raised_Cosine_Receive_Filter.v // Created: 2014-10-24 12:50:39 // // Generated by MATLAB 8.3 and HDL Coder 3.4 // // ------------------------------------------------------------- // ---------------------------------------...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!(ch >= 0 && ch <= 9 )) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + (ch - 0 ); ch = getchar(); } return...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e15; long long binpow(long long a, long long b) { long long res = 1; while (b > 0) { if (b & 1) { res = res * a; } a = a * a; b >>= 1; } return res; } long long dp[205][205][205]; int32_t mai...
#include <bits/stdc++.h> const int maxn = 5e5 + 5; using namespace std; char s[maxn]; int main() { scanf( %s , s); int k = strlen(s); char y = s[0]; for (int i = 0; i < k; i++) { if (s[i] > y) { cout << Ann << endl; } else { y = s[i]; cout << Mike << endl;...
/* Legal Notice: (C)2009 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 assoc...
#include <bits/stdc++.h> using namespace std; struct lichao { int l, r, A; long long B; lichao() : l(0), r(0), A(0), B(0x7fffffffffffffffLL) {} }; const int SZ = 1 << 17; vector<int> adj[100000]; vector<lichao> tree(2 * SZ); int node_cnt, num[100000], A[100000], B[100000]; long long ans[1000...
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; int d[201][201]; pair<pair<int, int>, int> E[20000]; vector<std::pair<int, int> > Intervals; int n, m; bool check(int idx, int x) { int u = E[idx].first.first, v = E[idx].first.second, w = E[idx].second; Intervals.clear(); ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:29:10 04/17/2008 // Design Name: // Module Name: DelayElement // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
////////////////////////////////////////////////////////////////////////// // Department of Computer Science // National Tsing Hua University // Project : FIFO for CS4125 Digital System Design // Module : fifo.v // Author : Chih-Tsun Huang // E-mail : // Revision : 4 // Date : 2014/04/28 // Abstract ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:58:11 07/01/2012 // Design Name: // Module Name: Device_led // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: //...
#include <bits/stdc++.h> using namespace std; const int MAXQ = 2e5; vector<int> solve(int K, vector<tuple<uint32_t, uint32_t, int> > V) { uint32_t mask = (((uint32_t)1) << K) - 1; vector<int> HT(1 << K), LT(1 << K); for (auto [l, r, v] : V) if (v) { uint32_t lhi = l >> K, llo = l & mask;...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int dp[10000]; int main() { int N, M; cin >> N >> M; int T; double D; int ans = 0; for (int i = 0; i < N; i++) { cin >> T >> D; dp[T - 1]++; for (int j = 0; j < T - 1; j++) dp[T - 1] = max(dp[T - 1], dp[j] + 1); } for ...
#include <bits/stdc++.h> using namespace std; int n = 0, T = 0; long long D[1003], g[1003]; long long x1[1003], xn[1003], Y1[1003], Yn[1003]; void getDisPre(long long x, int N, long long (&t1)[1003], long long (&tn)[1003]) { if (N == 0) { t1[0] = tn[0] = 0; return; } i...
// megafunction wizard: %Shift register (RAM-based)%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: ALTSHIFT_TAPS // ============================================================ // File Name: SHIFTREGRAM.v // Megafunction Name(s): // ALTSHIFT_TAPS // // Simulation Library Files(s): // altera_mf // ===...
// Copyright (c) 2014 CERN // Maciej Suminski <> // // 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) // any late...
/* File: toggle2pulse.v This file is part of the Parallella FPGA Reference Design. Copyright (C) 2013 Adapteva, Inc. Contributed by Roman Trogan <> 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 Softwar...
#include <bits/stdc++.h> using namespace std; int main() { int t, i, j, b, p, f, h, c, sum; cin >> t; while (t--) { cin >> b >> p >> f >> h >> c; sum = 0; b /= 2; if (h < c) { if (b < f) { sum += (c * b); b = 0; } else if (b > f) { su...
// Copyright 2020-2022 F4PGA 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed...
#include <bits/stdc++.h> using namespace std; int main(void) { int m; cin >> m; int C[m]; for (int i = 0; i < m; ++i) cin >> C[i]; int x, y; cin >> x >> y; int sum_1, sum_2; sum_1 = sum_2 = 0; int now = 0; for (int i = 0; i < m; ++i) sum_2 += C[i]; while (sum_1 < x || sum...
#include<iostream> #include<bits/stdc++.h> using namespace std; #define boost ios_base::sync_with_stdio(false); cin.tie(NULL) #define ll unsigned long long int #define tinput int t; cin>>t; while(t--) #define rep(i,n,s) for((i)=(s); (i)<(n); (i)++) template <typename T> T getmini(T x, T y) { return (...
#include <bits/stdc++.h> using namespace std; const int N = 3010; struct edge { int v, next, flag; } e[N << 2]; int head[N], cnt; void addedge(int u, int v, int flag) { e[cnt].v = v; e[cnt].flag = flag; e[cnt].next = head[u]; head[u] = cnt++; } int sum[N], dp[N]; void dfs(int u, in...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 08:18:40 03/03/2016 // Design Name: // Module Name: register // Project Name: // Target Devices: // Tool versions: // Description: // // Depend...
#include <bits/stdc++.h> using namespace std; string s[505]; int n, par[505][505], a[505 * 505] = {0}, v[505 * 505] = {0}, p[505 * 505]; bool b[505 * 505] = {0}; int dfs(int x, int y, int k) { par[x][y] = k; int ret = 1; if (x > 0 && par[x - 1][y] == -1 && s[x - 1][y] == . ) ret += dfs(x - ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mn = 1e5 + 1; ll n, d, a[mn], b[mn], ans = 1, cnt = 1, pos = 1, ansid[mn]; struct pairs { int val, id; pairs operator+(pairs A) { return (pairs){val + A.val, id + A.id}; } } tree[mn * 4], f[mn]; pairs maxp(pairs A, pairs...
/* * This tests the synthesis of a case statement that has an empty case. */ module main; reg clk, bit, foo; // Synchronous device that toggles whenever enabled by a high bit. always @(posedge clk) case (bit) 1'b0: ; 1'b1: foo <= ~foo; endcase // case(bit) (* ivl_synthesis_off *...
// (C) 1992-2014 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulati...
#include <bits/stdc++.h> using namespace std; const long long MAX = 3e5 + 10; const long long INF = 1e18; const long long M = 1e6 + 10; int main() { int n, i, j, k, l, p, q; string s; cin >> n >> s; set<char> a; char st[3] = { R , G , B }; for (i = 0; i < n; i++) a.insert(s[i]); ...
#include <bits/stdc++.h> int main() { int n, i, s = 0, m = 0, t; int a[100001]; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , a + i); s += a[i]; } t = a[0]; if (t > m) m = t; for (i = 1; i < n; i++) { if (t > 0) t += a[i]; else t = a[i];...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09:28:18 08/24/2011 // Design Name: // Module Name: q15_add // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; const int dir[5][2] = {0, 1, 0, -1, 1, 0, -1, 0, 0, 0}; const int inf = 0x7fffffff; const int mod = 1000000; const int Max = 1000000; int temp[10], ans[Max]; void check(char *s) { int index = 0, dec, sum = 0, cnt = 0; dec = atoi(s); memset(temp, 0,...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { fast(); long long int t = 1; while (t--) { long long int n, m; cin >> n >> m; long long int a[n][m], b[n][m]; for (int i = 0...
#include <bits/stdc++.h> using namespace std; int main() { int b, x; double a, c; cin >> a >> b >> c; a = ceil(a * (c / 100)); x = a; x -= b; if (x < 1) x = 0; cout << x << 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 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 la...
#include <bits/stdc++.h> using namespace std; vector<int> vec[10]; vector<vector<int> > vvv(183); queue<int> qu; map<string, int> mp; map<string, int>::iterator iter; bool ch[10] = {false}; int main() { string s1, s2; cin >> s1 >> s2; for (int i = 0; i < s1.length(); i++) { if (s1[i] >...
#include <bits/stdc++.h> using namespace std; const int p = 998244353, inv2 = 499122177; inline void XOR(int *a, int lim, int type) { for (register int mid = 1; mid < lim; mid <<= 1) { for (register int i = mid << 1, j = 0; j < lim; j += i) { for (register int k = 0; k < mid; k++) { a[...
#include <bits/stdc++.h> using namespace std; int ar[50][50]; int n; int check(int r, int c) { int v = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (ar[r][i] + ar[j][c] == ar[r][c]) { return 1; } } } return 0; } int main() { cin ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: mb2cpx_sm.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 and/or ...
/** * 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 ld = long double; using ll = long long; using ull = unsigned long long; const int INF = 1 << 30; const ll LINF = 1LL << 60; const int SZ = 1 << 13; char buff[SZ], *pos = buff + SZ - 1; inline ll read() { ll x = 0; int f = 1, c = (++po...
/** * 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 la...
/** * clock_divider.v - Microcoded Accumulator CPU * Copyright (C) 2015 Orlando Arias, David Mascenik * * 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 Licens...
/* Copyright 2018 Nuclei System Technology, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i...
#include <bits/stdc++.h> using namespace std; const int N = 1e6; const long long inf = 1e17; long long overFlow(long long a, long long b) { if ((inf / a) < b) return 1; return 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long x0, y0, ax, ay, bx, by; cin >> x0 >> y...
#include <bits/stdc++.h> char str[100010], out[100010], visited[100010]; int n, m, len, ar[100010], counter[256], tree[100010]; void update(int p, int v) { p++; while (p <= n) { tree[p] += v; p += (p & (-p)); } } int query(int p) { int res = 0; while (p) { res += tree[p];...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2013.4 // Copyright (C) 2013 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
/** * 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 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 la...
module recepcion(input rx, output reg avail, output reg [7:0] dout, input wire clk_div); initial begin avail=0; dout = 8'b00000000; end parameter RX_STATE_START = 2'b00; parameter RX_STATE_DATA = 2'b01; parameter RX_STATE_STOP = 2'b10; reg [1:0] state = RX_...
#include <bits/stdc++.h> using namespace std; int main() { int s, a, b, c; cin >> s >> a >> b >> c; if (a == 0 && b == 0 && c == 0) { printf( %.10f %.10f %.10f n , s, 0, 0); } else { int sum = a + b + c; printf( %.10f %.10f %.10f n , ((double)a * s) / sum, ((double)b * s) / sum, ...
/* * 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; bool isp(const int x) { if (x <= 1) return false; for (int i = 2; i * i <= x; ++i) if (x % i == 0) return false; return true; } int pow(int x, int e, const int MOD) { int r = 1; for (; e; e >>= 1, x = (long long)x * x % MOD) if (e & 1...
// megafunction wizard: %RAM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: bigasfuckram.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ===============...
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); char str[n]; scanf( %s , &str); int count = 0; for (int i = 0; i < n; i++) if (str[i] == str[i + 1]) count++; printf( %d , count); return 0; }
#include <bits/stdc++.h> using namespace std; int test() { long long n; cin >> n; long long cL = 0, cR = 0; long long si = 3 * 100001; long long *right = new long long[si], *left = new long long[si]; for (long long i = 0; i < si; i++) { right[i] = 0; left[i] = 0; } long l...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:43:04 03/22/2015 // Design Name: mux32bit2x1 // Module Name: C:/Users/Joseph/Documents/Xilinx/HW1/mux32bit2x1_test.v // Project Name: HW1 // Target Devi...
module module5(clk_, rst_, bar, foo); input clk_; input rst_; input [1:0] bar; output foo; parameter poser_tied = 1'b1; parameter poser_width_in = 0+1-0+1; parameter poser_width_out = 0+1; parameter poser_grid_width = 2; parameter poser_grid_depth = 1; parameter [poser_grid_width-1:0] cellTypes [0:p...
module build_tree ( input wire in, output [15:0] reg out, output [3:0] reg out_addr, output reg out_valid, output reg done, input wire CLK, input wire Reset, input wire EN ); // the len = 4 // This means that there is no need for the initial 6 bits // These 6 bits would normally tell the ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2013 by Wilson Snyder. interface ifc; integer value; endinterface module t (/*AUTOARG*/ // Inputs clk ); `ifdef INLINE_A //verilator inline_module `else //verilator no_i...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n; string s; int finish_x, finish_y; cin >> n >> s >> finish_x >> finish_y; if (n < abs(finish_x) + abs(finish_y) || n % 2 != (abs(finish_x) + abs(finish_y)) % 2) { cout << -1; ret...
/////////////////////////////////////////////////////////////////////////////// /// Andrew Mattheisen /// Zhiyang Ong /// /// EE-577b 2007 fall /// VITERBI DECODER /// bmu module /// /////////////////////////////////////////////////////////////////////////////// module bmu (cx0, cx1, bm0, bm1, bm2, bm3, bm4, bm5, 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 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 la...
#include <bits/stdc++.h> int main(void) { int b_cost, money, b_number; scanf( %d %d %d , &b_cost, &money, &b_number); int total_cost; int loan = 0; total_cost = b_cost; for (int i = 2; i <= b_number; i++) { total_cost += i * b_cost; } if (money < total_cost) { loan = total_...
// megafunction wizard: %ALTCLKCTRL%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altclkctrl // ============================================================ // File Name: PH2_CLK.v // Megafunction Name(s): // altclkctrl // // Simulation Library Files(s): // cycloneii // =================...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native ) static int a[100001], n, m, l, r, x, cnt; static bool type; inline static int read() { register int x = 0; static...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { int c; while (a != 0) { c = a; a = b % a; b = c; } return b; } int main() { ios_base::sync_with_stdio(0); int n, m, b = 0; cin >> n >> m; vector<vector<int> > arr(n, vector<int>(4, 0)); fo...
/** * 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() { string s; int l, i, j, k; cin >> s; for (i = 1; i < s.size() - 1; i++) { if (s[i] == A && ((s[i + 1] == B && s[i - 1] == C ) || (s[i - 1] == B && s[i + 1] == C ))) { printf( YES n ); 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...
#include <bits/stdc++.h> #pragma GCC optimize( O999 ) using namespace std; int main() { ios::sync_with_stdio(0); cout << INTERCAL ; 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...
#include <bits/stdc++.h> using namespace std; const int INF = 0x6fffffff; const int MINF = 0x80000000; const int mod = 1000000007; const int cons = 100001; const double pi = 3.141592653589793; int dy2[2] = {1, 0}; int dx2[2] = {0, -1}; int dy1[2] = {0, 1}; int dx1[2] = {1, 0}; int n, m; int main...
#include <bits/stdc++.h> using namespace std; int main() { int x, y, n, a, b; cin >> x >> y >> n; long double d = 10000000000, t, q; t = (long double)x / y; for (int i = 1; i <= n; i++) { q = abs(t - floor(t * i) / i); if (q < d) { a = floor(t * i); b = i; d =...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 5; const double EPS = 1e-3; int n; int t[MAXN]; int g(double q) { bool ok = true; for (int i = 1; i < n; i++) if (fabs(double(t[i] - t[i - 1] * q)) > EPS) ok = false; if (ok) return 0; ok = true; for (int i = 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 la...
#include <bits/stdc++.h> using namespace std; struct node { int days; int index; }; bool compare(node lhs, node rhs) { return (lhs.days < rhs.days); } int main() { int n, k; int sum = 0; scanf( %d%d , &n, &k); node a[n + 1]; for (int i = 1; i <= n; i++) { scanf( %d , &a[i].da...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
module sr_04(echo,clk,rst_n,distance_reg); input echo,clk,rst_n; output distance_reg; reg[9:0]distance_reg,cnt; wire start,finish; reg echo_reg1,echo_reg2; parameter idle=2'b00; parameter state1=2'b01; parameter state2=2'b10; reg [1:0]state; assign start=echo_reg1&~echo_reg2; //posedge assign finish=~echo_...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.4 (win64) Build Tue Nov 18 18:29:27 MST 2014 // Date : Tue Jun 30 15:18:15 2015 // Host : Vangelis-PC running 64-bit major release (...
`include "defines.v" module div ( input wire clk, input wire rst, input wire signed_div_i, input wire[`RegBus] opdata1_i, // 被除数 input wire[`RegBus] opdata2_i, // 除数 input wire start_i, input wire annul_i, output reg[`DoubleRegBus] result_o, output reg result_ready_o ); wire[32:0] ...
#include <bits/stdc++.h> using namespace std; int N; char s[500010]; int c[30][500010]; int then(int x) { return x & -x; } void in(int o, int x, int k) { while (x <= N) { c[o][x] += k; x += then(x); } } int out(int o, int x) { int re = 0; while (x > 0) { re += c[o][x]; ...
#include <bits/stdc++.h> using namespace std; void solve() { long long n, k; cin >> n >> k; string s; cin >> s; vector<char> base(k, ? ); for (long long i = 0; i < n; i++) { if (s[i] == 1 ) { if (base[i % k] == 1 ) { continue; } if (base[i % k] == ...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ // IMPORTANT: This requires an input text file named "rf1.fill" // Non-synthesizable behavioral RTL model for the instruction memory module instr_mem (instr_addr,instr,enb); // load instr - take data out...
#include <bits/stdc++.h> using namespace std; template <class T> void chkmax(T& x, T y) { x = (x > y ? x : y); } template <class T> void chkmin(T& x, T y) { x = (x < y ? x : y); } int a[6], b[6]; int main() { for (int i = 0; i < (int)(4); ++i) scanf( %d%d , &a[i], &b[i]); for (int i = ...
`timescale 1 ns/100 ps // Version: 8.5 8.5.0.34 module dmem(WD,RD,WEN,REN,WADDR,RADDR,RWCLK,RESET); input [7:0] WD; output [7:0] RD; input WEN, REN; input [9:0] WADDR, RADDR; input RWCLK, RESET; wire VCC, GND; VCC VCC_1_net(.Y(VCC)); GND GND_1_net(.Y(GND)); RAM4K9 dmem_R0C1(.ADDRA11(GND), .ADDR...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return f == 1 ? x : -x; ...
#include <bits/stdc++.h> using namespace std; const int N = 500010; int n, m; struct edge { int a, b, c, t; } e[N]; inline bool operator<(const edge &a, const edge &b) { return a.c < b.c; } struct union_find { int f[N], h[N], sz[N], cnt; struct oper { int x, fx, hx, szx, tc; } op[N *...
#include <bits/stdc++.h> using namespace std; int Set(int N, int pos) { return N = N | (1 << pos); } int reset(int N, int pos) { return N = N & ~(1 << pos); } bool check(long long N, int pos) { return (bool)(N & (1LL << pos)); } int n, m, l, r; string s; char c1, c2; int main() { cin >> n >> m; ...
#include <bits/stdc++.h> using namespace std; inline void pisz(int n) { printf( %d n , n); } int dl[1000][1000]; int dr[1000][1000]; int ul[1000][1000]; int ur[1000][1000]; int g[1000][1000]; int n, m; int recdl(int i, int j) { if (i < 0 || i == n || j < 0 || j == m) return -1001001001; if (i ...
#include <bits/stdc++.h> double const EPS = 3e-8; using namespace std; template <class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a % b) : a); } template <class T> T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); } struct debugger { template <typename T> debugger& operator,(const ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2005 by Wilson Snyder. module t (clk); input clk; reg [2:0] a; reg [2:0] b; reg q; f6 f6 (/*AUTOINST*/ // Outputs .q (q), // Inputs .a (a[2:0]...
#include <bits/stdc++.h> uint32_t readu32() { int c; while ((c = getchar()) < 0 ) ; uint32_t n = c & 15U; while ((c = getchar()) >= 0 ) n = n * 10 + (c & 15U); return n; } uint64_t readu64() { int c; while ((c = getchar()) < 0 ) ; uint64_t n = c & 15U; while ((c ...