text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; string convert(string s) { int l = s.size(); if (l % 2 == 1) return s; string s1 = s.substr(0, l / 2), s2 = s.substr(l / 2); s1 = convert(s1); s2 = convert(s2); if (s1 < s2) return s1 + s2; else return s2 + s1; } bool equivale...
// File : ../RTL/hostController/directcontrol.v // Generated : 11/10/06 05:37:19 // From : ../RTL/hostController/directcontrol.asf // By : FSM2VHDL ver. 5.0.0.9 ////////////////////////////////////////////////////////////////////// //// ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: sctag_retbuf.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it and/...
#include <bits/stdc++.h> using namespace std; int n, i, poz, p[250]; double t, v[250], m[250], x[250], aux, mint, tempv1, tempv2; bool fcomp(int a, int b) { return x[a] < x[b]; } int main() { scanf( %d , &n); scanf( %lf , &t); for (i = 1; i <= n; ++i) scanf( %lf , &x[i]), scanf( %lf , &v[i])...
#include <bits/stdc++.h> using namespace std; const int OO = (int)2e9; const double eps = 1e-9; int x[3], y[3]; int main() { int i; vector<pair<int, int> > V(8); set<int> X; set<int> Y; for (i = 0; i < 8; i++) { cin >> V[i].first >> V[i].second; X.insert(V[i].first); Y.in...
//------------------------------------------------------------------- // // COPYRIGHT (C) 2014, VIPcore Group, Fudan University // // THIS FILE MAY NOT BE MODIFIED OR REDISTRIBUTED WITHOUT THE // EXPRESSED WRITTEN CONSENT OF VIPcore Group // // VIPcore : http://soc.fudan.edu.cn/vip // IP Owner : Yibo FA...
// 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_...
#include <bits/stdc++.h> using namespace std; long long inv[500005]; void getinv() { inv[0] = inv[1] = 1; for (int i = 2; i < 500005; i++) inv[i] = ((-1000000007 / i * inv[1000000007 % i]) % 1000000007 + 1000000007) % 1000000007; } long long slove(int n, int m) { long lon...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_io_ddr_vref_rptr.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute ...
// Copyright (c) 2000-2012 Bluespec, Inc. // 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, pub...
// cog_ctr /* ------------------------------------------------------------------------------- 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 General Pub...
`` tgpp::source [file join [file dirname [info script]] .. hamming_code.tgpp] `` ///////////////////////////////////////////////////////////////////////////////////////////////// // test module: instantiate all declared modules //////////////////////////////////////////////////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; int dp[605][305][305]; int a[305][305]; int max(int a, int b) { return a > b ? a : b; } int main() { int n; while (scanf( %d , &n) != EOF) { int i, j, k; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf( %d , &a[i][j]...
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); double n, m; char ch; cin >> n >> ch >> m; if (n >= 12) n -= 12; double ans1, ans2; ans2 = 6 * m; ans1 = n * 30 + 0.5 * m; cout << ans1 << << ans2 << endl; }
#include <bits/stdc++.h> using db = double; int read() { int x; scanf( %d , &x); return x; } const int N = 50007; const db eps = 1e-10; db x, y, k[N], b[N], ans; int n, c, t[N * 2], las[N], L[N * 2], R[N * 2]; struct node { db ang; int id; } a[N * 2]; db sqr(db a) { return a * a;...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; string s; int a[maxn], tot, n; int main() { while (cin >> n) { memset(a, 0, sizeof a); tot = 0; cin >> s; string temp = s; if (n == 1) { puts( 0 ); continue; } for (int i = n -...
#include <bits/stdc++.h> using namespace std; int i, L; char s[100005]; int main() { scanf( %s , &s); L = strlen(s); for (i = 0; i < L; i++) printf( %c , s[i]); for (i = L - 1; i >= 0; i--) printf( %c , s[i]); }
#include <bits/stdc++.h> using namespace std; template <class C> constexpr int sz(const C &c) { return int(c.size()); } using ll = long long; using ld = long double; constexpr const char nl = n , sp = ; using T = long double; constexpr const T EPS = 1e-9; bool lt(T a, T b) { return a + EPS ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100020; const int logn = 18; const int MOd = 1e9 + 7; int a, b; int ar[maxn]; int main() { scanf( %d %d , &a, &b); for (int i = 1; i <= a; i++) scanf( %d , &ar[i]); double ans = 0.0; for (int i = 1, j, k, t; i <= b; i++) { ...
#include <bits/stdc++.h> using namespace std; int arr[100002][2]; long long dp[100002][2][2]; int n; long long solve(int idx, int arga3, int dir) { if (idx == 1 && dir == 0) return 0; if (idx == n && dir == 1) return 0; long long &ret = dp[idx][arga3][dir]; if (ret != -1) return ret; ret =...
#include <bits/stdc++.h> using namespace std; const int M = 100010; int n, i, Ans, b[M], pos[M]; long long A, w1, w2, m, ans, s[M]; struct shit { long long w; int id; } a[M]; bool cmp(shit x, shit y) { return x.w > y.w; } int main() { scanf( %d%I64d%I64d%I64d%I64d , &n, &A, &w1, &w2, &m); ...
#include <bits/stdc++.h> using namespace std; int main() { int m, n; cin >> m >> n; vector<string> nums(n); for (int i = 0; i < (int)(n); ++i) cin >> nums[i]; vector<long long> c(m, 1); for (int i = 0; i < (int)(m); ++i) { for (int j = 0; j < (int)(i); ++j) { int match = 1; ...
//====================================================================== // // Module Name: WHIRLPOOL_WCIPHER_PI // Description: Pi function of Whirlpool W-Cipher // // Language: Verilog-2001 // // Module Dependencies: none // // Developer: Saied H. Khayat // URL: https://github.com/saiedhk // ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = int(1e6) + 10; int n; char buffer[MAX_N]; int main() { gets(buffer); n = strlen(buffer); reverse(buffer, buffer + n); vector<pair<char, int> > v; for (int i = 0, j, l = -1; i < n; i = j) { for (j = i; j < n && buffer[j] ...
// We assume clock with frequency F = 100 MHz or period T = 10 ns `timescale 1ns / 1ps module mealy_fsm_tb; // Inputs (reg because they are assigned using procedural blocks) reg clk; reg rst; reg inp; // outputs wire oup; wire [1:0] current_state; wire [1:0] next_state; // Clock Const...
module asyc_add_tb; reg reset = 1; reg button = 0; reg clk = 0; wire [6:0] leds; syc_add add1(leds, reset, button, clk); initial begin $monitor($time, " reset: %b, button: %b, digit: %b, leds: %b", reset, button, add1.digit, leds); #0 reset = 1'b0; #10 reset = 1'b1; #5 button = 1'b1; ...
// DESCRIPTION: Verilator: System Verilog test of array querying functions. // // This code instantiates a module that calls the various array querying // functions. // // This file ONLY is placed into the Public Domain, for any use, without // warranty. // Contributed 2012 by Jeremy Bennett, Embecosm. module t (/*AU...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2019 by Roman Popov. module dut #( parameter DEPTH = 16, parameter WIDTH = 32, parameter RAM_SPLIT_WIDTH = 16 ) ( output logic [WIDTH-1:0] ram_dataout ); ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; char maz[505][505]; int dp[10][505][505]; inline void cm(int& x) { if (x >= mod) x -= mod; } int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) scanf( %s , maz[i] + 1); int up = (n + m - 1) /...
#include <bits/stdc++.h> using namespace std; long long read() { char x = getchar(); long long ans = 0; while (!isdigit(x)) x = getchar(); while (isdigit(x)) ans = ans * 10 + x - 0 , x = getchar(); return ans; } long long in[250005], now, n, vis[250005], dp[250005][2]; vector<pair<long lo...
#include <bits/stdc++.h> using namespace std; int n, k; int l, r; long long pw[500007], inv[500007], ans = 0; pair<int, int> p[500007]; const long long mod = 1e9 + 7; long long pwr(long long x, long long y) { if (y == 0) return 1LL; if (y == 1) return x; long long ret = pwr(x, y / 2); if (...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000; int prime[MAXN + 1]; void getPrime() { memset(prime, 0, sizeof(prime)); for (int i = 2; i <= MAXN; i++) { if (!prime[i]) prime[++prime[0]] = i; for (int j = 1; j <= prime[0] && prime[j] <= MAXN / i; j++) { prime[p...
#include <bits/stdc++.h> using namespace std; int main() { string a[6], b[6], c[6]; a[0] = purple ; b[0] = Power ; a[1] = green ; b[1] = Time ; a[2] = blue ; b[2] = Space ; a[3] = orange ; b[3] = Soul ; a[4] = red ; b[4] = Reality ; a[5] = yellow ; b[5]...
// // my_fpga_test_count_up_1k.v // `timescale 1ns/1ps `define ms(t) (t * 1e6) `define ns(t) (t) module my_fpga_test_count_up_1k; reg clk = 0, n_rst = 0; reg up = 0, dn = 0; wire [31:0] cnt; wire [3:0] cnt_1k; reg in1 = 0, in2 = 0; wire out1, out2; time t, u; my_fpga uut(clk, n_rs...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int N = 1e4 + 10; int T, n; int id[N], cnt[10], ans[10]; char s[N]; inline int check(int id) { int mini = inf; for (int i = 1; i <= 4; i++) mini = min(mini, cnt[i]); if (cnt[id] == mini) return 1; return 0; }...
#include <bits/stdc++.h> using namespace std; int x[10][10]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; x[a][b] = x[b][a] = 1; } if (n < 7) cout << m << n ; else { int sum = 30; for (int i = 1; i <= 7; ...
#include <bits/stdc++.h> using namespace std; const int N = (int)2e5 + 5; int n, m; vector<vector<int>> adj; int Set[N]; bool vis[N]; bool isBipartite(int node) { for (int& x : adj[node]) { if (!vis[x]) { vis[x] = 1; Set[x] = 3 - Set[node]; if (!isBipartite(x)) return fal...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 8; const int mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long n, m; cin >> n >> m; long long arr[n][m]; long long x = 0; for ...
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; int x, y; int z = 1; cin >> n >> m; cin >> x >> y; cout << x << << y << n ; cout << 1 << << y << n ; for (int i = 1; i <= n; i++) { vector<pair<int, int>> v; for (int j = 1; j <= m; j++) { ...
#include <bits/stdc++.h> const int MAXA = 5005; const int MAXN = 2016; int array[MAXN]{}; long long diffr[MAXA]{}; long long suffx[MAXA]{}; long double total; long long Ans = 0; int N; int main() { scanf( %d , &N); for (int i = 0; i < N; ++i) scanf( %d , &array[i]); total = N * (N - 1) >> ...
#include <bits/stdc++.h> using namespace std; string s1, s2; int ar[200001]; int n; int n2; bool possible(int check) { int posi[200001] = {0}; for (int i = 0; i < check + 1; i++) { posi[ar[i]]++; } int start1 = 0; int start2 = 0; while (start1 < n && start2 < n2) { if (po...
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, d, p, q, s, t, r; cin >> a >> b >> d; p = a + a + b + b; q = a + d + b; s = a + d + d + a; t = b + d + d + b; r = min(p, min(q, min(s, t))); cout << r << endl; return 0; }
#include <bits/stdc++.h> using namespace std; unsigned long long n, k, b1, b2, b[200007], ans, dl, dll[200007], an[200007]; map<unsigned long long, unsigned long long> a[11]; int main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> n >> k; for (unsigned long long i = 1; i <= n; ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: cpx_dp_maca_r.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it and...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2003-2007 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 `define zednkw 200 module BreadAddrDP (zfghtn, cjtmau, vipmpg, knquim, kqxkkr); input zfghtn; input ...
#include <bits/stdc++.h> using namespace std; using lli = long long int; using pii = pair<int, int>; using vi = vector<int>; using vb = vector<bool>; using vvi = vector<vector<int>>; using vlli = vector<long long int>; using vpii = vector<pair<int, int>>; const int N = 500005; mt19937 rng(chrono::st...
// ============================================================================= // COPYRIGHT NOTICE // Copyright 2006 (c) Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // This confidential and proprietary software may be used only as authorised by // a licensing agreement from Latt...
// // Paul Gao 01/2021 // // `timescale 1ps/1ps module bsg_link_ddr_tester #(parameter width_p = 64 ,parameter channel_width_p = 16 ,parameter num_channels_p = 1 ,parameter lg_fifo_depth_p = 6 ,parameter lg_credit_to_tok...
/** * mcrom_tb.v - Microcoded Accumulator CPU * Copyright (C) 2015 Orlando Arias, David Mascenik * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2005 by Wilson Snyder. module t (clk); input clk; reg [0:0] d1; reg [2:0] d3; reg [7:0] d8; wire [0:0] q1; wire [2:0] q3; wire [7:0] q8; // verilator lint_o...
#include <bits/stdc++.h> using namespace std; int a1, a2, a3, a4; int main() { cin >> a1 >> a2 >> a3 >> a4; if (a3 == a4) { if (a1 - a3 - 1 >= 0 && a2 - a4 >= 0) { for (int i = 0; i < a1 - a3 - 1; i++) cout << 4 ; for (int i = 0; i < a3; i++) cout << 47 ; for (int i = 0; i ...
/******************************************************************************* * Module: fifo_same_clock_fill * Date:2014-05-20 * Author: Andrey Filippov * Description: Configurable synchronous FIFO using the same clock for read and write. * Provides fill level - number of words currently in FIFO * * Copyrig...
// megafunction wizard: %LPM_MULT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: lpm_mult // ============================================================ // File Name: mult8x8.v // Megafunction Name(s): // lpm_mult // // Simulation Library Files(s): // lpm // =================================...
`include "elink_regmap.v" module erx_arbiter (/*AUTOARG*/ // Outputs rx_rd_wait, rx_wr_wait, edma_wait, ecfg_wait, rxwr_access, rxwr_packet, rxrd_access, rxrd_packet, rxrr_access, rxrr_packet, // Inputs erx_rr_access, erx_packet, emmu_access, emmu_packet, edma_access, edma_packet, ecfg_access, ecfg_pa...
#include <bits/stdc++.h> using namespace std; inline int read() { int ans = 0, fh = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) fh = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) ans = (ans << 1) + (ans << 3) + ch - 0 , ch = getchar(); retu...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, i; cin >> n; long long cnt = 0; while (n >= 10) { n++; while (n % 10 == 0) { n = n / 10; } cnt++; } cout << cnt + 9 << endl; }
/** * 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 t; cin >> t; while (t--) { int a, b, c, d; cin >> a >> b >> c >> d; if (min(a, b) + min(c, d) == max(a, b) && max(a, b) == max(c, d)) { cout << YES n ; } else { cout << NO n ; } } }
// dig /* ------------------------------------------------------------------------------- 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 General Public ...
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } template <typename T> T abs(T x) { return x < 0 ? -x : x; } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const int MOD = (int)1e+9 + 7; int n; vector<pair<int...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000001; const long double EPS = 1e-9; const int MOD = 1000000007; const long long LLINF = 1000000000000000001; const int maxn = 1042; int n; int a[maxn]; char ans[maxn][maxn]; bool good[maxn]; int main() { ios_base::sync_with_st...
`include "defines.v" module id_ex ( input wire clk, input wire rst, input wire[`AluOpBus] id_aluop, input wire[`AluSelBus] id_alusel, input wire[`RegBus] id_reg1, input wire[`RegBus] id_reg2, input wire[`RegAddrBus] id_waddr, input wire id_we, input wire[5:0] stall, input wire flush, input...
#include <bits/stdc++.h> using namespace std; int main() { int z[6] = {1, 0, 0, 1, 2, 2}; int r[6] = {2, 2, 1, 0, 0, 1}; int l[6] = {0, 1, 2, 2, 1, 0}; long long int m, n, num; while (cin >> m >> n) { num = m % 6; if (z[num] == n) { cout << 1 << endl; } else if (r[num] ...
// Copyright 2020-2022 F4PGA Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int N = 1e7 + 100; unordered_map<int, int> vis, Cnt; vector<int> Mice; vector<int> Cheese; int main() { int n, m, y0, y1; scanf( %d%d%d%d , &n, &m, &y0, &y1); for (int i = 0; i < n; i++) { int x; scanf( %d , &...
#include <bits/stdc++.h> using namespace std; const int MAXN = 220000; const int MAXM = 2 * MAXN; const int MAXS = 26; struct SAM { struct Node { int nxt[MAXS], par; int len, siz; } st[MAXM]; int m, root, lst; inline int newNode(int l) { int x = ++m; memset(st[x].nxt, 0...
#include <bits/stdc++.h> const int inf = 0x3f3f3f3f; const long long int INF = 0x3f3f3f3f3f3f3f3f; using namespace std; inline void INP() {} long long int n, m; vector<pair<long long int, long long int> > v; void solve() { cin >> n >> m; long long int mn = INF; long long int mx = 0; for (l...
// File: memory_arrayTBV.v // Generated by MyHDL 0.10 // Date: Mon Aug 27 20:10:29 2018 `timescale 1ns/10ps module memory_arrayTBV ( ); // myHDL -> verilog testbench for `memory_array` module reg [4:0] wptr = 0; reg fifo_we = 0; reg clk = 0; reg [4:0] rptr = 0; reg [7:0] data_in = 0; wire [7:0] data_out; reg clea...
`timescale 1ns / 1ps module LED7SEG(DIGIT, DISPLAY,BCD0, BCD1, KB0, KB1, clk); input clk; input [3:0] BCD1; input [3:0] BCD0; input [3:0] KB1; input [3:0] KB0; output reg [3:0] DIGIT; output [7:0] DISPLAY; reg [3:0] value; always @ ( posedge clk) begin case(DIGIT) 4'b0111: begin value <= BCD1; ...
/* * 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() { int a[72] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 3...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long sum = 0, sum_mas; cin >> n; vector<int> mas; for (int i = 0, temp = 0; i < n; i++) { cin >> temp; sum += temp; mas.push_back(temp); } sum_mas = sum; sort(mas.begin(), mas.end()); for (in...
//begin #include <Core> /* * Package: StandardCodeLibrary.Core * */ #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <utility> #include <vector> #include <list> #include <string> #include <stack> #include <queue> #include <deque> #include <set> #inc...
#include <bits/stdc++.h> using namespace std; int main() { int T; scanf( %d n , &T); for (int t = 0; t < T; t++) { string s; getline(cin, s); bool p = false; int prevZero = -1; for (int i = 0; i < s.size(); i++) { char c = s[i]; if (c == 0 ) { if ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:268435456 ) using namespace std; long long _gcd(long long a, long long b) { if (b == 0) return a; _gcd(b, a % b); } int main() { int n, m, k, a[20500][10], res[20500] = {0}, b[20500][10] = {0}; cin >> n >> m >> k; for (int i = 0; i <...
// (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...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long r = n % 3; if (r != 2) cout << 1ll << << 1ll << << n - 2 << endl; else cout << 1ll << << 2ll << << n - 3 << endl; }
`define CYCLE_TIME 50 module TestBench; reg Clk; reg Reset; reg Start; integer i, outfile, outfile2, counter; reg flag; reg [26:0] address; reg [23:0] tag; reg [4:0] index; wire [256-1:0] mem_cpu_data; wire mem_cpu_ack; wire [256-1:0] cpu_mem_data; wire [32-1:0] cpu_mem_addr; wire ...
/* * 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() { int x, cnt = 0; cin >> x; int arr1[x], arr2[x]; for (int i = 0; i < x; i++) { cin >> arr1[i] >> arr2[i]; } for (int i = 0; i < x; i++) { for (int j = 0; j < x; j++) { if (i == j) { continue; } ...
// ported from http://www.dejazzer.com/eece4740/lectures/uart_test_impl1.zip // modified to echo back what user type in and instead of an increment of that character module uart_echo ( input wire clk_i, input wire btn_reset, input wire btn_send_back, input wire rx, output wire tx,...
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 // Date : Tue Sep 17 19:45:27 2019 // Host : varun-laptop running 64-bit Service Pac...
/* * 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> const int Maxn = 500010; using namespace std; multiset<long long> S; int n, m; long long t[Maxn]; void add(int pos, int x) { for (; pos <= m; pos += pos & -pos) { t[pos] += x; } } long long query(int pos) { long long ans = 0; for (; pos; pos ^= pos & -pos) ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : 11....
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int k, b, n; cin >> k >> b >> n; map<int, int> freq; freq[0]++; int cont_zeros = 0; int cur_mod = 0; long long total_zeros = 0; long long total_mod = 0; for (int i = 0; i ...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of inst_ab_e // // Generated // by: wig // on: Mon Jun 26 08:25:04 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../../generic.xls // // !!! Do not edit this file! Autogenerated by MIX !!! // $Aut...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int H, M, N; set<int> a[200005]; int p[200005], seq[200005], r = 0; int u[200005]; map<int, pair<int, int> > history; void release(pair<int, int> P) { a[P.first].insert(P.second); } int main(void) { scanf( %d%d%d , &H, &M, &N); for (int i = 0; i < H;...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x = 1; map<int, int> m; int y = 1; m[x] = 1; while (y < 1001) { m[y] = 1; int temp = y + x; x = y; y = temp; } m[y] = 1; for (int i = 1; i <= n; i++) { if (m[i] == 1)...
#include <bits/stdc++.h> using namespace std; struct cs { int to, next; } a[200001]; int aa[400001], head[100001], sum[100001]; bool vi[100001], c[100001]; int n, m, z, y, x, ans, ll, S; void init(int x, int y) { a[++ll].to = y; a[ll].next = head[x]; head[x] = ll; } void dfs(int x, int...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2020 by Yutetsu TAKATSUKASA. // SPDX-License-Identifier: CC0-1.0 logic [7:0] should_show_warning_global0 /* verilator split_var */; logic [7:0] should_show_warning_global1 [1:0] /* ve...
`timescale 1ns / 1ps module text_editor_keyboard_controller( input sys_Clk, input PS2_Clk, input Reset, inout PS2KeyboardData, inout PS2KeyboardClk, output reg [7:0] KeyData, output reg KeyReleased ); /*******************************************************************...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int pre = INT_MIN; int cur; int state = 0; for (int i = 0; i < n; i++) { cin >> cur; if (cur > pre) { if (state == 0) { pre = cur; continue; } else { cout << ...
#include <bits/stdc++.h> using namespace std; int rain(int n, int *T, int i) { int r = 1; int d = i + 1, g = i - 1, ex = i; while ((g >= 0) && (T[g] <= T[i])) { r++; i = g; g--; } i = ex; while ((d < n) && (T[d] <= T[i])) { r++; i = d; d++; } retur...
#include <bits/stdc++.h> using namespace std; template <class Q> Q _min(Q x, Q y) { return x < y ? x : y; } template <class Q> Q _max(Q x, Q y) { return x > y ? x : y; } set<long long int> S; long long int a[1005][1005], b[1005][1005]; long long int lights[1005000]; long long int ans = 0, ...
/////////////////////////////////////////////////////////////////////////////// // vim:set shiftwidth=3 softtabstop=3 expandtab: // // Module: add_hdr.v // Project: NF2.1 // Description: Adds a length header to packets // // The format of this extra word is: // // Bits Purpose // 15:0 Packet length in b...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; string s; while (t--) { cin >> s; vector<int> E, O; int io = 0, ie = 0, prev = -1; for (int i = 0; i < s.size(); ++i) { if ((s[i] - 48) % 2 == 0) { if (io < O.size() && ie < E.size()...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; inline int Read() { int x = 0, f = 1; char c = getchar(); while (c > 9 || c < 0 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = x * 10 + c - 0 ; c = getchar(); ...