text
stringlengths
59
71.4k
module convert_30to15_fifo( input wire rst, // reset input wire clk, // clock input input wire clkx2, // 2x clock input input wire [29:0] datain, // input data for 2:1 serialisation output wire [14:0] dataout); // 5-bit data out //////////////////////////////////////////////////// // Here we in...
module fifo_full_block (/*AUTOARG*/ // Outputs wr_fifo_full, wr_fifo_almost_full, wr_addr, wr_gray_pointer, // Inputs reset, wr_clk, wr_rd_gray_pointer, wr_write ); parameter AW = 2; // Number of bits to access all the entries //########## //# INPUTS //########## input reset...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2019 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc = 0; reg [63:0] cr...
// (C) 2001-2016 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
// // Copyright (C) 2015 Markus Hiienkari <> // // This file is part of Open Source Scan Converter project. // // 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...
/* * 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...
// megafunction wizard: %CRC Compiler v10.0% // GENERATION: XML // ============================================================ // Megafunction Name(s): // crc_gen_altcrc // ============================================================ // Generated by CRC Compiler 10.0 [Altera, IP Toolbench 1.3.0 Build 218] ...
#include <bits/stdc++.h> using namespace std; int main() { string str; int n; cin >> n >> str; bool flag = true; int fs = 0, ss = 0; for (int i = 0; i < n; i++) { if (str[i] != 4 && str[i] != 7 ) { flag = false; } } for (int i = 0; i < n / 2; i++) { fs +=...
/*+-------------------------------------------------------------------------- Copyright (c) 2015, Microsoft Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5; int n; pair<long long, long long> a[MAXN + 5]; priority_queue<long long, vector<long long>, greater<long long> > q; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; ++i) { long long t...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) using namespace std; const long long MAXN = 1e+5 + 7; const long long MOD = 1e+9 + 7; const long long INF = 0x7f7f7f7f7f7f7f7f; const int INFi = 0x7f7f7f7f; vector<long lo...
/** * 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_base::sync_with_stdio(false); cin.tie(0); ; long long t; cin >> t; while (t--) { long long n; cin >> n; if (n <= 3) cout << -1 << n ; else { if (n & 1) { for (long long i = 1; i...
#include <bits/stdc++.h> using namespace std; int main() { long long ele, i, j, ele1, k, n, a, b, q; cin >> q; for (i = 0; i < q; i++) { cin >> n >> a >> b; if (n == 1) { cout << a << endl; continue; } else if (2 * a > b) { ele = n % 2; ele1 = n / 2; ...
#include <bits/stdc++.h> using namespace std; int x, y, q; void exgcd(int a, int b) { int temp; if (b == 0) { x = 1; y = 0; q = a; } else { exgcd(b, a % b); temp = x; x = y; y = temp - a / b * y; } } int c3, c4, c5; int k3, k4, k5; int f, x0, Why_C...
#include <bits/stdc++.h> using namespace std; long long a[101010]; long long l, r, pref[101010]; long long ans, cnt, sum, max1, min1, ali; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; string s; cin >> n; while (n--) { cin >> l >> r; ...
#include <bits/stdc++.h> using namespace std; long long n, nn, p, pp, tt; int k, _s, t; char s[105]; int main() { for (scanf( %d , &t); t--;) { _s = k = 0; p = 1; scanf( %lld , &n); nn = n; while (nn) { nn /= 4; p *= 4; k++; } p /= 4; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); string a, b, c = ; cin >> a >> b; for (int i = 0; i < a.length(); i++) { if (a[i] + 1 < b[i]) { c += a[i] + 1; for (int j = i + 1; j < a.length(); j++) c += z ; ...
// 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...
//////////////////////////////////////////////////////////////////////////////// // // // Copyright 2006, 2007 Dennis van Weeren // // ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); if (fopen( .in , r )) { freopen( .in , r , stdin); freopen( .out , w , stdout); } int...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2019 by Driss Hafdi. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk, rst ); input clk; input rst; logic [2:0] ctrl_inc_single; logic [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...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// Copyright 1986-1999, 2001-2013 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2013.4 (lin64) Build 353583 Mon Dec 9 17:26:26 MST 2013 // Date : Mon Mar 17 23:05:27 2014 // Host : macbook running 64-bit Arc...
#include <bits/stdc++.h> using namespace std; vector<int> adj[1000009]; int in[1000009], out[1000009]; bool vs[22][1000009]; void dfs(int x, int n) { vs[x][n] = 1; for (auto& it : adj[n]) if (!vs[x][it]) dfs(x, it); } int main() { int N, M; scanf( %d%d , &N, &M); while (M--) { ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int mod = 1e9 + 7; int n, q; long long a[N], w[N], c[N << 1][2]; inline void add(int x, long long v, int id) { if (!id) for (; x <= n; x += x & -x) c[x][id] += v; else for (; x <= n; x += x & -x) c[x][id] = (c[x]...
module testbench(); parameter els_p = 16; parameter width_p = 32; parameter lg_els_lp = `BSG_SAFE_CLOG2(els_p); parameter num_test_p = 100000; bit clk; bit reset; bsg_nonsynth_clock_gen #( .cycle_time_p(1000) ) cg0 ( .o(clk) ); bsg_nonsynth_reset_gen #( .reset_cycles_lo_p(0) ,.re...
#include <bits/stdc++.h> using namespace std; using i64 = long long; using u64 = unsigned long long; struct debug { ~debug() { cerr << endl; } template <class c> debug& operator<<(c x) { cerr << x; return *this; } template <class c, class d> debug& operator<<(pair<c, d> x) { ...
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { char c; int f = 1; while (!isdigit(c = getchar())) if (c == - ) f = -1; x = (c & 15); while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15); x *= f; } const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string s; cin >> s; int l = s.length(); int f[l + 2]; int a[26] = {0}; int l1[1000005], l2[1000005]; for (int i = 0; i <= l; i++) { f[i] = 0, l1[i] = 0, l2[i] = 0; } for (int i = 0; ...
#include <bits/stdc++.h> using namespace std; struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _; const int lgn = 32; int n; vector<vector<int>> gr; vector<vector<int>> P; vector<int> lvl, ans, dp; map<pair<int, int>, int> ind; void pre(...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double pi = 3.1415926535897932384626; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 &&...
// DESCRIPTION: Verilator: Verilog example module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. // ====================================================================== // This is intended to be a complex example of several features, please also // see...
#include <bits/stdc++.h> using namespace std; typedef int* Pint; typedef long long* PLL; const int MAXN = 1E4; int a[110], f[110][3]{}; int n; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , a + i); for (int i = 1; i <= n; i++) { f[i][0] = min(min(f[i - 1][0], f[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; bitset<64> f1[3610], f2[3610]; int n, m; map<int, vector<int>> mp1, mp2; int y[66], y2[66]; set<int> s; vector<int> res; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> y[i], y[i] *= 2, mp1[y[i]].push_back(i); for (int i = 1; i <=...
#include <bits/stdc++.h> using namespace std; template <typename T, typename T2> T2 fac(T n) { return n < 2 ? 1 : fac<T, T2>(n - 1) * n; } template <typename T, typename T2, typename T3> T2 fac(T n, T3 mod) { return n < 2 ? 1 : (fac<T, T2, T3>(n - 1, mod) * n) % mod; } template <typename T> T ...
#include <bits/stdc++.h> using namespace std; int n, Q; string s[100005]; int L[100005], R[100005], K[100005]; long long ans[100005]; vector<int> in[100005], ot[100005], G[100005 << 1]; long long sm[100005]; int last, fa[100005 << 1], tr[100005 << 1][26], len[100005 << 1], tot, f[100005 << 1], sa[...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/06/11 12:17:32 // Design Name: // Module Name: lab5_3_1_tb // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // R...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = (int)1e9 + 7; const int N = (int)3e5 + 7; int n, p, k, a[N]; map<int, int> cnt; inline int add(int a, int b) { return (a += b) >= p ? a - p : a; } inline int mul(int a, ...
//========================================== // Function : Code Gray counter. // Coder : Alex Claros F. // Date : 15/May/2005. //======================================= `timescale 1ns/1ps module minimac_graycounter #(parameter COUNTER_WIDTH = 2) (output reg [COUNTER_WIDTH-1:0] GrayCount_out, ...
// -*- Mode: Verilog -*- // Filename : testbench.v // Description : Basic Picoblaze TB // Author : Philip Tracton // Created On : Thu May 21 22:35:48 2015 // Last Modified By: Philip Tracton // Last Modified On: Thu May 21 22:35:48 2015 // Update Count : 0 // Sta...
module TestCounter(); reg clk, sig; //Clock and input RF signal whose frequency we must measure. wire [13:0] f; //Calculated frequency. integer fMeas; integer fAct; //Actual frequency. integer nSig; integer testNum; //Number of positive edges in sig before counter computes f. Note that in repeat blocks, inversions o...
// megafunction wizard: %ALTERA_MULT_ADD v16.0% // GENERATION: XML // mult_fix8b.v // Generated using ACDS version 16.0 222 `timescale 1 ps / 1 ps module mult_fix8b ( output wire [15:0] result, // result.result input wire [7:0] dataa_0, // dataa_0.dataa_0 input wire [7:0] datab_0, // datab_0.datab_0 inp...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:47:55 03/21/2014 // Design Name: // Module Name: LC3_MIO_ADDRCTL // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies...
/** * 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 IP { string nm; int a, b, c, d; }; int n, m; int test(IP a[], IP x) { for (int i = 0; i < n; i++) { if (a[i].a == x.a && a[i].b == x.b && a[i].c == x.c && a[i].d == x.d) return i; } return -1; } IP a[1000], b[1000]; i...
#include <bits/stdc++.h> using namespace std; int n, a[500010], x, sz; long long ans; int main() { scanf( %d , &n); for (int step = 1; step <= n; step++) { scanf( %d , &x); while (a[sz - 1] >= a[sz] && a[sz] <= x && sz >= 2) { ans += min(a[sz - 1], x); sz--; } a[+...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int x, test; cin >> test; while (test--) { int n, c0, c1, h; string s; cin >> n >> c0 >> c1 >> h >> s; int cnt0 = 0, cnt1 = 0; for (auto &z : s) { ...
// trigger_generator.v `timescale 1 ns / 1 ps module trigger_generator ( input clk, input sync, input reset, input sel_random, input [31:0]rate, output reg [4:0]trg ); wire trg_rand; // random trigger reg trg_per; // periodic trigger always @(posedge clk or posedge reset) begin if (reset) trg <= ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int n; vector<int> dig; long long cnt[15]; long long C[25][25]; struct cond { int sum; int a[20]; string s; cond() { for (int i = 0; i < 20; i++) { a[i] = 0; } s = ; sum = 0; ...
// ---------------------------------------------------------------------- // Copyright (c) 2015, 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:...
module FSM(reset,clk, full, empty, rec, play, wr, rd); input wire reset; input wire clk; input wire full; input wire empty; input wire rec; input wire play; output reg wr; output reg rd; localparam e_espera = 2'b00; localparam e_rec = 2'b01; localparam e_play = 2'b11; reg [1:0] next_state = ...
module DE1_disp ( output reg [0:3] DISPn, output reg [0:6] HEX, input wire [0:6] HEX0, input wire [0:6] HEX1, input wire [0:6] HEX2, input wire [0:6] HEX3, input wire clk ); // state bits parameter state0 = 2'b00, state1 = 2'b01, state2 = 2'b10, state3 = 2'b11; reg [1:0] state; reg...
/** * 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 /* * File : MemControl.v * Project : University of Utah, XUM Project MIPS32 core * Creator(s) : Grant Ayers () * * Modification History: * Rev Date Initials Description of Change * 1.0 24-Jun-2011 GEA Initial design. * 2.0 28-Jun-2012 GEA...
#include <bits/stdc++.h> using namespace std; string s1, s2, s3; int win(string s1, string s2) { if (s1 == rock ) { if (s2 == rock ) return 0; if (s2 == scissors ) return 1; if (s2 == paper ) return 2; } if (s1 == paper ) { if (s2 == rock ) return 1; if (s2 == scis...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2017/07/31 09:57:03 // Design Name: // Module Name: Sonic // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revisio...
`timescale 1ns / 1ps // pwm_ctl.v ver 1.0 // Kazushi Yamashina // // // para_in <= 0 ~ 19999 // -Interval of asserting "en_out" will change // depending on the value of the "para_in". // -The more you increase the value the interval will increase. // // dir_in <= 1: positive rotate, 0: negative rotate m...
/*********************************************************************** * * Copyright (C) 2011 Adrian Wise * * 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; eit...
#include <bits/stdc++.h> using namespace std; int main() { long int n; scanf( %ld , &n); long long int a[n], i, x = 0, b[n], j; for (i = 0; i < n; i++) { scanf( %lld , &a[i]); } b[0] = 1; for (i = n - 2, j = 1; i >= 0; i--, j++) { if (a[i] < a[i + 1]) { b[j] = b[j - 1...
#include <bits/stdc++.h> using namespace std; template <typename T> void print_container(ostream& os, const T& c) { const char* _s = ; if (!c.empty()) { __typeof__(c.begin()) last = --c.end(); for (__typeof__((c).begin()) it = (c).begin(); it != (c).end(); ++it) { os << *it; ...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; template <typename A> ostream &operator<<(ostream &cout, vector<A> const &v); template <typename A, typename B> ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout << ( << p.first << , << p.second << ) ; ...
#include <bits/stdc++.h> using namespace std; struct s_ix { long long ix; long long val; }; bool operator<(s_ix aa, s_ix bb) { return aa.val - aa.ix < bb.val - bb.ix; } int main() { ios::sync_with_stdio(0); cin.tie(0); long long T; cin >> T; while (T--) { long long n, k, nc[2...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 10, mod = 1e9 + 7, inf = 1e18; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, k, x, s = 0, flag = 0, ans = 0; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> x; s += x; if (s / k)...
#include <bits/stdc++.h> using namespace std; void solve() { int n, d, m; cin >> n >> m >> d; int c[m], sum = 0; for (int i = 0; i < m; i++) { cin >> c[i]; sum += c[i]; } d--; if (sum + (m + 1) * d >= n) { cout << YES << endl; int k = (d > 0 ? (n - sum) / d : 0)...
#include <bits/stdc++.h> using namespace std; int c(int x) { int rev = 0; int tambah = 1; while (x != 0) { int temp = x % 10; if (temp == 4 || temp == 7) { rev += (tambah * (temp)); tambah *= 10; } x /= 10; } return rev; } int main() { int a, 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 law...
#include <bits/stdc++.h> using namespace std; queue<int> q; const int maxn = 40007; const int maxm = 800007; const int inf = 0x7f7f7f7f; struct E { int u, v, w, cf; } e[maxm]; int first[maxn], nt[maxm], ES = 1; bool acc[maxm]; inline void addE(int u, int v, int w, int cf) { e[++ES] = (E){u, ...
#include <bits/stdc++.h> int n, m, q; std::vector<int> dp; std::vector<std::pair<int, int> > edges; struct bip { std::vector<int> pers; std::stack<std::pair<int, int> > updates; std::stack<int> change; void update(int i, int j) { updates.push({i, pers[i]}); pers[i] = j; } int...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n, val; cin >> n; vector<int> vet; for (int i = 0; i < n; i++) { cin >> val; vet.push_back(val); } sort(vet.begin(), vet.end()); vector<int> ans; while (ans.size() < n) { ...
#include <bits/stdc++.h> using namespace std; char src[2002], tar[2002]; int ans[2002 * 4], n; int get(int l, int r, char ch) { for (int i = l; i <= r; i++) if (src[i] == ch) return i; return -1; } void reverse(int l, int r) { for (int i = l; i < r - i + l; i++) swap(src[i], src[r - i + 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...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: wb_rom_32x8192.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =========================...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int main() { long long r; cin >> r; if (r % 2 == 0 || r == 1 || r == 3) cout << NO ; else { long long x, y; long long up = (r - 1); for (int i = 1; i < 100000; i++) { if ((up / i - i - 1) % 2 == 0) { x = i; ...
//***************************************************************************** // (c) Copyright 2008 - 2013 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 /...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n, c = 0, p = 0; cin >> n; long long int s = (n / 2); for (int i = 1; i <= s; i++) { p += 8; c += (p * i); } cout << c << endl; } }
#include <bits/stdc++.h> using namespace std; char tmp[100001]; string v[100001][2]; long long dp[100001][2]; long long c[100001]; int n; long long f(int i, int j) { if (i == n - 1) return 0; if (dp[i][j] == -1) { dp[i][j] = 1000000000000000LL; if (v[i][j] <= v[i + 1][0]) dp[i][j] = mi...
/** * 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 xpow(long long a, long long b) { if (!b) return 1; if (b == 1) return a; if (b & 1) { return ((a * xpow(a, b - 1))); } else { long long p = xpow(a, b / 2); return ((p * p)); } } int32_t main() { ios_base::sync_with...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, x = 0; char c[30][30] = {0}; scanf( %d n , &n); for (i = 1; i <= n; i++) { char temp[605] = ; cin.getline(temp, 605); int length = strlen(temp); for (j = 0; j < length; j++) { c[0][temp[j] - 96]...
#include <bits/stdc++.h> using namespace std; const int N = 1e5; const int INF = 1e9; long long MOD = 998244353; long long sum(long long n) { long long sm = 0; while (n) { sm += n % 10; n /= 10; } return sm; } int main() { list<int> a; list<int> b; long long n; ...
#include <bits/stdc++.h> using namespace std; long long n, m; vector<long long> a(30005); bool check(long long v) { long long i, val = 0; for (i = 0; i < n; i++) { long long x = a[i]; long long y = (a[i] + v) % m; if (y >= x) { if (x > val) val = x; if (y < val) return ...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003-2007 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; wire out; reg in; Genit g (.clk(clk), .value(in), .result(ou...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; long long c = n, maxi = INT_MIN, mini = INT_MIN, t = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (maxi != a[i]) { maxi = a[i]; mini = a[i]; t = 1; } else { ...
#include <bits/stdc++.h> const int MaxN = 100111; const int mod = 1000000009; int f[MaxN]; int getFather(int x) { if (f[x] == x) return f[x]; return f[x] = getFather(f[x]); } int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) f[i] = i; int ans = 0; for (in...
#include <bits/stdc++.h> using namespace std; long long mM(long long a, long long b, long long mod) { long long res = 0; a %= mod; while (b) { if (b & 1) res = (res + a) % mod; a = (2 * a) % mod; b >>= 1; } return res; } long long fpow(long long first, long long second, lon...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 20; int n, x, y, a[maxn], o = 0; int main() { cin >> n >> x >> y; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { for (int j = max(0, i + x - 1); j < i; j++) { if (a[j] < a[i]) { o = 1...
/* Copyright (c) 2014 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 m = 10; int a[10], b[10], ap[10], bp[10]; int n; int main() { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); string s; cin >> s; n = int(s.size()); for (int i = 0; i < n; ++i) { int num = s[i] - 0 ; ++ap[num]; ...
// (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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2011 by Wilson Snyder. // bug420 typedef logic [7-1:0] wb_ind_t; typedef logic [7-1:0] id_t; module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg ...
/* * This file is part of the DSLogic-hdl project. * * Copyright (C) 2014 DreamSourceLab <> * * 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 2 of the License, or * (at yo...
module ARM_CU_ALU_TestBench5; parameter sim_time = 750*2; // Num of Cycles * 2 reg MFC , Reset , Clk , MEMSTORE,MEMLOAD; reg [31:0] MEMDAT; wire MFA,READ_WRITE,WORD_BYTE; wire [7:0] MEMADD; //module ARM_CU_ALU( input MFC , Reset , Clk , MEMSTORE,MEMLOAD,MEMDAT, output MEMADD, MFA,READ_WRITE,WORD_BYTE); ARM_CU_ALU C...
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { if (x < 0) return -x; return x; } template <class T> T sqr(T a) { return a * a; } const double pi = acos(-1.0); const double eps = 1e-8; char str1[2000010]; char str2[2000010]; int main() { int cross, c...