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...
// todo module sim_conditioner(); // INPUTS // OUTPUTS // INOUTS `include "parameters_global.v" //`include "parameters_ram.v" // SIGNAL DECLARATIONS EXTERNAL reg CLK_MASTER; reg CPU_RESET_N; reg PWR_CTRL_PWR_FAIL_N; wire uut_pwr_fail; initial begin ...
/* Copyright (c) 2015-2018 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...
// (C) 2001-2011 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated doc...
// // Copyright 2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string num; cin >> num; num = num.substr(num.length() - x, x); cout << count(num.begin(), num.end() - y - 1, 1 ) + count(num.end() - y, num.end(), 1 ) + (*(num.end() ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( -ffloat-store ) #pragma GCC optimize( -fno-defer-pop ) long long power(long long a, long long b, long long m) { if (b == 0) return 1; if (b == 1) return a % m; long long t = power(a, b...
#include <bits/stdc++.h> using namespace std; void ans(int n, int p) { if (n == 5) { assert(p == 0); for (int i = int(1); i <= int(n); i++) { printf( %d %d n , i, i + 1 > n ? i + 1 - n : i + 1); printf( %d %d n , i, i + 2 > n ? i + 2 - n : i + 2); } return; } int ...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; long long q; long long n, k, a, b; int main() { cin >> q; while (q--) { cin >> k >> n >> a >> b; long long l = 0, r = n, mid, ans = -1; while (l <= r) { mid = (l + r) / 2; if (mid * a + (n - mid) * b >= k) r = mid ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int y, w; cin >> y >> w; int ans; ans; if (y >= w) { ans = 6 - y + 1; } else if (w >= y) { ans = 6 - w + 1; } if (ans == 6) { cout << 1 << / << 1 << endl; }...
// DESCRIPTION: Verilator: Test generate index usage. // // The code illustrates a problem in Verilator's handling of constant // expressions inside generate indexes. // // This is a regression test against issue 517. // // **If you do not wish for your code to be released to the public // please note it here, otherwis...
#include <bits/stdc++.h> using namespace std; map<int, long long> x, y; map<pair<int, int>, long long> xy; int main() { int n; cin >> n; while (n--) { int xx, yy; cin >> xx >> yy; x[xx]++; y[yy]++; xy[make_pair(xx, yy)]++; } long long ans = 0; for (auto i : ...
#include <bits/stdc++.h> using namespace std; const int inf = ~0u >> 1, mod = (int)(1e9) + 7; int n, m; long long pow2[555 * 555], f[555][555]; int main() { scanf( %d%d , &n, &m); pow2[0] = 1ll; for (int i = 0; i < (int)500 * 500; ++i) pow2[i + 1] = (pow2[i] * 2ll) % mod; f[0][0] = 1ll; fo...
#include <bits/stdc++.h> using namespace std; int n, m; char a[60][60], b[60][60]; int dir[4][2] = {0, 1, 1, 0, -1, 0, 0, -1}; struct node { int x, y, sum; }; node ans[2600]; bool cmp(node a, node b) { return a.sum < b.sum; } int bfs(int x, int y) { queue<node> q; node t, next; t.x = x...
`include "../include/tune.v" // PentEvo project (c) NedoPC 2008-2009 // // DRAM controller. performs accesses to DRAM. // // state: | RD1 | RD2 | RD3 | RD4 | WR1 | WR2 | WR3 | WR4 | RFSH1 | RFSH2 | RFSH3 | RFSH4 | // clk: ___/```\___/```\___/```\___/```\___/```\___/```\___/```\___/```\_...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; int sum = 0, odd = 0, even = 0; for (int i = 0; i < n; i++) { int x; cin >> x; if (x % 2 == 0) { even++; } else { ...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `ifdef OVL_XCHECK_OFF //Do nothing `else `ifdef OVL_IMPLICIT_XCHECK_OFF //Do nothing `else wire valid_test_expr; assign valid_test_expr = ~(test_expr ^ test_expr); `endif // OVL_IMPL...
`ifdef BSV_ASSIGNMENT_DELAY `else `define BSV_ASSIGNMENT_DELAY `endif `ifdef BSV_POSITIVE_RESET `define BSV_RESET_VALUE 1'b1 `define BSV_RESET_EDGE posedge `else `define BSV_RESET_VALUE 1'b0 `define BSV_RESET_EDGE negedge `endif `ifdef BSV_RESET_FIFO_HEAD `define BSV_RESET_EDGE_HEAD or `BSV_RESET_EDGE dRS...
#include <bits/stdc++.h> using namespace std; using namespace std; vector<long long>::iterator ptr; long long count = 0; long long cache[10004]; long long dp[100005] = {0}; long long cnt[200005] = {0}; long long a[200005] = {0}; long long b[200005] = {0}; long long r[200005] = {0}; long long pr(lo...
#include <bits/stdc++.h> using namespace std; int p[1000005]; int fnd(int x) { return p[x] = p[x] == x ? x : fnd(p[x]); } void unn(int x, int y) { p[fnd(y)] = fnd(x); } int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; int gcd(int x, int y) { return x % y ? gcd(y, x % y) : y; } int pq[5144]; vector<in...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2012 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // verilator lint_off MULTIDRIVEN ...
/* * 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 n, q; long long a[755], mx[755]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> q; for (long long i = 1; i <= n; i++) cin >> a[i]; for (long long i = 0; i <= n; i++) { long long l ...
`timescale 1ns / 1ps /* Do NOT allow undeclared nets */ `default_nettype none /* Example for June 2014 - Programmable Logic In Practice. Copyright Colin O'Flynn 2014. All Rights Reserved. */ module lx9_reconfig_top( //Inputs input wire USER_RESET, input wire USER_CLOCK, //PMod Connection: J5, Pin 1 o...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; const int MN = 1e6 + 6; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << fixed << setprecision(10); long long n; cin >> n; long long p_x = 0, p_y = 0; long long res = 1; for (long long ...
////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2013, Andrew "bunnie" Huang // // See the NOTICE file distributed with this work for additional // information regarding copyright ownership. The copyright holder // licenses this file to you under the Apache License...
/////////////////////////////////////////////////////////////////////////////// // vim:set shiftwidth=3 softtabstop=3 expandtab: // // Module: oq_regs_eval_full.v // Project: NF2.1 // Description: Evaluates whether a queue is full // // Currently looks at the number of packets in the queue and the number of // words le...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, mod = 1000000007, INF = 1e9 + 7; const int block = 316; int n, k, type[N], a[N], m, cnt[N * 3], l[N][5]; long long ans, res[N], p[N][5]; set<long long> s; map<long long, int> conv; struct query { int l, r, id, num; query(){}; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) cin >> a[i]; vector<vector<int> > dp(201); for (int i = 1; i <= n; i++) { dp[a[i]].push_back(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; int main() { int n, m, t, timer = 0; scanf( %d%d%d , &n, &m, &t); deque<int> q; vector<int> col(n); char isOk = false; for (int i = 0, j = 0; i < n; i++) { int x, y, z, start; scanf( n%d:%d:%d , &x, &y, &z); start = x * 3600 + ...
// *********************************************************** // $Header: /var/lib/cvs/dncvs/FPGA/dini/fifo/fifo_checksum.v,v 1.8 2014/08/28 22:04:32 neal Exp $ // *********************************************************** // Description: // // Calculates checksums on FIFO wr/rd data. // ***************************...
#include <bits/stdc++.h> using namespace std; int h1, h2, n; int v[111]; char c[111]; int a[111]; int b[111]; const double eps = 1e-9; int main() { cin >> h1 >> h2 >> n; for (int i = (0); i < (n); i++) cin >> v[i] >> c[i] >> a[i] >> b[i]; int best = 0; for (int i = -200; i <= 200; i++) {...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.4 (lin64) Build Tue Nov 18 16:47:07 MST 2014 // Date : Fri May 6 14:51:06 2016 // Host : graviton running 64-bit Debian GNU/Linux 7....
/* * 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 n, k; long long f[1005][2005][4]; int main() { f[1][1][0] = f[1][1][1] = f[1][2][2] = f[1][2][3] = 1; cin >> n >> k; for (int i = 1; i <= n; i++) f[i][1][0] = f[i][1][1] = 1; for (int i = 2; i <= n; i++) { for (int j = 2; j <= k; 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 law...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int oo = (int)1e9; const double PI = 2 * acos(0.0); const double eps = 1e-7; const int MAXN = 1e5 + 10; int dx[] = {1, 0, -1, 0, -1, -1, 1, 1}; int dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; int main() { int n, k, a[100009]; ...
#include <bits/stdc++.h> using namespace std; int main() { int na, ma, nb, mb; cin >> na >> ma; char ch1[na + 5][ma + 5]; for (int i = 1; i <= na; i++) { for (int j = 1; j <= ma; j++) { cin >> ch1[i][j]; } } cin >> nb >> mb; char ch2[nb + 5][mb + 5]; for (int i = ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n + 1); for (int i = 1; i <= n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); vector<vector<vector<int>>> dp( 2, vector<vector<int>>(k + 1, vector<int>(k + 1))); dp[0][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; signed main() { long long T; cin >> T; while (T--) { string s; cin >> s; long long ans = (long long)s.size(), curr = 0; for (long long i = 0; i < s.size(); i++) { if (s[i] == + ) { curr++; } else { ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Sun May 28 19:58:38 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; int n, a[3001], b[3001], cnt = 1, sum; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); while (1) { if (cnt == a[++sum]) cnt++; else { cout << cnt; return 0; } } ...
#include <bits/stdc++.h> using namespace std; int a[110]; int main() { int n, k; cin >> n >> k; vector<int> v; for (int i = 0; i < k; i++) cin >> a[i]; for (int i = 1; i <= n; i++) v.push_back(i); int lea = 0; for (int i = 0; i < k && v.size() > 0; i++) { lea %= v.size(); i...
////////////////////////////////////////////////////////////////////// //// //// //// OR1200's Instruction TLB //// //// //// //// This file is part of the OpenR...
#include <bits/stdc++.h> int n, i, j, l, h, k[5500], f[5500], t[5500]; int main() { scanf( %d n , &n); for (i = 1; i <= n; i++) { scanf( %d , &h); k[i] = k[i - 1] + h; j = i - 1; while (t[j] > k[i] - k[j]) j--; f[i] = f[j] + i - 1 - j; t[i] = k[i] - k[j]; } printf...
#include <bits/stdc++.h> void err() { std::cout << std::endl; } template <typename T, typename... Args> void err(T a, Args... args) { std::cout << a << ; err(args...); } using namespace std; const int mod = 998244353; const int inf = 1 << 30; const int maxn = 200000 + 5; const int maxq = 30...
// // Copyright 2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, e, f[200009], i, j, zx, xc, s, lf[200009], rg[200009], tim, up[200009]; vector<long long> v[200009], shv[200009]; pair<long long, long long> dp[200009]; bool bo[200009], ka[200009]; bool anc(long long q, long long w) { if (lf[q] <...
#include <bits/stdc++.h> using namespace std; const int N = 2505; int n, m, K, a[2][N][N], L[N][8], R[N][8], Lc[N][8], Rc[N][8]; char s[N]; long long ans; void work(int x1, int x2, int y1, int y2, int d) { if (y2 - y1 > x2 - x1) { swap(x1, y1), swap(x2, y2), d ^= 1; } if (x1 + 1 == x2) { ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int mo = 1000000007; const int inf = 0x3f3f3f3f; const int INF = 2000000000; int n, m, phi; int lt[100008], size[100008], f[100008], vis[100008], a[100008], b[100008], sum, tot, root, pre1[10000...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int inf = 2147483647; const long double pi = acos(-1); inline unsigned long long read() { unsigned long long data = 0, w = 1; char ch = getchar(); while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == ...
// (C) 2001-2012 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 doc...
//--------------------------------------------------------------------- // // Company: UNSW // Original Author: Lingkan Gong // Project Name: XDRS Demo // // Create Date: 17/07/2012 // Design Name: region_wrapper // //--------------------------------------------------------------------- `timescale 1ns/1ns modu...
#include <bits/stdc++.h> using namespace std; int a, b, c, k, k1, ans; int main() { cin >> a >> b >> c; if (b > c) swap(b, c); if (b <= a / 2 && c > a / 2) { cout << Final! << endl; return 0; } while (c != b) { b++; c++; b /= 2; c /= 2; ans++; } ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 == x2) { cout << abs(y1 - y2) << endl; } else if (y1 == y2) { ...
#include <bits/stdc++.h> const int nax = 1e5 + 5; using namespace std; int gcd(int x, int y) { if (x % y == 0) return y; return gcd(y, x % y); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int n, m; cin >> n >> m; vector<int> a(n + 1), b(m + 1...
// -- (c) Copyright 2009 - 2011 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...
#include <bits/stdc++.h> using namespace std; typedef struct { long long loc; long long num; } amar; bool operator<(amar x, amar y) { if (x.num >= y.num) return false; else return true; } int main() { long long n, k, c[40]; char s[100005]; memset(c, 0, sizeof c); ...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 1e5 + 5; vector<int> a[maxn]; int res[maxn]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { int q, w; scanf( %d%d , &q, &w); a[q].push_back(w); } int ...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * 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, version 3 of the License. * * This program is distributed in ...
// UC Berkeley CS251 // Spring 2018 // Arya Reais-Parsi () // emacs --batch riscv_top.v -f verilog-batch-auto `include "const.vh" module riscv_top ( input clk, input reset, output mem_req_valid, input mem_req_ready, output mem_req_rw, outpu...
#include <bits/stdc++.h> using namespace std; int n, a[105], c, x, k; int main() { cin >> n; for (int i = 0; i < 2; i++) { cin >> x; while (x--) cin >> k, c += 1 - a[k], a[k] = 1; } cout << (c == n ? I become the guy. : Oh, my keyboard! ); }
#include <bits/stdc++.h> using namespace std; struct node { int v, d; bool operator<(const node &a) const { if (d == a.d) return v < a.v; return a.d < d; } }; set<node> s; vector<int> adj[200005]; int d[200005], p[200005]; bool vis[200005]; void dfs(int u) { int l = adj[u].si...
`timescale 1ns/10ps module pll_0002( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'outclk1' output wire outclk_1, // interface 'locked' output wire locked ); altera_pll #( .fractional_vco_multiplier("true"), ...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; long long a_na_b_mod_c(long long a, long long b, long long c) { if (b == 0) return 1; long long t = a_na_b_mod_c(a, (b / 2), c) % c; if (b % 2 == 0) return (t * t) % c; else return (((t * t) % c) * (a % c)) ...
#include <bits/stdc++.h> using namespace std; int t, n, k; char a[5][500]; bool vis[5][500], check; bool valid(int x, int y) { if (x < 0 || x > 2 || vis[x][y]) return 0; return 1; } void dfs(int x, int y, int tm) { if (!valid(x, y) || check) return; if (a[x][y + 2 * tm] != . ) return; ...
// megafunction wizard: %LPM_COUNTER%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: LPM_COUNTER // ============================================================ // File Name: xxx_test_counter.v // Megafunction Name(s): // LPM_COUNTER // // Simulation Library Files(s): // lpm // =======================...
// (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 ...
#include <bits/stdc++.h> using namespace std; using namespace std; long long z = 1000000007; long long gcd(long long a, long long b) { if (a == 0) return b; if (b == 0) return a; return gcd(b, a % b); } long long power(long long a, long long b) { long long res = 1; while (b) { if (...
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const long long INFL = LLONG_MAX; const long double pi = acos(-1); const int MOD = 1e9 + 7; int ans; int N; inline long long mod(long long a) { a %= MOD; a += MOD; a %= MOD; return a; } inline int add(int a, int b...
#include <bits/stdc++.h> using namespace std; vector<vector<int> > solve(int N) { vector<vector<int> > res(2, vector<int>(1, 1)); for (int n = 2, r = 0; n <= N; ++n) { res[r].push_back(n); ++r; if (r >= int((res).size())) { vector<int> new_row; for (const vector<int>& r : r...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long a, b, sum = 0; cin >> a >> b; while (a > 0 && b > 0) { if (a < b) swap(a, b); sum += a / b; a = a - b * (a / b); } cout << sum << endl; } ...
module tb_m_elink_stub; reg [1:0] elink_txrr_packet; reg elink_txi_wr_wait_p; wire elink_txo_lclk_p; wire elink_txo_frame_n; wire elink_rx_lclk_pll; wire elink_rxwr_access; reg elink_rxrd_wait; wire elink_txrd_wait; wire elink_mailbox_full; reg elink_rx_ref_clk; reg elink_tx_lclk; reg elink_txwr_access; wire elink_txo...
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; inline int qpow(int a, int p) { int ans = 1; while (p) { if (p & 1) ans = (long long)ans * a % MOD; a = (long long)a * a % MOD; p >>= 1; } return ans; } inline int add(const int& x, const int& y) { r...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int N = 55; int n, cnt[N]; vector<pair<int, int> > adj[N]; void dfs(int u, int p, int depth, vector<pair<int, int> > &leaves) { bool leaf = 1; for (auto e : adj[u]) { int v, c; tie(v, c) = e; if (v == p) conti...
#include <bits/stdc++.h> using namespace std; const int N = 4000 + 1; const int sq = 100; const long long int mod = 1e9 + 7; const long long int inf = 4000 + 1; unordered_map<long long int, int> dp; int ps[N], n; inline int get(int l, int r) { return ps[r] - ps[l]; } int solve(int l, int r, int k, boo...
#include <bits/stdc++.h> int main() { int n, m; scanf( %d %d , &n, &m); int c[n], a[m]; int i; for (i = 0; i < n; i++) { scanf( %d , &c[i]); } for (i = 0; i < m; i++) { scanf( %d , &a[i]); } int j = 0, count = 0; int t = 0; for (i = 0; i < m;) { if (j >= n...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/**************************************************************** /* /* Description: /* count the frequency of each signal, /* for the huffman codeing processs afterwards /* Author: /* Guozhu Xin /* Date: /* 2017/7/11 /* Email: /* ********...
#include <bits/stdc++.h> using namespace std; int Popcount(long long int a) { int k; for (k = 0; a; a >>= 1) if (a & 1ll) k++; return k; } int Ffs(long long int a) { int k; for (k = 0; a; a >>= 1, k++) ; return k; } long long int C[50][50]; long long int getAns(long lon...
/** * 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...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Clifford Wolf <> * * 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 permission notice appear in all copies. * * T...
#include <bits/stdc++.h> int main() { int x, y; scanf( %d%d , &x, &y); double r = sqrt(x * x + y * y); int rmin = r; if ((double)rmin == r) { printf( black ); return 0; } if (x == 0 || y == 0) { printf( black ); return 0; } double tan = (double)y / (double)x...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; cout << s[0]; for (int i = 1; i < s.size() - 1; i += 2) { cout << s[i]; } cout << s.back(); cout << n ; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t...
// ============================================================== // 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...
/* * 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 ov7670_top( input clk, output scl, inout sda, output ov7670_reset, output pwdn, output xclk, input pclk, input href, input vsync, input [7:0] data, input M_AXIS_TREADY, output M_AXIS_TVALID, output M_AXIS_TLAST, output M_AXIS_TUSER, output [23:0] M_AXIS_TDATA); // htt...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, All Rights Reserved // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software...
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { return a > b ? a : b; } long long min(long long a, long long b) { return a < b ? a : b; } void fun(int arr[], int n) { stack<int> s; int left[n + 1]; int right[n + 1]; for (int i = 0; i < n; i++) { left...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:40:09 05/31/2016 // Design Name: // Module Name: Contador_AD_Year // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencie...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll t,i,maxi,sumi,mini; cin>>t; while(t--) { ll n; cin>>n; ll a[n]; for(i=0;i<n;i++) cin>>a[i]; maxi=-1; mini=a[0]; sumi=0; ...
`timescale 1 ns / 1 ps module averager_counter # ( parameter integer FAST_COUNT_WIDTH = 13, parameter integer SLOW_COUNT_WIDTH = 19 ) ( input wire restart, input wire clken, input wire [FAST_COUNT_WIDTH-1:0] count_max, input wire ...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e16; long long n, a[200005], p[200005], MA = 0, z = 0; int main() { scanf( %lld , &n); memset(p, 0, sizeof(p)); for (int i = 0; i < n; i++) { scanf( %lld , &a[i]); p[a[i]]++; if (p[a[i]] > MA) { MA = p[a[i...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int max_n = (1 << 21) + 100; vector<int> ans; int a[max_n]; void de(int i) { int l = i << 1; int r = (i << 1) | 1; if (a[l] == 0 && a[r] == 0) { a[i] = 0; return; } else { if (a[l] > a[r]) { ...
/* This file is part of JT51. JT51 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. JT51 is distributed in the hope tha...