text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int maxn = 3e8; int l, r, cnt, ans1, pre1[20000005]; bitset<maxn> pre; int max1, max2; int main() { cin >> l >> r; pre[1] = pre[0] = 1; ans1 = 1; for (int yui = 2; yui <= r; yui++) { if (pre[yui] == 0) { cnt++; pre1[cn...
/** * 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; long long gcd(long long x, long long y) { if (x == 0) return y; return gcd(y % x, x); } int main() { int t; long long r, b, k; scanf( %d , &t); while (t--) { scanf( %I64d%I64d%I64d , &r, &b, &k); long long Gcd = gcd(r, b); r...
///////////////////////////////////////////////////////////////////////// // Copyright (c) 2008 Xilinx, Inc. All rights reserved. // // XILINX CONFIDENTIAL PROPERTY // This document contains proprietary information which is // protected by copyright. All rights are reserved. This notice ...
#include <bits/stdc++.h> using namespace std; struct Bus { long long s, t; }; bool cmp(Bus &a, Bus &b) { return a.t < b.t; } long long n, m, it[4 * 111111], tmp = 1, l, r; Bus bus[111111]; vector<long long> positions; void update(int idx, int l, int r, int pos, long long val) { if (pos < l || po...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100000 + 2; const int MAX_M = 100000 + 2; int weight[MAX_N]; struct Edge { int v, x; } E[MAX_M * 10]; int tot; template <int N> struct AdjList { int l[N]; inline void addEdge(int u, int v) { E[tot] = (Edge){v, l[u]}; ...
/** * 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 memtest00(clk, setA, setB, y); input clk, setA, setB; output y; reg mem [1:0]; always @(posedge clk) begin if (setA) mem[0] <= 0; // this is line 9 if (setB) mem[0] <= 1; // this is line 10 end assign y = mem[0]; endmodule // ---------------------------------------------------------- module memtest01(...
/** * 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) 2002 Steven Wilson () // // 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) // ...
#include <bits/stdc++.h> using namespace std; struct ty { int d[4][11], a; } t[400005], ans; int n, m, q, x, y, a[11][100005], co[42], col, fa1, fa2, fa[42]; int find(int x) { if (x == fa[x]) return x; return fa[x] = find(fa[x]); } ty update(ty x, ty y) { ty z; for (int i = 1; i <= n; ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; vector<string> N(a), M(b); for (auto& i : N) cin >> i; for (auto& i : M) cin >> i; int q; cin >> q; while (q--) { int n; cin >> n; cout << N[(n - 1) % a] << M[(n - 1) % b] << n ; ...
#include <bits/stdc++.h> using namespace std; const int G = 2520; const int B = 41; const int MAXN = B * G; unsigned char S[G][B], ps[B + 1][G][4], mp[256]; string e; void Pre() { mp[ A ] = 0; mp[ G ] = 1; mp[ T ] = 2; mp[ C ] = 3; } void build(int g) { for (int i = 0; i < 4; i++) ...
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long p); inline int D() { int t; scanf( %d , &t); return t; } inline long long llD() { long long t; scanf( %lld , &t); return t; } const int N = 1e6 + 5; long long arr[N], cost[N]; int ...
`timescale 1ns/10ps `include "pipeconnect.h" module dc_ctrl(input wire clk, input wire rst, input wire `REQ dc_ctrl_req, output wire `RES dc_ctrl_res); parameter debug = 0; wire [31:0] addr, q; reg r_ = 0; always @(p...
// Copyright (c) 2013, Simon Que // 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 must retain the above copyright notice, this // list of conditions and the...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010, 2011 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 dis...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10, M = 2e5 + 10; struct upd { int r, s, t, id; } t; vector<upd> v[M]; struct edge { int x, y; } e[M]; int ans[M], n, m, qi, f[N][N]; signed main() { int x; scanf( %d %d %d , &n, &m, &qi); for (register int 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 law...
#include <bits/stdc++.h> using namespace std; int n, n1, n2, mn, mx; int A[100001]; int main() { cin >> n >> n1 >> n2; for (int i = 0; i < n; i++) { cin >> A[i]; } sort(A, A + n); mn = min(n1, n2); mx = max(n1, n2); double s1 = 0; double s2 = 0; int nr = 0; int k = ...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; long long int t, n, m, a[1000005] = {0}, d[1000005], b[1000005]; stack<long long int> s; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long long int i, j, k, x, y; cin >> n >> m; ...
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read() { T s = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { s = (s << 3) + (s << 1) + ch - 48; ch = getchar(); } ...
#include <bits/stdc++.h> using namespace std; int n, a[210], m; priority_queue<int> q; priority_queue<int, deque<int>, greater<int> > q2; int main() { while (scanf( %d%d , &n, &m) != EOF) { for (int i = 0; i < n; ++i) scanf( %d , &a[i]); int ans = a[0]; for (int i = 0; i < n; ++i) { ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void upmax(T& a, T b) { if (a < b) a = b; } template <class T> inline void upmin(T& a, T b) { if (a > b) a = b; } const int maxn = 307; const int maxm = 100007; const int mod = 1000000007; const int inf = 0x7fffffff; ...
#include <bits/stdc++.h> using namespace std; const int Maxn = 100 * 1000 + 5; int n; vector<int> arr[Maxn]; int main() { scanf( %d , &n); int x, k; for (int i = 0; i < n; i++) { scanf( %d%d , &x, &k); arr[k - 1].push_back(x); } for (int i = 0; i < Maxn; i++) { int 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 law...
module key_expansion(key_in, rk_delayed_out, round_cnt, rk_last_out, clk, input_sel, sbox_sel, last_out_sel, bit_out_sel, rcon_en); input [7:0] key_in; output [7:0] rk_delayed_out; output [7:0] rk_last_out; input [3:0] round_cnt; input clk; input input_sel, sbox_sel, last_out_sel, bit_out_...
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x)...
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getcha...
`ifndef _alu `define _alu module alu( input [3:0] ctl, input [31:0] a, b, output reg [31:0] out, output zero); wire [31:0] sub_ab; wire [31:0] add_ab; wire oflow_add; wire oflow_sub; wire oflow; wire slt; assign zero = (0 == out); assign sub_ab = a - b; assign add_ab = a + b; // over...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5, MOD = 1e9 + 7; long long k, p, q; string ans; set<long long> s; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> k; if (k < 25) { cout << -1 << endl; return 0; }...
#include <bits/stdc++.h> using namespace std; const long long mxn = 105; const long long mxm = 1; const long long INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; const double eps = 1e-7; long long a[mxn]; signed main(void) { long long q; cin >> q; while (q--) { long long n; cin ...
/* * 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 N = 1e9 + 5; long long n, k; bool valid(long long x) { long long maxi = (x)*k - ((x - 1) * ((x + 2) / 2.0)); if (maxi >= n) return true; else return false; } long long binary() { long long lo = 0, mid, hi = k; whil...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\Debounce_Index.v // Created: 2014-09-08 14:12:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ------------------------------------------------------------- // -----------------------...
//----------------------------------------------------------------------------- // // (c) Copyright 2012-2012 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 ...
////////////////////////////////////////////////////////////////////// //// //// //// uart_testbench_utilities.v //// //// //// //// This file is part of the "...
#include <bits/stdc++.h> using namespace std; const int N = 2 * 100 * 1000 + 10; string s, t; int d[N]; int LastSeen[N]; void input() { cin >> s >> t; return; } void PrePros() { int keep = (int)(t.size()) - 1, pnt = (int)(s.size()) - 1; while (keep >= 0) { if (s[pnt] == t[keep]) { ...
/** * 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 = 1100; long long x, y; int n; int main() { std::ios::sync_with_stdio(false); while (cin >> n) { long long x1, x2, y1, y2; x1 = y1 = 1000000000; x2 = y2 = -1000000000; for (int i = 0; i < n; ++i) { cin >> x >>...
//***************************************************************************** // (c) Copyright 2008-2010 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 // ...
/* * 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...
/* Distributed under the MIT license. Copyright (c) 2016 Dave McCoy () 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, mo...
#include <bits/stdc++.h> using namespace std; float r, p, m; float a[100 * 1000]; int main() { cin >> m >> r; p = r * sqrt(2); a[0] = 2 * r; a[1] = 2 * r + p; for (int i = (2), _end = (m); i < _end; ++i) { a[i] = 2 * p; a[i] += 2 * r * (i - 1); } float sum = 0; sum +=...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 18:20:57 09/06/2015 // Design Name: // Module Name: FSM_Mult_Function // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenci...
////////////////////////////////////////////////////////////////////// //// //// //// OR1200's Tick Timer //// //// //// //// This file is part of the OpenR...
// File: RingCounter_TBV.v // Generated by MyHDL 0.10 // Date: Wed Sep 5 07:53:29 2018 `timescale 1ns/10ps module RingCounter_TBV ( ); // myHDL -> verilog Testbench for `RingCounter` module reg clk = 0; reg rst = 0; wire [3:0] q; reg [1:0] Dir = 2'b10; wire [3:0] seed; reg [3:0] RingCounter0_0_q_i = 3; assign s...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const int M = 2e5 + 10; struct Edge { int u, v, cap, flow = 0; Edge(int u, int v, int cap) : u(u), v(v), cap(cap) {} }; class Dinic { public: vector<Edge> edges; vector<vector<int>> G; int n, m = 0, s, t; vector<int> H, ptr; queue<in...
/* * 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/10ps module dummy_master( input wire clock // K5 PLL1 input clock (50 MHz) ,input wire reset // Memory access ,input mem_waitrequest ,output reg [1:0] mem_id = 1 ,output reg [29:0...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // // 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 // //...
module cov_miss_fifo import bsg_cache_non_blocking_pkg::*; ( input clk_i , input reset_i , input v_i , input ready_o , input v_o , input yumi_i , input bsg_cache_non_blocking_miss_fifo_op_e yumi_op_i , input scan_not_dq_i , input read_write_same_addr , input v_r , in...
/** * 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() { ios::sync_with_stdio(false); cin.tie(nullptr); int tc; cin >> tc; while (tc--) { int n, m, x1, y1, x2, y2, w, h; cin >> n >> m >> x1 >> y1 >> x2 >> y2 >> w >> h; int right = n - x2; int left = x1; int up = m...
//Legal Notice: (C)2016 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
// DESCRIPTION: Verilator: Verilog Test for short-circuiting in generate "if" // that should not work. // // The given generate loops should attempt to access invalid bits of mask and // trigger errors. // is defined by SIZE. However since the loop range is larger, this only works // if short-circuited evaluation of th...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, i, j, res = 0, k, v1, v2; cin >> n; vector<long long> v; for (i = 0; i < n; i++) { cin >> j; v.emplace_back(j); } if (n == 1) { cout << v[0] << ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, s = 0, i, x, vs = 0; vector<int> a; cin >> n; for (i = 0; i < n; i++) { cin >> x; a.push_back(x); vs += x; } sort(a.begin(), a.end(), std::greater<int>()); if (n == 1) cout << a[0] << endl...
module ram_wb_b3( wb_adr_i, wb_bte_i, wb_cti_i, wb_cyc_i, wb_dat_i, wb_sel_i, wb_stb_i, wb_we_i, wb_ack_o, wb_err_o, wb_rty_o, wb_dat_o, wb_clk_i, wb_rst_i); parameter dw = 32; parameter aw = 32; input [aw-1:0] wb_adr_i; input [1:0] wb_bte_i; input [2:0] wb_cti_i; input wb_cyc_i;...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; const int mod = 100003; const int INF = 0x3f3f3f; int n, m, x, y; int vis[N]; struct node { int x, r, i, v; } tar[N]; bool cmp1(node &x, node &y) { return x.x < y.x; } bool cmp2(node &x, node &y) { return x.i < y.i; } int fin...
/******************************************************************************* * 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 ...
/** * 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 ) using namespace std; void init_ios() { ios_base::sync_with_stdio(0); cin.tie(0); } const int N = (1 << 19); int n, m, jump[N][20]; pair<int, int> a[N], drz[2 * N]; void add(int v, int val, int ind) { v += N; if (val < drz[v].first) retu...
// 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 : Tue Jun 06 02:47:18 2017 // Host : GILAMONSTER running 64-bit major release (...
// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long int n; cin >> n; vector<long long int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; sort(v.begin(), v.end()); if (n == 1) { ...
#include <bits/stdc++.h> using namespace std; void solve(); void precalc(); int main() { string s = change me please ; int t = 1; while (t--) solve(); return 0; } void solve() { int n; cin >> n; vector<int> a(n), h(n); for (int i = 0; i < n; ++i) cin >> a[i] >> h[i]; int...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010 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 distribut...
#include <bits/stdc++.h> using namespace std; vector<int> graph[200000]; int color[200000], black, white, maxDist, farNode; void solve(int node, int par, int dis) { if (dis > maxDist) farNode = node, maxDist = dis; for (auto &v : graph[node]) { if (v == par) continue; solve(v, node, dis + (c...
#include <bits/stdc++.h> int main() { int x, y, s; scanf( %d %d %d , &x, &y, &s); if (s >= 0) { y = y + s; if (y % x) printf( %d , y % x); else printf( %d , x); } else if (s < 0) { double p = abs(s); p = ceil(p / x); y = y + s + (p * x); if (y ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const int mod = 1e9 + 7; int n, l[N], t[N]; long long r; int main() { scanf( %d%lld , &n, &r); for (int i = 0; i < n; i++) scanf( %d , l + i); for (int i = 0; i < n; i++) { scanf( %d , t + i); if (t[i] < l[i]) retur...
#include <bits/stdc++.h> using namespace std; const int MaxK = 53, MaxN = 2000005; int N, K; char A[MaxN]; char B[MaxN]; int id(char c) { return ( a <= c && c <= z ) ? c - a : c - A + 26; } namespace KuhnMunkres { const int MAX_N = 505; const int INF = 100000000; const int BASE = 1000; int n...
#include <bits/stdc++.h> using namespace std; int n, K, a[100100], f[30030][205][4][2]; bool vis[30030][205][4][2]; void work() { memset(f, -127, sizeof(f)); for (int i = 1; i <= n; i++) { f[i][1][0][0] = -a[i]; f[i][1][2][0] = a[i]; vis[i][1][0][0] = 1; vis[i][1][2][0] = 1; ...
`include "project_defines.v" module bipolar_micro_stepper #( parameter CLOCK_DIV = 16 )( input clk, input rst, //Control input i_go, output o_busy, input i_stop, //Position input [31:0] i_current_position, ou...
/* * freq_gen_tb.v: Test bench for freq_gen.v * author: Till Mahlburg * year: 2019 * organization: Universität Leipzig * license: ISC * */ `timescale 1 ns / 1 ps `ifndef WAIT_INTERVAL `define WAIT_INTERVAL 1000 `endif `ifndef M_1000 `define M_1000 1000 `endif `ifndef D `define D 1 `endif `ifndef O_1000 ...
/* ------------------------------------------------------------------------------- -- Title : PS/2 interface -- Project : ------------------------------------------------------------------------------- -- File : ps2.v -- Author(s) : Daniel Quintero <> -- : Stefan Kristiansson <> -- ...
#include <bits/stdc++.h> using namespace std; int getint() { unsigned int c; int x = 0; while (((c = getchar()) - 0 ) >= 10) { if (c == - ) return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - 0 ); } while (((c = getchar()) - 0 ) < 10); return x...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 77; long long a[N], f[N], l, r; int n, k; bool check(int mid) { for (int i = 1; i <= n; i++) f[i] = 0; f[0] = 1; int pl = 1, pr; for (int i = 1; i <= n; i++) { while (a[i] - a[pl] > mid) pl++; pr = i - k + 1; f...
/* * 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...
`define WIDTH_P 4 `define ELS_P 3 `include "bsg_defines.v" /********************************** TEST RATIONALE ************************* 1. STATE SPACE Since the values of data inputs have little influence on the functioning of DUT, they are kept constant and not varied. The select input should be a one ho...
//Legal Notice: (C)2017 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
// (C) 2001-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 any of the foregoing (including device programming or simulation // files), and any associated doc...
`timescale 1 ns / 1 ps module boxcar_filter_tb(); parameter DATA_WIDTH = 8; reg clk; reg signed [DATA_WIDTH-1:0] din; wire signed [DATA_WIDTH-1:0] dout; boxcar_filter #( .DATA_WIDTH(DATA_WIDTH) ) DUT ( .clk(clk), .din(din), .dout(dout) ); parameter CLK_PERIOD = 8; initial begi...
//Listing 10.1 module ps2_tx ( input wire clk, reset, input wire wr_ps2, input wire [7:0] din, inout wire ps2d, ps2c, output reg tx_idle, tx_done_tick ); // symbolic state declaration localparam [2:0] idle = 3'b000, rts = 3'b001, start = 3'b010, data = 3'b01...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [6:0] mem1d; reg [6:0] mem2d [5:0]; reg [6:0] mem3d [4:0][5:0]; ...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; long long arr[t], sum = 0; for (int i = 0; i < t; ++i) { cin >> arr[i]; sum += arr[i]; } if (sum != 0) { cout << YES << endl; cout << 1 << endl; cout << 1 << << t << endl; ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 10; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; inline int read() { static char buf[1000000], *p1 = buf, *p2 = buf; register int x = false; register char ch = p1 == p2 &&...
`default_nettype none // ============================================================================ module oserdes_test # ( parameter DATA_WIDTH = 8, parameter DATA_RATE = "SDR", parameter ERROR_HOLD = ) ( // "Hi speed" clock and reset input wire CLK, input wire RST, // OSERDES clocks input wire CLK1...
#include <bits/stdc++.h> using namespace std; const int maxn = 505, MOD = 1e9 + 7; struct node { node *ch[20], *fail; int cnt, id; node(node* son = NULL) { for (int i = 0; i <= 19; i++) ch[i] = son; fail = son; cnt = id = 0; } } nil, *null = &nil, *root = null, *nd[maxn]; typ...
#include <bits/stdc++.h> #pragma optimize( , off) #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma comment(linker, /STACK:36777216 ) const int mod = 1000000007; using namespace std; template <class T> vo...
#include <bits/stdc++.h> using namespace std; int main() { int n; int m; int sum = 0; int a[100005]; int rec[100005] = {0}; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) { int ss = a[i]; if (rec[ss] == 0) { rec[s...
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; int res = -1, pos = -1, j = 0; for (int i = 0; i < b.size(); i++) { if (a[j] != b[i]) { pos = j; if (res != -1 || a[j + 1] != b[i]) { res = 0; break; } 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 la...
// -*- verilog -*- // Copyright (c) 2012 Ben Reynwar // Released under MIT License (see LICENSE.txt) module qa_wrapper #( parameter WDTH = 32 ) ( input wire clk, input wire reset, input wire [WDTH-1:0] in_data, input wire in_nd, output wire [WDTH-1...
`define MSG_REQ 1'b1 `define MSG_RESP 1'b0 `define CMD_PA 4'b0000 `define CMD_CL 4'b0001 `define CMD_W 4'b0010 `define CMD_R 4'b0011 `define CMD_S 4'b0100 `define CMD_F 4'b0101 `define CMD_IN 4'b0110 `define CMD_CPD 4'b1000 `define CMD_CPR 4'b1001 `define CMD_CPF 4'b1010 `define CMD_CPS 4'b1011 `define CMD_EN 4'...
#include <bits/stdc++.h> using namespace std; template <class T> typename T::value_type arr_sum(const T& v, int n) { typename T::value_type sum = 0; for (int i = 0; i < n; ++i) sum += v[i]; return sum; } struct Sync_stdio { Sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(fa...
#include <bits/stdc++.h> int main() { int t, a, b, c, d, k, i, pen, pencil; scanf( %d , &t); for (i = 0; i < t; i++) { scanf( %d %d %d %d %d , &a, &b, &c, &d, &k); if (a % c != 0) { pen = (a / c) + 1; } if (a % c == 0) { pen = (a / c); } if (b % d != 0) ...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; struct custom_hash { size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return x + FIXED_RANDOM; } }; void solve() { long...
#include <bits/stdc++.h> using namespace std; long long n, m, i, x, ans; int main() { cin >> n >> m; x = 1; for (i = 1; i <= m; i++) x = x * 2 % 1000000009; ans = 1; for (i = 1; i <= n; i++) ans = ans * (x - i) % 1000000009; cout << ans; return 0; }