text
stringlengths
59
71.4k
// ============================================================== // 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 modul...
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << n ; err(++it, args...); } long long powMod(long long x, long long y) { long lon...
#include <bits/stdc++.h> using namespace std; int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1}; int dy[] = {0, 0, 1, -1, -1, 1, -1, 1}; int a[500], c[500]; int main() { int t = 0, z = 0, len; int n, k = 0, m = 0, bam = 0, dan = 0, ans = 0; scanf( %d %d , &n, &m); for (int l = 1; l < n + 1; l++) { ...
// // pixel.v -- last stage in display pipeline // module pixel(clk, pixclk, attcode, pixel, blank, hsync_in, vsync_in, blink, hsync, vsync, r, g, b); input clk; input pixclk; input [7:0] attcode; input pixel; input blank; input hsync_in; input vsync_in; input...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { return !b ? a : gcd(b, a % b); } template <typename T> T lcm(T a, T b) { return a * (b / gcd(a, b)); } template <typename T> T sqr(T a) { return a * a; } template <typename T> T cube(T a) { retu...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; const int INFINITE = 0x3f3f3f3f; template <class T> inline void checkmin(T &a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T &a, T b) { if (b > a) a = b; } template ...
#include <bits/stdc++.h> using namespace std; const double PI = 3.141592653589793238462643383279502884197169399375105820974944; long long dist(long long a, long long b, long long c, long long d) { return abs(a - c) + abs(b - d); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0);...
#include <bits/stdc++.h> void sc(int &x) { scanf( %d , &x); } void sc(int &x, int &y) { scanf( %d%d , &x, &y); } void sc(int &x, int &y, int &z) { scanf( %d%d%d , &x, &y, &z); } void sc(long long &x) { scanf( %lld , &x); } void sc(long long &x, long long &y) { scanf( %lld%lld , &x, &y); } void sc(long long ...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int mod = (int)1e9 + 7; int sum(int a, int b) { int s = a + b; if (s >= mod) s -= mod; return s; } int mult(int a, int b) { return (1LL * a * b) % mod; } int pw(int a, int b) { if (b == 0) return 1; if (b & ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int INF = 1.01e9; const long long INF18 = 1.01e18; int main() { int n; long long C; scanf( %d%lld , &n, &C); vector<long long> a(n); vector<long long> b(n - 1); for (int i = 0; i < (n); i++) { scanf( %lld...
// a barrel shifter to satisfy the single clock cycle constraint // and yet support the multibit shift operation // @requires: A 32-bit data input, a 32-bit control input; // @returns: A 32-bit left shifted output to support shift by 7 module shiftll (busSLL, busA, sel); output [31:0] busSLL; input [31:0] busA, se...
// ----------------------------------------------------------------------- // // Copyright 2004 Tommy Thorn - 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,...
#include <bits/stdc++.h> using namespace std; int main() { int N; scanf( %d , &N); int neg = 0, sum = 0; int mini = 1005; for (int i = 1; i < 2 * N; i++) { int x; scanf( %d , &x); neg ^= x < 0; x = abs(x); mini = min(mini, x); sum += x; } printf( %d n ...
module wb_bfm_memory #(//Wishbone parameters parameter dw = 32, parameter aw = 32, parameter DEBUG = 0, // Memory parameters parameter memory_file = "", parameter mem_size_bytes = 32'h0000_8000) // 32KBytes (input wb_clk_i, input wb_rst_i, input [aw-1:0] wb_adr_i, input [dw-1:...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0, a; for (int i = 0; i < n; i++) { cin >> a; sum += a; } int m; cin >> m; vector<char> good(1e5 + 1, false); int l, r; for (int i = 0; i < m; i++) { cin >> l >> r; f...
#include <bits/stdc++.h> int t1, t2; inline int get() { char c[10]; scanf( %s , &c); if (!strcmp(c, monday )) return 1; if (!strcmp(c, tuesday )) return 2; if (!strcmp(c, wednesday )) return 3; if (!strcmp(c, thursday )) return 4; if (!strcmp(c, friday )) return 5; if (!strcmp(c...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int hm = 0, wm = 0; for (int i = 0; i < (int)(n); i++) { char c; int h, w; cin >> c >> h >> w; if (h < w) { swap(h, w); } if (c == + )...
/** * 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...
`timescale 1ns / 1ps module InstructionMemory( output reg[31:0] RA, /* Read Data Output*/ input [31:0] A /* Adress */ ); always @ (*) begin case (A) 32'h00000004: RA = 32'hE3A00000; //MOV R0, #0x0 32'h00000008: RA = 32'hE3A04004; //MOV R4, #0x00000004 32'h0000000c: RA = 32'hE3A05010; //MOV 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; int jie[2000050], i, ni[2000050], j, g[1000050], su[1000050], m; bool vis[1000050]; int qmi(int di, int zhi) { int ret = 1, x = di; while (zhi) { if (zhi & 1) ret = 1LL * ret * x % 1000000007; x = 1LL * x * x % 1000000007; zhi >>= 1; } ...
#include <bits/stdc++.h> int n, p[4005], f[4005][4005], w[4005], tl; void solve() { scanf( %d , &n); n <<= 1; for (int i = 1; i <= n; ++i) scanf( %d , &p[i]); tl = 0; int pre = 1; w[++tl] = 1; for (int i = 2; i <= n; ++i) { if (p[i] < p[pre]) w[tl]++; else { p...
#include <bits/stdc++.h> using namespace std; const long long INF = 10000000000; const int maxn = 5010; long long a[maxn]; long long last[maxn]; int dp[maxn]; long long s[maxn]; int n; int main(int argc, char *argv[]) { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]); f...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { printf( %d , i); for (int j = 1; j < n; j++) { int tmp = (i + j) % n; if (tmp == 0) tmp = n; printf( %d , j * n + tmp); } printf( n ); }...
#include <bits/stdc++.h> using namespace std; int mark[1000009]; int main() { long long n, m = 0, i, j, t; long long sum; cin >> n; long long a[n]; for (i = 0; i < n; i++) { scanf( %lld , &a[i]); } t = a[n - 1]; sum = t; for (j = n - 1; j > 0; j--) { if (a[j - 1] < ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); int curr = 1; for (int i = 0; i < n; i++) { if (arr[i] >= curr) { curr++; } } cout << curr; return 0; }...
#include <bits/stdc++.h> using namespace std; enum { UP, DOWN, LEFT, RIGHT }; const int MAX = 15500; struct Node { int dir; Node* pt[4]; } node[MAX], *cur, *row[MAX], *col[MAX], *st[MAX]; char s[MAX]; int r, c, top; int getDir(char c) { switch (c) { case U : return UP; c...
#include <bits/stdc++.h> int in[301]; int c[301]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int n, i, j; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , in + i); for (i = 1; i <= n; i++) scanf( %d , c + i); for (i = 1; i <= n; i++) { for (j = 2; j * j <...
#include <bits/stdc++.h> using namespace std; const int mxn = 200000; int n; int a[mxn], b[mxn], first[mxn], ff[mxn]; vector<int> v[mxn]; auto cmp = [](int x, int y) { return b[x] > b[y]; }; priority_queue<int, vector<int>, decltype(cmp)> pq(cmp); map<int, int> second; int main() { ios::sync_with_...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 10, mod = 1e9 + 7; long long n, dp[2][N], d[2][N], t[2][N]; vector<long long> ch[N]; void dfs(long long v) { if (!ch[v].size()) { dp[0][v] = 0; dp[1][v] = 1; return; } for (long long i : ch[v]) dfs(i); d[...
//========================================== // Function : Code Gray counter. // Coder : Alex Claros F. // Date : 15/May/2005. //======================================= `timescale 1ns/1ps module GrayCounter #(parameter COUNTER_WIDTH = 4) (output reg [COUNTER_WIDTH-1:0] GrayCount_out, //'Gray'...
module score ( input wire clk, input wire [10:0] PIXEL_H, PIXEL_V, input wire [7:0] PLAYER_ONE, PLAYER_TWO, output reg [2:0] PIXEL ); // signal declaration wire [10:0] rom_addr; reg [6:0] char_addr; reg [3:0] row_addr; reg [2:0] bit_addr; wire [7:0] font_word; wire font_bi...
#include <bits/stdc++.h> using namespace std; int main() { string s; long n, i, k = 0, u = 0, d = 0, l = 0, r = 0; cin >> n; cin >> s; for (i = 0; i < s.size(); i++) { if (s[i] == U ) u++; if (s[i] == D ) d++; if (s[i] == L ) l++; if (s[i] == R ) r++; } k += m...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, r; cin >> n >> m >> r; int min1 = 1001; int max1 = 0; int a, b; for (int i = 0; i < n; i++) { cin >> a; min1 = min(a, min1); } for (int i = 0; i < m; i++) { cin >> b; max1 = max(b, max1); ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, a, t; while (cin >> n >> m >> a) { if (m < n) { t = m; m = n; n = t; } if (a >= m) cout << 1 << endl; if ((a < m) && (a >= n)) { if (m % a == 0) cout << m / a << endl;...
/// date:2016/3/4 /// engineer: ZhaiShaoMin /// module function : just combine memory_fsm and memory_state_data_ram module memory (//input clk, rst, //fsm state of rep paralle-serial port corresponding to mem m_rep_fsm_state, ...
#include <bits/stdc++.h> using namespace std; struct Node { int len, link; int nxt[26]; long long val; }; struct Automaton { int sz, last; Node s[200100 * 10]; void init() { sz = last = 0; s[0].len = 0; s[0].link = -1; s[0].val = 0; memset(s[0].nxt, 0, sizeo...
#include <bits/stdc++.h> using namespace std; long long G[500][500], d[500][500]; long long x[500], n, m; void floyd(long long k) { for (long long i = 0; i < n; i++) if (i != k) { for (long long j = 0; j < n; j++) if (i != j && j != k) if (G[i][j] > G[i][k] + G[k][j]) { ...
#include <bits/stdc++.h> using namespace std; int n, m; int x[500010], y[500010]; bitset<2010 * 2> A[2010]; void Work() { for (int i = 1; i <= n; i++) { int t = i; for (int j = i + 1; j <= n; j++) if (A[j][i]) t = j; swap(A[i], A[t]); for (int j = 1; j <= n; j++) if...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a[1010], maxx = -1, res[1010], ans = 0; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; if (res[a[i]] > 0) res[a[i]]++; else res[a[i]] = 1; maxx = max(maxx, res[a[i]]); } maxx =...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, m, q, p; cin >> q; while (q--) { cin >> n; string s; cin >> s; p = 0; if (s.length() > 2) { cout << YES n2 n ; cout << s[0] << ; for (i = 1; i < n; i++) cout << s[i]; ...
// ============================================================== // 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...
`timescale 1ns / 1ps /* This file is part of JT12. JT12 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. JT12 program is di...
/* * 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> inline void read(T &x) { x = 0; T f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); x *= f; } int main() { ...
/* Copyright (c) 2015-2016 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, distri...
#include <bits/stdc++.h> const int MAXN = 1000001; int n, m, a[MAXN], b[MAXN]; int box[MAXN], axi[MAXN]; int n1, n2; int main() { std::cin >> n >> m; for (int i = 1; i <= n; i++) { std::scanf( %d , a + i); if (a[i] <= m) { b[++n1] = a[i]; box[a[i]]++; } } if (...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:05:56 02/23/2015 // Design Name: // Module Name: mult_descale_pipeline // Project Name: // Target Devices: // Tool versions: // Description: ...
module check (input signed [22:0] a, b, c); wire signed [22:0] int_AB; assign int_AB = a - b; always @(a, b, int_AB, c) begin #1; if (int_AB !== c) begin $display("ERROR"); $finish; end end endmodule module stimulus (output reg signed [22:0] A, B); parameter MAX = 1 << 23; parameter S = 1000...
/* Copyright 2018 Nuclei System Technology, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; using ll = long long; using cd = complex<double>; ll base = 100; void fft(vector<cd>& a, bool inv) { int n = a.size(); int bits = __builtin_ctz(n); for (int i = 0; i < n; ++i) { int x = 0; for (int j = 0; j < bits; ++j) x = (x << 1) | (i >>...
#include <bits/stdc++.h> using namespace std; template <class T> void cmax(T &a, T b) { a = (a > b ? a : b); } template <class T> void cmin(T &a, T b) { a = (a > b ? b : a); } const long long maxn = 270000, base = 31, kcz = 1e9 + 7; long long inv; long long ksm(long long ds, long long zs = k...
#include <bits/stdc++.h> using namespace std; static const int MOD = 51123987; static const int MAXN = 150 + 10; char s[MAXN]; int p[MAXN][3]; int dp[MAXN][55][55][55]; int n, res; int main() { scanf( %d%s , &n, s + 1); p[n + 1][0] = p[n + 1][1] = p[n + 1][2] = n + 1; for (int i = n; i >= 1;...
#include <bits/stdc++.h> using namespace std; struct Point { long long x, y; void read() { scanf( %lld%lld , &x, &y); } }; long long product(const Point &o, const Point &a, const Point &b) { return (a.x - o.x) * (b.y - o.y) - (b.x - o.x) * (a.y - o.y); } bool intersect(const Point &a, const Poin...
/* * 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 long long pw10[] = {1, 10, 100, 1000, 10000, 100000}; long long K, F[7], Q, dp[7][2000000]; signed main() { cin >> K; for (long long i = 1; i <= 6; ++i) cin >> F[i]; memset(dp, -0x3f, sizeof(dp)); dp[0][0] = 0; for (long long i = 1; i <= 6;...
////////////////////////////////////////////////////////////////////////////////// // // This file is part of the N64 RGB/YPbPr DAC project. // // Copyright (C) 2015-2021 by Peter Bartmann <> // // N64 RGB/YPbPr DAC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public ...
#include <bits/stdc++.h> using namespace std; int n, m, k, x, y, a, b, d[2010][2010], v[2010][2010]; bool solve(int x, int y, int k) { int l = max(1, x - k), r = min(x + k, n), t; for (int i = l; i < r + 1; i++) { t = k - abs(i - x); if (y - t > 0 && !v[i][y - t]) return a = i, b = y - t, 1; ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, a, cnt = 0, tmp; scanf( %lld%lld%lld , &n, &m, &a); cnt = (m / a) * (n / a); if (n % a != 0) cnt += (m / a); if (m % a != 0) cnt += (n / a); if (m % a != 0 && n % a != 0) cnt += 1; printf( %lld n , cnt); retur...
#include <bits/stdc++.h> using namespace std; void run(); int main() { ios::sync_with_stdio(0); run(); } int n; int v[5001]; char s[5001]; int grundy[5001]; void run() { cin >> s; n = strlen(s); vector<int> blob; for (int i = 0; i < n; i++) if (0 < i and i + 1 < n and s[i...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 18:57:02 11/23/2014 // Design Name: // Module Name: counter_26bit // Project Name: // Target Devices: // Tool versions: // Description: // // D...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21.06.2017 16:52:43 // Design Name: // Module Name: Ps2Teclado // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Re...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Chrisky HU // // Create Date: 21:35:40 10/01/2015 // Design Name: // Module Name: ElbertV2_FPGA_Board // Project Name: // Target Devices: // Tool versions: // Description: // /...
/** * $Id: red_pitaya_hk.v -01-21 11:40:39Z matej.oblak $ * * @brief Red Pitaya house keeping. * * @Author Matej Oblak * * (c) Red Pitaya http://www.redpitaya.com * * This part of code is written in Verilog hardware description language (HDL). * Please visit http://en.wikipedia.org/wiki/Verilog * for more d...
#include <bits/stdc++.h> int perm[100010 + 1]; using namespace std; int main() { int n; cin >> n; int s = 1; int e = n; while (e - s > 0) { perm[s] = s + 1; perm[s + 1] = e; perm[e] = e - 1; perm[e - 1] = s; s += 2; e -= 2; } if (s == e) perm[s] = s;...
#include <bits/stdc++.h> using namespace std; const int rozmiar_kubelka = 356; int n, m; vector<int> her; vector<pair<char, int> > mov; int dp[(1 << 20)]; void policz() { dp[0] = 0; int a = 1; for (; a < (1 << m); a++) { int c = __builtin_popcount(a); c = m - c; auto akt = mo...
#include <bits/stdc++.h> int a[100010], b[100010]; bool check(int *a, int n, int id) { int cntt = 0; for (int i = 0; i < n; i++) { if (i == id) continue; b[cntt++] = a[i]; } if (cntt == 1) return true; for (int i = 1; i < cntt; i++) if (b[i - 1] == 0 && b[i] != 0) return false;...
#include <bits/stdc++.h> using namespace std; int A[200005]; int lazy[600005], ma[600005], mi[600005]; long long sum[600005]; void push_up(int cur) { sum[cur] = sum[cur * 2] + sum[cur * 2 + 1]; ma[cur] = max(ma[cur * 2], ma[cur * 2 + 1]); mi[cur] = min(mi[cur * 2], mi[cur * 2 + 1]); } void pus...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
#include <bits/stdc++.h> using namespace std; template <class T, class U> bool cmp_second(const pair<T, U> &a, const pair<T, U> &b) { return a.second < b.second; } pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) { return make_pair(a.first + b.first, a.second + b.second); }...
/** * 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 \$__M9K_ALTSYNCRAM_SINGLEPORT_FULL (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN); parameter CFG_ABITS = 8; parameter CFG_DBITS = 36; parameter ABITS = 1; parameter DBITS = 1; parameter CLKPOL2 = 1; parameter CLKPOL3 = 1; input CLK2; input CLK3; //Read data output [CFG_D...
//Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2015.2 (win64) Build Fri Jun 26 16:35:25 MDT 2015 //Date : Sun Mar 06 21:30:27 2016 //Host : raw-PC running 64-bit Service Pack 1 (build 760...
/** * 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 double PI = acos(-1.0); template <typename T> T abs(T x) { return x > 0 ? x : -x; } template <typename T> T sqr(T x) { return x * x; } template <typename T> bool chmin(T &x, T y) { if (x > y) { x = y; return true; }...
#include <bits/stdc++.h> using namespace std; using VI = vector<int>; const int NN = 200011; int a[NN], b[NN], arr[NN]; VI vec[NN], cyc[NN]; int nc; int dp[NN], vst[NN]; int n, s; void dfs(int u) { while (not vec[u].empty()) { int v = vec[u].back(); vec[u].pop_back(); dfs(a[v]); ...
module helloworld ( input clk, input rst, output [7:0] tx_data, output reg new_tx_data, input tx_busy, input [7:0] rx_data, input new_rx_data ); localparam STATE_SIZE = 1; localparam IDLE = 0, PRINT_MESSAGE = 1; localparam MESSAGE_LEN = 23; reg [STATE_SIZE-1:0] state_d, stat...
#include <bits/stdc++.h> using namespace std; constexpr long long ROWS = 2; constexpr long long NMAX = 1e5; long long h[ROWS][NMAX]; long long dp[ROWS][NMAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long COLS; cin >> COLS; for (long long i = 0; i < ROWS; ++i) ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:11:08 08/25/2014 // Design Name: // Module Name: conled // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // ...
//a ruidmentary credit tracker for an entire router module vcr_ugal_sniffer(/*autoarg*/ // Outputs credit_count, // Inputs clk, reset, flit_ctrl, flow_ctrl ); `include "c_functions.v" `include "c_constants.v" `include "vcr_constants.v" // flit buffer entries per VC parameter num_flit_buffers ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 10; const long long CONST = 314000000LL; const long long inf = (1LL << 60); bool mark[MAXN], INF[MAXN], bad[MAXN]; int m, n, cntComp; long long cnt[MAXN], func[MAXN], deg[MAXN], comp[MAXN], type[MAXN], len[MAXN]; long long mini[MAXN...
// DESCRIPTION: Verilator: Unsupported tristate constructur error // // This is a compile only regression test of tristate handling for bug514 // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2017 by Rob Stoddard. module t (/*AUTOARG*/ // Outputs out, // Inputs data,...
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : (-x); } template <class T> T sqr(T x) { return x * x; } const double eps = 1E-8; struct P { double x, y; P(double x = 0.0, double y = 0.0) : x(x), y(y) {} P operator+(P a) { return P(x ...
#include <bits/stdc++.h> using namespace std; char str[1000005 + 1]; int main() { int ans = 0, i; stack<int> S; scanf( %s , str); for (i = 0; str[i] != 0 ; ++i) { if (str[i] == ( ) S.push(i); if (str[i] == ) && !S.empty()) { S.pop(); ans += 2; } } pri...
#include <bits/stdc++.h> using namespace std; long long dp[1010][105], po[1010], po2[1010]; long long qui(long long a, long long n, long long m) { long long ans = 1; while (n) { if (n & 1) ans = (ans * a) % m; n >>= 1; a = (a * a) % m; } return ans; }; int main() { long l...
// cog_vid /* ------------------------------------------------------------------------------- Copyright 2014 Parallax Inc. This file is part of the hardware description for the Propeller 1 Design. The Propeller 1 Design is free software: you can redistribute it and/or modify it under the terms of the GNU Ge...
#include <bits/stdc++.h> using namespace std; double dp[200 + 50][200 + 50][200 + 50]; double p[200 + 50]; double res; int a[200 + 50]; int n, l, x, kol; int main() { scanf( %d%d%d , &n, &l, &kol); for (int i = 1; i <= n; i++) { scanf( %d , &x); p[i] = (x + 0.0) / 100; } for (i...
module opicorv32_alu_wrap ( is_lui_auipc_jal_jalr_addi_add, is_slti_blt_slt, is_sltiu_bltu_sltu, is_compare, instr_beq, instr_bne, instr_bge, instr_bgeu, instr_xori, instr_ori, instr_andi, instr_sub, instr_xor, instr_or, instr_and, reg_op2, reg_op1, ...
/* Copyright (c) 2015 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100005; int n, m; int t[MAX_N], x[MAX_N]; int nxt; int idx[MAX_N]; int res[MAX_N]; bool mycmp(const int a, const int b) { if (x[a] != x[b]) return x[a] < x[b]; return a < b; } int main() { scanf( %d%d , &n, &m); for (int...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
// finding a state for which valid=0 in the design below takes 26.5 second on ifv: module lfsr15(clk, rst, ena, state); // period = 32767 input clk, rst, ena; output [14:0] state; reg [14:0] state; always @(posedge rst or posedge clk) begin if (rst == 1) begin state <= 1; end else if (ena) begin ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, t, ma, sum = 0; std::string s[1000]; cin >> n >> k; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < k; i++) { cin >> t; ma = 1; map<char, int> m; for (int j = 0; j < n; j++) m[s[j][i]]++; ...
// *************************************************************************** // *************************************************************************** // 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 MaxN = 1005; char a[MaxN]; int b[MaxN]; bool prime(int x) { for (int i = 2; i < x / 2; i++) { if (x % 2 == 0) { return false; } } return true; } int main() { string s; int i, n, Max, j; char v; Max = 0;...
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, k, p; int odd[N], even[N], po, pe; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n >> k >> p; for (int i = 0; i < n; ++i) { int x; cin >> x; if (x & 1) ...
#include <bits/stdc++.h> using namespace std; const int maxn = 300000 + 3000; int n, m; int a[maxn], l[maxn], r[maxn], pos[maxn]; struct Segtree { int l, r; int val; } node[maxn << 3]; inline int read() { int x; scanf( %d , &x); return x; } inline void build(int p, int l, int r) { ...