text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> template <unsigned P> class modint { static_assert(1 <= P); using mint = modint<P>; protected: unsigned v; public: modint() : v() {} template <typename T, typename std::enable_if<std::is_signed<T>::value && ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }... |
/**
* 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 = 2e5 + 10; const int MOD = 998244353; struct node { long long a, b; node() {} node(long long a, long long b) { this->a = a; this->b = b; } node operator+(const node& rhs) const { return node((a + rhs.a) % MOD, (b... |
#include <bits/stdc++.h> using namespace std; int Array[10005]; int main() { int N, m, i, j, l, r, x, Count; scanf( %d%d , &N, &m); for (i = 1; i <= N; i++) scanf( %d , Array + i); for (i = 1; i <= m; i++) { Count = 0; scanf( %d%d%d , &l, &r, &x); for (j = l; j <= r; j++) { ... |
#include <bits/stdc++.h> using namespace std; const double PI = 4 * atan(1); template <int p> struct FF { long long val; FF(long long x = 0) { val = (x % p + p) % p; } bool operator==(const FF<p> other) { return val == other.val; } bool operator!=(const FF<p> other) { return val != other.val; } ... |
/**
* 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(NULL); ; long long int t; cin >> t; while (t--) { long long int n; cin >> n; float a = 1; float b = (float)360 / ((2 * n)); b /= 2; b = (3.1415926535897932... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> prices[1010]; int allp[1010]; int all; int margin_price; int above_cnt[1010], margin_cnt[1010], cnt[1010]; double f[1010][1010], g[1010][1010]; double comb[1010][1010]; int main() { comb[1][0] = comb[1][1] = 1; for (int i = ... |
// -----------------------------------------------------------------------
//
// Copyright 2004 Tommy Thorn - All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation,... |
// This module is a simple clock crosser for control signals. It will take
// the asynchronous control signal and synchronize it to the clk domain
// attached to the clk input. It does so by passing the control signal
// through a pair of registers and then sensing the level transition from
// either hi-to-lo or lo-to-... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int MAXX = 2e6 + 10; long long f(long long n) { long long ret = n; for (long long i = 2; i * i <= n; i++) { if (n % i == 0) { while (n % i == 0) n /= i; ret -= ret / i; } } if (n > 1) r... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &t) { t = 0; char ch = getchar(); int f = 1; while ( 0 > ch || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } do { (t *= 10) += ch - 0 ; ch = getchar(); } while ( 0 <= ch &&... |
`timescale 1ns / 100ps
module QMFIR_uart_top(/*AUTOARG*/
// Outputs
uart_tx,
// Inputs
uart_rx, clk, arst_n
);
output uart_tx;
input uart_rx;
input clk;
input arst_n;
wire arst_n;
wire [15:0] MEMDAT;
wire core_clk;
wire uart_rst... |
module top;
reg pass;
reg [7:0] a, b;
wire [15:0] ruu, rsu, rus, rss;
reg signed [15:0] res;
integer i;
assign ruu = a / b;
assign rsu = $signed(a) / b;
assign rus = a / $signed(b);
assign rss = $signed(a) / $signed(b);
initial begin
pass = 1'b1;
// Run 1000 random vectors
for (i = 0... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long int n = ((int)s[1] - 0 ) + 10 * ((int)s[3] - 0 ) + 100 * ((int)s[4] - 0 ) + 1000 * ((int)s[2] - 0 ) + 10000 * ((int)s[0] - 0 ); long long int result = (n * n) % 1... |
`timescale 1ns / 1ps
// Documented Verilog UART
// Copyright (C) 2010 Timothy Goddard ()
// 2013 Aaron Dahlen
// Distributed under the MIT licence.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to... |
#include <bits/stdc++.h> using namespace std; long long read() { long long cc = getc(stdin); for (; cc < 0 || cc > 9 ;) cc = getc(stdin); long long ret = 0; for (; cc >= 0 && cc <= 9 ;) { ret = ret * 10 + cc - 0 ; cc = getc(stdin); } return ret; } long long power(long ... |
/* Generated by Yosys 0.8 (git sha1 UNKNOWN, clang 10.0.0 -fPIC -Os) */
(* top = 1 *)
(* src = "/Users/tramyn/Documents/workspaces/cello_workspace/yosysRun/gc.v:4" *)
module Start_Sensor_Actuator_G1__prevStart_G1__prevSensor_net(Start, Sensor, Actuator, G1__prevStart, G1__prevSensor);
wire _00_;
wire _01_;
wir... |
#include <bits/stdc++.h> const long long maxn = 1e3 + 5; const long long w = 1e8; using namespace std; int m, n, p, kq; char a[maxn][maxn]; string s; char dir[4] = { D , L , U , R }; int tdx, tdy; int x, y; inline void init() { cin >> n >> m; cin.ignore(); for (int i = 1; i <= n; i++)... |
// 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 [63:0] crc;
reg [63:0] sum;
// Take CRC data and apply to test... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll inf = 1e18; int n, m; int edges[22][2]; bool used[6][6]; int arr[7]; void init() {} void input() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> edges[i][0] >> edges[i][1]; edges[i][0]--; edges... |
module Controller(input clk,rst,output reg RdOrR2,AluOrMem,RFWE,MWE,output reg[1:0] stackContrl,pcContrl,input Zero,Cout,input[5:0] cntlInstruc);
/*always@(posedge clk,posedge rst)
if(rst)
begin
RdOrR2=1'b0;
AluOrMem=1'b0;
RFWE=1'b0;
MWE=1'b0;
stackContrl=2'b00;
pcContrl=2'b00;
end
el... |
// SNES-Hook - A tiny 5V CPLD device to hijack reset on the SNES console
//
// Copyright (C) 2015 Evan Custodio
//
// 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 Lice... |
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2015.3 (win64) Build Mon Sep 28 20:06:43 MDT 2015
// Date : Wed Mar 30 14:52:13 2016
// Host : DESKTOP-5FTSDRT running 64-bit major releas... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n % 2 << endl; } |
// ==============================================================
// 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 1ns/1ps
modul... |
/*
# jtag_uart.v - This module provides an 8-bit parallel FIFO interface to
# the Altera Virtual JTAG module.
#
# Description: Follows the design pattern recommended in Altera's Virtual
# JTAG Megafunction user guide. Links the VJTAG to two 64-byte FIFO's
#
# Copyright (C) 2014 Binary Logic (nhi.phan.lo... |
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017
// Date : Tue Apr 18 23:15:16 2017
// Host : DESKTOP-I9J3TQJ running 64-bit major re... |
/**
* Module: arbiter
*
* Description:
* A look ahead, round-robing parameterized arbiter.
*
* <> request
* each bit is controlled by an actor and each actor can 'request' ownership
* of the shared resource by bring high its request bit.
*
* <> grant
* when an actor has been given ownership of shared res... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; inline int read() { int X = 0, w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == - ; ch = getchar(); } while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar(); return w ? -X : X; } int n... |
`define bsg_and_macro(bits) \
if (harden_p && (width_p==bits)) \
begin: macro \
bsg_rp_tsmc_40_AND2X1_b``bits and_gate (.i0(a_i),.i1(b_i),.o); \
end
module bsg_and #(parameter `BSG_INV_PARAM(width_p)
, parameter harden_p=0... |
module control_exe(
clk,
rst,
branch_target, // PC+1+offset
pc_added, //PC+1
flag, // flagprev_idex
cond, // condition for branch
branch_idex, // input from control.v for branch
jal_idex, // input from control.v for jump and link
jr_idex, //input from control.v for jump return
exec_idex, //input fro... |
/**
* 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 , unroll-loops , omit-frame-pointer , inline ) #pragma GCC option( arch=native , tune=native , no-zeroupper ) #pragma GCC target( avx , popcnt ) using namespace std; const long long int INF = (long long int)1e17 + 5; const unsigned long long int MOD = ... |
`default_nettype none
`timescale 1ns / 1ps
module receiver_tb();
reg [15:0] story;
reg clk_i = 0, reset_i = 0;
reg rxd_i = 1, rxc_i = 0;
reg rxreg_oe_i = 0, rxregr_oe_i = 0;
wire idle_o;
wire [63:0] dat_o;
wire sample_to;
receiver #(
.SHIFT_REG_WIDTH(64),
.BAUD_RATE_WIDTH(32)
) x(
.clk_i(clk_i),... |
/* -------------------------------------------------------------------------------
* (C)2007 Robert Mullins
* Computer Architecture Group, Computer Laboratory
* University of Cambridge, UK.
* -------------------------------------------------------------------------------
*
* Tree Matrix Arbiter
*
* - 'multist... |
#include <bits/stdc++.h> const int MaxN = 300000; using namespace std; long long arr[MaxN + 5], a[MaxN + 5], n; struct Segment { int l, r, lx, mx, rx; int Sign(long long x) { return x > 0 ? 1 : -1; } void Update(Segment A, Segment B) { lx = A.lx, rx = B.rx; mx = max(A.mx, B.mx); if... |
#include <bits/stdc++.h> using namespace std; int main() { int n, p = 0, ans = 0; string s, dvg, answ, r_dvg; cin >> n >> s; for (int i = 0; i < n - 1; i++) { dvg = s.substr(i, 2); for (int j = i; j < n - 1; j++) { r_dvg = s.substr(j, 2); if (dvg == r_dvg) { p++... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 21:38:20 11/23/2014
// Design Name:
// Module Name: Anti_jitter
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dep... |
// (c) Copyright 1995-2019 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; int main() { int ans = 0, a, b, a2, b2; cin >> a >> b; while (((a != 0) and (b != 0))) { if ((a + b) <= 2) { cout << ans << endl; return 0; } if (2 * a <= b) { cout << ans + a << endl; return 0; } ... |
#include <bits/stdc++.h> using namespace std; long long int n, k; long long int a[200100]; bool check(long long int x) { long long int moves = 0; for (__typeof(n + 1) i = (n / 2 + 1) - ((n / 2 + 1) > (n + 1)); i != (n + 1) - ((n / 2 + 1) > (n + 1)); i += 1 - 2 * ((n / 2 + 1) > (n + 1))... |
module halfadder(in1, in2, sum, cout);
input wire in1, in2;
output wire sum, cout;
assign sum = in1 ^ in2;
assign cout = in1 & in2;
endmodule
module fulladder(in1, in2, cin, sum, cout);
input wire in1, in2, cin;
output wire sum, cout;
assign sum = in1 ^ in2 ^ cin;
assign cout = (in1 & in2) | (in2 & cin) | (cin... |
#include <bits/stdc++.h> using namespace std; constexpr long long R = 1e3 + 69, INF = 2e9 + 6969, mod = 998244353; long long n, a[R], dp[R], fact[R], rev[R]; long long choose(long long N, long long K) { long long cur = (fact[N] * rev[K]) % mod; cur = (cur * rev[N - K]) % mod; return cur; } long ... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, unsigned long long int y) { long long int res = 1; while (y > 0) { if (y & 1) { res = res * x; } y = y >> 1; x = x * x; } return res; } long long int powermod(long long int x, unsig... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int bags[4]; int flag = 0; for (int i = 0; i < 4; i++) { cin >> bags[i]; } if (bags[0] + bags[1] == bags[2] + bags[3]) { cout << YES n ; } else if (bags[0] + bags[2] == bags[1] + bags[3]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long int n, c = 0; int x; cin >> n; unsigned long long int pos[11] = {}, neg[11] = {}, z = 0, i; for (i = 0; i < n; i++) { cin >> x; if (x == 0) z++; else if (x < 0) neg[(-1) * x]++; ... |
#include <bits/stdc++.h> int main() { int t, n; scanf( %d , &t); while (t--) { scanf( %d , &n); for (int i = 1; i <= n; ++i) printf( %d%c , n - i + 1, n [i == n]); } } |
//-----------------------------------------------------------------------------
//-- Divisor de frecuencia entre M
//-- (c) BQ. August 2015. written by Juan Gonzalez (obijuan)
//-----------------------------------------------------------------------------
//-- GPL license
//---------------------------------------------... |
//==================================================================================================
// Filename : submidRecursiveKOA2.v
// Created On : 2016-10-28 08:46:44
// Last Modified : 2016-10-31 11:42:31
// Revision :
// Author : Jorge Esteban Sequeira Rojas
// Company : Institu... |
#include <bits/stdc++.h> using namespace std; string str; int memo[100005][3]; int dp(int Idx, int prev) { if (Idx == (int)str.size()) return 0; int choice1 = 1000000; if (memo[Idx][prev] != -1) return memo[Idx][prev]; if (prev == 0) { if (isupper(str[Idx])) choice1 = dp(Idx + 1, 0... |
#include <bits/stdc++.h> using namespace std; int n, a[100001], c[100001]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int s = 0; for (int i = n - 1; i >= 0; i--) if (s > 0) s -= a[i]; else { c[i] = 1; s += a[i]; } if (s < 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 la... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23:11:42 05/27/2016
// Design Name:
// Module Name: TOP
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Rev... |
// (c) Copyright 1995-2016 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 ... |
`default_nettype none
`timescale 1ns/1ns
`define simulation
module tb_ptp();
wire clk, reset;
clock clock(clk, reset);
reg read = 0;
wire [31:0] readdata;
reg [31:0] data;
reg iobus_iob_poweron = 1;
reg iobus_iob_reset = 0;
reg iobus_datao_clear = 0;
reg iobus_datao_set = 0;
reg iobus_cono_clear = 0;
reg... |
/**
* This is written by Zhiyang Ong
* and Andrew Mattheisen
* for EE577b Troy WideWord Processor Project
*/
`timescale 1ns/10ps
/**
* `timescale time_unit base / precision base
*
* -Specifies the time units and precision for delays:
* -time_unit is the amount of time a delay of 1 represents.
* The time unit... |
#include <bits/stdc++.h> using namespace std; const int N = 200002, SQ = 450; int n, c, a[N], first[N]; long long sum[SQ]; bool solve() { int x = c; for (int i = x; i >= 1; --i) { i = min(i, x); if (!sum[i / SQ]) { i = i / SQ * SQ; continue; } if (sum[i / SQ] <=... |
`include "assert.vh"
`include "cpu.vh"
module cpu_tb();
reg clk = 0;
//
// ROM
//
localparam MEM_ADDR = 6;
localparam MEM_EXTRA = 4;
reg [ MEM_ADDR :0] mem_addr;
reg [ MEM_EXTRA-1:0] mem_extra;
reg [ MEM_ADDR :0] rom_lower_bound = 0;
reg [ MEM_ADDR :0] rom_upper_bo... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, fa, h[N]; vector<int> G[N], p, q; int main() { scanf( %d , &n); for (int i = (1); i <= (n - 1); ++i) scanf( %d , &fa), G[fa].push_back(i); function<void(int)> dfs = [&](int u) { for (int v : G[u]) dfs(v), h[u] = max... |
#include <bits/stdc++.h> int dp[200100]; int X[200100]; int Y[200100]; int T[200100]; int MX[200100]; int main(void) { int n, r; scanf( %d %d , &r, &n); for (int i = 1; i <= n; i++) dp[i] = MX[i] = -200100; MX[0] = X[0] = Y[0] = dp[0] = T[0] = 0; for (int i = 1; i <= n; i++) { scan... |
/**
* 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... |
#include <bits/stdc++.h> using namespace std; long long arr[1000]; long long seg[1000005]; long long gcd(long long a, long long b) { if (b == 0) { return a; } return gcd(b, a % b); } void buildtree(long long start, long long end, long long treenode) { if (start == end) { seg[tree... |
/**
* 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; template <class T> struct rge { T b, e; }; template <class T> rge<T> range(T i, T j) { return rge<T>{i, j}; } template <class T> auto dud(T *x) -> decltype(cerr << *x, 0); template <class T> char dud(...); struct debug { template <class T... |
/**
* 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 x[100002]; vector<int> P[2 * 100002]; void NoSol() { printf( No n ); exit(0); } long long sqr(int x) { return 1LL * x * x; } int bs(int x, long long val) { int i = -1, sz = P[x].size(), p = 1; while (p < sz) p <<= 1; while (p) { ... |
`include "tinker.vh"
module top
(
///////// OSC ////////
input OSC_50_B3B,
input OSC_50_B3D,
input OSC_50_B4A,
input OSC_50_B4D,
input OSC_50_B7A,
input OSC_50_B7D,
input OSC_50_B8A,
input OSC_50_... |
//bram.v
/*
Distributed under the MIT license.
Copyright (c) 2011 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,... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, i, j, k; cin >> n >> m; int a[101] = {0}; for (i = 0; i < m; i++) { cin >> j; a[j]++; } vector<int> v; for (i = 1; i <= 100; i++) { if (a[i] != ... |
// File: top_TBV.v
// Generated by MyHDL 0.10
// Date: Mon Aug 20 12:46:54 2018
`timescale 1ns/10ps
module top_TBV (
);
// myHDL -> Verilog Testbench for `top`
reg clk = 0;
wire [3:0] led;
wire [7:0] top0_0_pwm0_0_1_2_dutyCount;
reg [7:0] top0_0_pwm0_0_1_2_counter = 0;
wire [7:0] top0_0_pwm1_0_1_dutyCount;
reg [7... |
#include <bits/stdc++.h> using namespace std; int n; long double l, v1, v2; long double a[100000]; long double p[100001]; vector<pair<long double, int> > events; int main() { cout << fixed << setprecision(12); cin >> n >> l >> v1 >> v2; long double dist = l * v2 / (v1 + v2); events.push_ba... |
/**
* 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; void solve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<pair<int, int> > dp(n); dp[n - 1].second = 0; dp[n - 1].first = 1; int mx = 0; for (int i = n - 2; i > -1; i--) { if (a[i + 1] > a... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int x, y, i; if (b * c > a * d) { x = b * c - a * d; y = b * c; } else { x = a * d - b * c; y = a * d; } while (1) { int k = 0; for (i = 2; i <= x; i++)... |
/*
* CRC-16 Encoder/Decoder
*
* Calculation of 16-bit cyclic redundancy checks
*
* For more detailed information about CRC-16 for EPC Gen2, refer to annex F of the protocol
*/
`timescale 1us / 1ns
module crc16
(
output reg crc16_check_pass_reg,
output [15:0]crc_16,
input clk_crc16,
input rst_c... |
module ula_test (
input reset,
input clk_sys, // master clock
output ce_vid,
// VRAM interfacing
output [14:0] vram_addr,
input [7:0] vram_dout,
output [7:0] port_ff,
// ULA+
input ulap_avail,
// Timex mode
input tmx_avail,
// Misc. signals
input mZX,
... |
`include "assert.vh"
`include "cpu.vh"
module cpu_tb();
reg clk = 0;
//
// ROM
//
localparam MEM_ADDR = 6;
localparam MEM_EXTRA = 4;
reg [ MEM_ADDR :0] mem_addr;
reg [ MEM_EXTRA-1:0] mem_extra;
reg [ MEM_ADDR :0] rom_lower_bound = 0;
reg [ MEM_ADDR :0] rom_upper_bo... |
#include <bits/stdc++.h> using namespace std; const int maxn = 211; vector<pair<int, int> > con[maxn]; vector<pair<int, int> > edge; bool vis[maxn]; int n, w, tmx, tv, ans; void dfs(int x, int dis) { vis[x] = 1; if (dis > tmx) tmx = dis, tv = x; for (int i = 0; i < con[x].size(); i++) if... |
#include <bits/stdc++.h> using namespace std; using LL = long long; using DD = long double; using pii = pair<int, int>; const LL INFLL = 0x7f7f7f7f7f7f7f7fLL; const int INFint = 0x7f7f7f7f; LL exactMatchingSubranges(vector<int> &cumulative, int match) { LL rr = 0; for (int i = 0; i < int((int((cum... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, pos, l, r, ans = 0; cin >> n >> pos >> l >> r; if (abs(pos - l) > abs(pos - r)) { ans += abs(pos - r) + 1; if (n == r) ans -= abs(pos - r) + 1; ... |
// 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 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 n, k, p[111], c[111], l[111], bottleneck[111], par[111], cost[111][111]; bitset<200005> prime; vector<vector<int> > vert; int edmondskarp(int s, int t) { int mf = 0; while (1) { memset(bottleneck, 0, sizeof(bottleneck)); bottleneck[s] = 1e9... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MOD2 = 1007681537; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int x[maxn], y[maxn]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x[i]; } for (int i = 1; i <= m; i++) { cin >> y[i]; } int u = 0, d = 0, ans = 0; int sumu = 0, sum... |
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017
// Date : Fri Oct 27 10:20:39 2017
// Host : Juice-Laptop running 64-bit major relea... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long L, v, l, r; cin >> L >> v >> l >> r; long long tot = L / v; long long minus = r / v; minus -= (l - 1) / v; cout << tot - minus << n ; } return 0; } |
#include <bits/stdc++.h> int x[100010]; int main() { int a, b, c, i; scanf( %d%d%d , &a, &b, &c); for (i = 1; i <= a; i++) scanf( %d , &x[i]); int s = 0, t = 1; long long int count = 0; while (1) { if (t > a && s == 0) { printf( %I64d , count); return 0; } w... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ans; long long sum = 0; map<long long, int> d; cin >> n; ans = n - 1; for (int i = 0; i < n; i++) { int t; cin >> t; sum += t; d[sum]++; ans = min(ans, n - d[sum]); } cout << ans << n ; ... |
#include <bits/stdc++.h> using namespace std; void solve(int test) { int x; cin >> x; int no = x % 10; int cnt = 0; while (x) { cnt++; x /= 10; } int ans = (no - 1) * 10; while (cnt) { ans += cnt; cnt--; } cout << ans << n ; } int main() { io... |
/**
* 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 N = 201110, M = 501110; int n, m, numeven, numodd; int a[N]; stack<int> odd, even; map<int, int> mp; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); mp[a[i]]++; if (a[i] % 2 == 0) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { long long int n; scanf( %lld , &n); printf( %lld n , n); } return 0; } |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company: California State University San Bernardino
// Engineer: Bogdan Kravtsov
// Tyler Clayton
//
// Create Date: 15:17:23 10/24/2016
// Module Name: ALU_MUX_tb
// Project Name: MIP... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { long long n, s, t; cin >> n >> s >> t; cout << max(n - s + 1, n - t + 1) << n ; } return 0; } |
/*******************************************************************************
Vendor: Xilinx
Associated Filename: realfft_rtl_tb.v
Purpose: Part of a Vivado HLS tutorial example
Device: All
Revision History: March 31, 2013 - initial release
***************************************************************************... |
#include <bits/stdc++.h> using namespace std; int on[10001]; int main() { std::ios::sync_with_stdio(false); cin.tie(0); int n, t, r, ans = 0; cin >> n >> t >> r; for (int i = 0; i < n; ++i) { int w; cin >> w; w += 400; int cnt = 0; for (int j = w; j > w - t; --j) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.