text
stringlengths
59
71.4k
//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...
/** * 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) 2014 Francis Bruno, All Rights Reserved // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software...
#include <bits/stdc++.h> int main() { int n, s; scanf( %d%d , &n, &s); s *= 100; int max = 0; bool tr = false; for (int i = 1; i <= n; i++) { int d, c; scanf( %d%d , &d, &c); int money = d * 100 + c; if (money <= s) { tr = true; int sweet = (s - money) %...
#include <bits/stdc++.h> using namespace std; ifstream f( text.in ); int t, coada[26 * 2 + 5], p, u, n, ind, frecventa[26 + 5], imposibil; string sir; int main() { cin >> t; while (t--) { cin >> sir; n = sir.size(); p = u = 26; coada[p] = sir[0] - a + 1; frecventa[sir[0...
/* _______________________________________________________________________________ Copyright (c) 2012 TU Dresden, Chair for Embedded Systems (http://www.mr.inf.tu-dresden.de) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the follo...
#include <bits/stdc++.h> using namespace std; vector<long long int> ar[100005]; long long int vis[100005]; long long int mi; long long int val[100005]; void dfs(long long int a) { vis[a] = 1; mi = min(val[a], mi); for (auto it : ar[a]) { if (vis[it] == 0) { dfs(it); } } ...
#include <bits/stdc++.h> using namespace std; long long a, b, c, d; long long f(long long k) { return (d * b * k - 2 * a) * (k + 1) / -2; } int main() { int t; cin >> t; while (t--) { cin >> a >> b >> c >> d; if (a > b * c) { cout << -1 n ; continue; } double...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int si, lef, t0; int a1, t1, p1; int a2, t2, p2; int main() { cin >> si >> lef >> t0; cin >> a1 >> t1 >> p1; cin >> a2 >> t2 >> p2; if (t1 > t2) { swap(a1, a2); swap(t1, t2); swap(p1, p2); } l...
#include <bits/stdc++.h> using namespace std; const long long linf = 1e18 + 9; const int inf = 1e9 + 9; const int N = 2e5 + 9; int n, q, l[N], r[N], a[N], wh[N]; long long bit[N], ans[N]; vector<int> h[N]; vector<pair<int, int> > Q[N]; void update(int t) { t++; while (t <= n + 1) { bit[t...
#include <bits/stdc++.h> using namespace std; template <class T1> void debug(T1 e) { cout << e << endl; } template <class T1, class T2> void debug(T1 e1, T2 e2) { cout << e1 << t << e2 << endl; } template <class T1, class T2, class T3> void debug(T1 e1, T2 e2, T3 e3) { cout << e1 << 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...
/** * 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/10ps module cpc_clks_0002( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'outclk1' output wire outclk_1, // interface 'outclk2' output wire outclk_2, // interface 'outclk3' output wire outclk_3, ...
/* -------------------------------------------------------------------------- Synesthesia-Moksha - Copyright (C) 2012 Gregory Matthew James. This file is part of Synesthesia-Moksha. Synesthesia-Moksha is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as p...
////////////////////////////////////////////////////////////////////// //// //// //// File name "encoder_8b10b.v" //// //// //// //// This file is part of the : ...
`include "vscale_ctrl_constants.vh" `include "rv32_opcodes.vh" module vscale_PC_mux( input [`PC_SRC_SEL_WIDTH-1:0] PC_src_sel, input [`INST_WIDTH-1:0] inst_DX, input [`XPR_LEN-1:0] rs1_data, input [`XPR_LEN-1: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...
/* * 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> #pragma GCC optimise( Ofast , unroll-loops) using namespace std; void solve() { int n, m, k; cin >> n >> m >> k; long long a[n][m], b[n * m + 3], c[n][m]; memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; int n, x; void solve() { cin >> n >> x; int left = x - 1; int right = n - x; if (left >= right) cout << (x - 1 == 0 ? 1 : x - 1) << endl; else cout << (x + 1 > n ? n : x + 1) << endl; } int main() { ios_base ::sync_with_stdio(fa...
#include <bits/stdc++.h> int main(void) { int n, k, p = 0, t, i, j, c = 0; scanf( %d%d , &n, &k); int x[n], y[n], z[k * 2]; for (i = 0; i < n; i++) { scanf( %d , &x[i]); y[i] = i + 1; } for (i = 0; i < n; i++) { for (j = 0; j < n - 1; j++) { if (x[j] < x[j + 1]) { ...
#include <bits/stdc++.h> using namespace std; long long int visited[100001]; vector<long long int> adj[100001]; long long int sum = 0; void dfs(long long int s) { if (visited[s] == 1) { return; } sum++; visited[s] = 1; for (auto u : adj[s]) { dfs(u); } } long long int b...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long inf = (1LL << 60); const double pi = acos(-1); long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; ...
#include <bits/stdc++.h> using namespace std; inline int read() { register int res = 0, c; while (c = getchar(), c < 0 || c > 9 ) ; do { res = (res << 3) + (res << 1) + (c ^ 48); } while (c = getchar(), c >= 0 && c <= 9 ); return res; } const int inf = 0x3f3f3f3f; const i...
/*================================================ Thomas Gorham ECE 441 Spring 2017 Project 2 - lfsr Description: This module implements a LFSR for the generation of pseudorandom numbers. It will use an 8 bit register with the polynomial x^8+x^6+x^5+x^4+1 ================================================*/ `timescale 1...
// megafunction wizard: %RAM: 2-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: RAMB16_S4_2_altera.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =====...
module main; wire [2:0] value1, value2, value3, value4; dut #( .select(1) ) dut1(value1); dut #( .select(2) ) dut2(value2); dut #( .select(3) ) dut3(value3); dut #( .select(4) ) dut4(value4); initial begin #1 $display("value1=%d, value2=%d, value3=%d, value4=%d", value1, value2, value3, v...
#include <bits/stdc++.h> using namespace std; const int MAXN = 32, MAXS = 1 << 17; const int MOD = 1e9 + 7, H = 3137; int add(int a, int b) { a += b; if (a >= MOD) a -= MOD; return a; } int sub(int a, int b) { a -= b; if (a < 0) a += MOD; return a; } int mul(int a, int b) { retur...
// (C) 2001-2014 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 A[100005]; int F[100005]; int main() { int n, x; cin >> n >> x; for (int i = 1; i <= n; i++) { scanf( %d , &A[i]); F[A[i]]++; } int idx = (n + 1) / 2; bool wasPresent = true; if (!F[x]) { wasPresent = false; A[...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\velocityControlHdl\velocityControlHdl_MinMax1.v // Created: 2014-08-25 21:11:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // -----------------------------------------------------------...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: test_stub_scan.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 an...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen */ `timescale 1ns/100ps /** * `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 must be 1 10 or 100 * -base is the time ba...
// hub_mem /* ------------------------------------------------------------------------------- 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 Ge...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 200050; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int isprime(int x) { for (int i = 2; i <= sqrt(x); i++) { if (x % i == 0) return 0; } return 1; } int judge(char ch...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long INF = 4e18 + 10; long long n; long long a[55]; vector<vector<long long> > ans; long long findpos(long long x) { for (long long i = 0; i < n; i++) if (a[i] == x) return i; } void p1(long long x) { ...
// amm_master_qsys_with_pcie_mm_interconnect_0_avalon_st_adapter.v // This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module amm_master_qsys_with_pcie_mm_interconnect_0_ava...
#include <bits/stdc++.h> using namespace std; char question[4][100]; int len[4]; int main() { for (int i = 0; i < 4; i++) { cin >> question[i]; string s = question[i]; len[i] = s.size() - 2; } int count_ = 0; int index = -1; for (int i = 0; i < 4; i++) { int n; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, m, k, arr[1005], ro[1005], co[1005]; char s[2000000]; int main() { int a, b; cin >> s + 1; a = count(s + 1, s + strlen(s + 1) + 1, x ); b = count(s + 1, s + strlen(s + 1) + 1, y ); for (int i = 1; i <= a - b; i++) cout << x ; for (i...
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 4000; const int INF = 1e9; struct edge { int to, c, f, back; edge(int to, int c, int f, int back) : to(to), c(c), f(f), back(back) {} }; vector<edge> g[N]; vector<int>...
#include <bits/stdc++.h> using namespace std; int dp[200010][33]; void generate() { for (long long i = 1; i <= (200000); i++) { for (long long j = 0; j < (32); j++) { dp[i][j] = dp[i - 1][j] + !((1 << j) & i); } } } int main() { ios::sync_with_stdio(false); cin.tie(0); ...
// Quartus Prime Verilog Template // Single port RAM with single read/write address and initial contents // specified with an initial block module phyIniCommand1 #(parameter DATA_WIDTH=32, parameter ADDR_WIDTH=4) ( input [(DATA_WIDTH-1):0] data, input [(ADDR_WIDTH-1):0] addr, input we, clk, outp...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; } long long int f[n + 1]; f[0] = 0; for (int i = 1; i < n; i++) { f[i] = f[i - 1] ^ i; } long long sum = 0; for (int i = 1; i ...
// Filename: sevensegmentdecoder_assign.v // Author: Danny Dutton // Date: 03/03/15 // Version: 1 // Description: Decode 4-bit input and drive a seven segment using assignment module sevensegdecoder_always(digit, drivers); input [3:0] digit; output [6:0] drivers; // Take a to be the MSB of t...
`timescale 1 ns / 1 ps module axi_bram_reader # ( parameter integer AXI_DATA_WIDTH = 32, parameter integer AXI_ADDR_WIDTH = 32, parameter integer BRAM_DATA_WIDTH = 32, parameter integer BRAM_ADDR_WIDTH = 10 ) ( // System signals input wire aclk, input wire a...
#include <bits/stdc++.h> using namespace std; const int MAX = 505; long long l1[MAX], l2[MAX], r1[MAX], r2[MAX], a1[MAX], a2[MAX]; int main() { ios::sync_with_stdio(0); cin.tie(0); int q; cin >> q; for (int i = 0; i < q; ++i) { cin >> l1[i] >> r1[i] >> l2[i] >> r2[i]; } for (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...
#include <bits/stdc++.h> using namespace std; long long cnt[10]; long long w, ans; void dfs(int pos, long long c) { long long rec; if (pos > 8) { ans = max(ans, w - c); return; } rec = min(cnt[pos], c / pos); for (long long i = rec; i >= max(rec - 8, 0LL); i--) dfs(pos + 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 la...
#include <bits/stdc++.h> using namespace std; const int maxn = 2000; int pre[maxn]; int countlen(int i) { int ans = 0, p; for (p = i; p != -2; p = pre[p]) ans++; return ans; } int main() { int i, n; cin >> n; for (i = 0; i < n; i++) cin >> pre[i], pre[i]--; int ans = 0; for (...
#include <bits/stdc++.h> using namespace std; template <class T> T power(T a, T b) { T x; if (b == 0) x = 1; else x = a; for (size_t i = 1; i < b; i++) x *= a; return x; } long long int gcd(long long int a, long long int b) { return b == 0 ? a : gcd(b, a % b); } long lo...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2003 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); // surefire lint_off _NETNM // surefire lint_off ST...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Ultra(TM) in wire load mode // Version : L-2016.03-SP3 // Date : Sun Nov 20 02:50:12 2016 ///////////////////////////////////////////////////////////// module ETAII_N16_Q4 ( in1, in2, res ); input [15:0] in1; input [15...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops , omit-frame-pointer , inline ) #pragma GCC option( arch=native , tune=native , no-zero-upper ) #pragma GCC target( avx2 ) using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typen...
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1); void boos() { ios_base ::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void file() { freopen( array.in , r , stdin); freopen( array.out , w , stdout); } const long long INF = 1e9 + 7; const int INF1...
/* * 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 "defines.v" module registers( input wire clk, input wire rst, input wire[4:0] readAddr1_i, input wire readEnable1_i, output reg[31:0] data1_o, input wire[4:0] readAddr2_i, input wire readEnable2_i, output reg[31:0] data2_o, input wire[4:0] writeAddr_i, input wire[31:...
module top; reg passed; reg [1:0] sel; reg [1:0] A; wire Z; parent parent(.sel(sel), .A(A), .Z(Z)); initial begin // $monitor("1: %b, 0: %b", parent.child[1].Z, parent.child[0].Z); passed = 1'b1; sel = 2'b11; A = 2'b00; #1 if (Z !== 1'b0) begin $display("FAILED: selected both, ex...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : 11....
#include <bits/stdc++.h> using namespace std; int n, tms; void upd(int &x, int y) { x = min(x, y); } struct trietree { int node[505][12]; int sum[505]; int dp[505][505][12]; int dp2[505][505][12][12]; bool vis[505][505][15]; int dep[505]; int tot; void insert(char ch[], int val) ...
// // Copyright (c) 1999 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; const int N = 1e3 + 5; char a[N][N]; void fileIO() {} int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; fileIO(); int h, w; int tot = 0; cin >> h >> w; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++)...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long n, n2 = 1, a[5010], dat[20010], ans = 0; vector<long long> v, vv[5010]; map<long long, long long> mp; void build(long long k, long long lb, long long ub) { if (lb == ub) return; build(k * 2 + 1, lb, (lb + ub) / 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 law...
#include <bits/stdc++.h> using namespace std; const long long maxn = 5e5; vector<pair<long long, long long>> g[maxn]; long long v1 = 0; long long v2 = 0; vector<pair<pair<long long, long long>, long long>> t1(maxn * 4); vector<pair<pair<long long, long long>, long long>> t2(maxn * 4); vector<long long> ...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> ostream& operator<<(ostream& cout, const pair<T1, T2>& a) { return cout << ( << a.first << ; << a.second << ) ; } template <typename T> ostream& operator<<(ostream& cout, const vector<T>& a) { if (a.size() == 0) ...
#include <bits/stdc++.h> 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) { cerr << x; } void __prin...
/** * 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...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; if (n > 5 * m) { cout << YES ; return 0; } bool dp[n][m + 1]; for (int i = 0; i <= m; i++) dp[0][i] = false; for (int i = ...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module tlu_controller #( parameter BASEADDR...
//----------------------------------------------------------------------------- // File : test_setup.v // Creation date : 28.11.2017 // Creation time : 15:57:44 // Description : Test arrangement for verifying the SPI examples. // Created by : TermosPullo // Tool : Kactus2 3.4.1184 32-bit // Plugin : Veril...
#include <bits/stdc++.h> using namespace std; struct pairvar { int a; int b; }; bool isPrime(long long x) { if (x == 1) { return false; } long long a = (long long)x; for (int i = 2; i <= (long long)sqrt((double)a); i++) { if (a % i == 0) { return false; } } ...
#include <bits/stdc++.h> using namespace std; const int N = 1000006, LG = 21, mod = 1e9 + 7, M = N; const double eps = 1e-3, pi = acos(-1.0); const long long INF = 1123456789123456789LL; int main() { string str; cin >> str; char mi = a ; bool ans = true; for (char c : str) if (c > m...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:51:28 08/18/2015 // Design Name: // Module Name: Comparator_Equal // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencie...
/* * usart.v - Serial interface to supervisor chip * * Part of the CPC2 project: http://intelligenttoasters.blog * * Copyright (C)2017 * * 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...
/** * 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 = 105555; int a[N]; int main() { int n; scanf( %d , &n); int mn = 1e7, mi, mx = -1e7, xi; for (int i = 0; i < n; ++i) { scanf( %d , a + i); if (i > 1 && xi < i - 1 && mx > a[i - 1] && a[i - 1] < a[i]) { printf( 3 n%d %...
#include <bits/stdc++.h> using namespace std; const int MAXN = 600010; struct wl { int k, l, pos; }; wl w[MAXN]; wl temp[MAXN]; int n; int p[MAXN]; int cnt, tcnt; int *t; int x[MAXN], y[MAXN]; int find(int p) { int l = 0, r = tcnt; while (l < r) { int mid = (l + r) / 2; i...
// Generated by altmemphy 10.0 [Altera, IP Toolbench 1.3.0 Build 218] // ************************************************************ // THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE! // ************************************************************ // Copyright (C) 1991-2011 Altera Corporation // Any megaf...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; int a = 1, b = n * n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n / 2; j++) { if (j > 1) cout << ; cout << a << << b; a++, b--; } c...
#include <bits/stdc++.h> using namespace std; using ld = long double; void run(); signed main() { ios::sync_with_stdio(0); cin.tie(); cout << fixed << setprecision(13); run(); } void print(vector<long long> a) { for (long long i : a) { cout << i << ; } cout << endl; } ...
#include <bits/stdc++.h> using namespace std; long long n, m, budget; long long price[100005], perMoney[100005]; bool can(int k) { long long curBudget = 0; int j = 0; for (int i = k - 1; i >= 0; i--, j++) { curBudget += max(0ll, price[j] - perMoney[i]); } return curBudget <= budget; ...
/** * 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 = 1e5 + 50; const int inf = 0x3f3f3f3f; int A[maxn]; int n, k; void solve(int l, int r) { if (l + 1 == r || !k) return; int mid = (l + r) >> 1; k -= 2; swap(A[mid], A[mid - 1]); solve(l, mid); solve(mid, r); } int main(...
#include <bits/stdc++.h> using namespace std; const int NMAX = 1005; const int INF = 1 << 30; int n, m, xs, xf, ys, yf; char a[4][NMAX][NMAX]; int d[4][NMAX][NMAX]; bool inq[4][NMAX][NMAX]; deque<pair<int, pair<int, int>>> q; bool u(int dir, int x, int y) { char c = a[dir][x][y]; return c == ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; long long INF = (long long)1e20; long long mod = (long long)1e9 + 7; pair<long long, long long> solve( long long v, vector<vector<pair<long long, long long>>> &nodes, long long p, long long k) { vector<pair<pair<long long, long long>, long long>> a; ...
#include <bits/stdc++.h> using namespace std; string rem(string second) { if (second[second.size() - 1] == r ) second.erase(second.size() - 1); return second; } vector<string> split(string second, char delim) { replace(second.begin(), second.end(), delim, ); stringstream ss(second); str...
/* * 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 spi_slave ( input clk, input resetn, input spi_clk, input spi_mosi, input spi_cs, input [7:0] write_value, output [7:0] read_value, output [0:0] first_byte, output [0:0] timeout_expired, output [0:0] done, output [7:0] debug_info );...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long B = uniform_int_distribution<int>(333, 999)(rng); const long long MOD1 = 1792209677, MOD2 = 1211874137; template <class T> pair<T, T> operator+(const pa...
//----------------------------------------------------------------------------- //-- Banco de prueba para setbit //-- (c) BQ August 2015 //-- Written by Juan Gonzalez (obijuan) //-- mods by D. Cuartielles for Arduino, 2015 December, GPLv3 //----------------------------------------------------------------------------- /...
/** * 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 law...
#include <bits/stdc++.h> using namespace std; const int IINF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; const double DINF = numeric_limits<double>::infinity(); const int MOD = 1000000007; const double EPS = 1e-9; const double PI = acos(-1.0); const int DX[] = {1, 0, -1, 0, 1, -1, 1, -1};...
#include <bits/stdc++.h> using namespace std; void solve() { int i, j, k, n, m, ans = 0, cnt = 0, sum = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; vector<int> res; res.push_back(a[0]); int last = a[0], flag = 1; for (int i = 1; i < n - 1;) { if (abs(a[i] - ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int s = 0; while (n--) { int a, b; cin >> a >> b; s += b - a + 1; } cout << (k - (s % k)) % k << endl; return 0; }