text
stringlengths
59
71.4k
`define bsg_tiehi_macro(bits) \ if (harden_p && (width_p==bits)) \ begin: macro \ bsg_rp_tsmc_40_TIEHBWP_b``bits tiehi (.o); \ end module bsg_tiehi #(parameter `BSG_INV_PARAM(width_p) , parameter harden_p=1 ...
/* sigma-delta modulator test */ module sdm ( input clk, //bus clock input [14:0] ldatasum, // left channel data input [14:0] rdatasum, // right channel data output reg left=0, //left bitstream output output reg right=0 //right bitsteam output ); //-------------------------------------------------...
#include <bits/stdc++.h> using namespace std; int main() { int n, t, x, c, d, ch = 0, caser = 0, lol = 0, sum = 0, rating = -1, upper = 1e9, lower = -1e9; cin >> n; for (int i = 0; i < n; i++) { cin >> c >> d; if (i == 0) { if (d == 1) lower = 1900; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int th = 0; for (int i = 1; i < n; i++) { th += i; th %= n; cout << (th + 1) << ; } return 0; }
module riscv_fid ( clk, resetn, //Instruction bif instr_bif_addr, instr_bif_rdata, instr_bif_req, instr_bif_ack, //bypass wdata_bypass, //STall stall_back, //RF write channel rf_wdata, rf_wr_req, rf_wr_ack ); reg [31:0] pc; assign instr_bif_addr = pc; alway...
#include <bits/stdc++.h> using namespace std; int main() { int n, b, d; int a[100000 + 10]; cin >> n >> b >> d; for (int i = 0; i < n; i++) cin >> a[i]; int p = 0, emp = 0; int temp = 0; for (int i = 0; i < n; i++) { if (a[i] > b) continue; temp += a[i]; if (temp > d) {...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int a[N]; int main() { int i, j, k = 0, n; cin >> n; long long s = 0, t; for (i = 1; i <= n; i++) { cin >> a[i]; s += a[i]; } if (s % 2 == 1) { cout << 0 n ; return 0; } t = 0; for (...
/* * 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...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ // Behavioral model for the 32-bit program counter module program_counter2 (next_pc,rst,clk); // Output signals... // Incremented value of the program counter output [0:31] next_pc; // =======...
// DESCRIPTION: Verilator: Verilog Test module module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; reg [2*32-1:0] w2; initial w2 = {2 {32'h12345678}}; reg [9*32-1:0] w9; initial w9 = {9 {32'h12345678}}; reg [10*32-1:0] w10; initial w...
#include <bits/stdc++.h> using namespace std; int n, id = 0; int Hash[333], L[333]; map<string, int> M; vector<int> v; int kmp(int Len) { int len = v.size(); int lps[len], I = 0, num = 0; lps[0] = 0; for (int i = 1; i < len; i++) { if (v[I] != v[i]) I = -1; lps[i] = ++I; } ...
#include <bits/stdc++.h> int main() { int n, s, i, a, b, t, j, v, f, c; int candy = -1, d; scanf( %d%d , &n, &s); s = s * 100; while (n--) { scanf( %d%d , &a, &b); d = (a * 100) + b; if (d <= s) { f = s - d; c = f % 100; if (c > candy) candy = c; } ...
#include <bits/stdc++.h> using namespace std; const long long N = 200005; int main() { long long n, z, x, y; cin >> n; z = (n * (n - 1) * (n - 2) * (n - 3) * (n - 4)) / 120; x = (z * (n - 5)) / 6; y = (x * (n - 6)) / 7; cout << z + x + y << n ; return 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...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
/* * 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; char c1[1005], c2[1005]; long long f[100005][2], ans, k, l; bool pd; int main() { scanf( %s , c1); scanf( %s , c2); scanf( %lld , &k); l = strlen(c1); f[0][0] = 1; for (register long long i = 1; i <= k; i = -~i) { f[i][0] = ((l - 1) *...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first; } for (int i = 0; i < n; i++) { cin >> a[i]...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; double r; cin >> n >> r; double X[n]; for (int i = 0; i < n; i++) { cin >> X[i]; } double Y[n]; Y[0] = r; for (int i = 1; i < n; i++) { Y[i] = r; for (int j =...
////////////////////////////////////////////////////////////////////// //// //// //// spi_shift.v //// //// //// //// This file is part of the SPI I...
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; long long pwr(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % MOD; b >>= 1, a = a * a % MOD; } return ans; } long long inv(long long a) { return pwr(a, MOD - 2); } ...
#include <bits/stdc++.h> inline int two(int n) { return 1 << n; } inline int test(int n, int b) { return (n >> b) & 1; } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(int& n, int b) { n &= ~two(b); } inline int last_bit(int n) { return n & (-n); } inline int ones(int n) { int...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:53:42 05/12/2015 // Design Name: // Module Name: EX_ME // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenc...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T, class U> ostream& operator<<(ostream& o, const pair<T, U>& p) { o << ( << p.first << , << p.second << ) ; return o; } template <class T> ostream& operator<<(ostream& o, const vector<T>& v) { o << [ ; ...
// (c) Copyright 1995-2017 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() { long long n; cin >> n; long long a[n + 1]; memset(a, 0, sizeof(a)); for (long long i = 1; i <= n; i++) cin >> a[i]; sort(a, a + n + 1); long long sum[n + 1]; memset(sum, 0, sizeof(sum)); sum[1] = a[1]; for (int i = 2;...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2009 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t; integer p_i; // signal type IData reg [15:0] p_s; // signal type SData reg [7:0] ...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. `ifdef OVL_XCHECK_OFF //Do nothing `else `ifdef OVL_IMPLICIT_XCHECK_OFF //Do nothing `else wire valid_start_event; wire valid_test_expr; assign valid_start_event = ~(start_event ^ st...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; template <class T, class U> inline void Max(T &a, U b) { if (a < b) a = b; } template <class T, class U> inline void Min(T &a, U b) { if (a > b) a = b; } char s[3][105]; int ok[3][105], dp[105...
/** * 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 n; scanf( %d , &n); int num = sqrt(n); if (num * num == n) { for (int i = n - num + 1; i >= 1; i -= num) { for (int j = 0; j < num; j++) { printf( %d , i + j); } } printf( n ); return 0...
#include <bits/stdc++.h> using namespace std; int n, m, lim; struct node { int to; int val; }; stack<int> ans; vector<node> g[5500]; int f[5500][5500]; int fa[5500][5500]; void dfs(int u, int dep) { for (int i = 0; i != g[u].size(); i++) { int& co = g[u][i].val; int& v = g[u][i...
#include <bits/stdc++.h> using namespace std; enum { MAXPOS = 110500, MAXBYTE = 20, MAXN = 7070 }; int q_level[MAXN], q_left[MAXN], q_right[MAXN], q_value[MAXN]; int jump_up[MAXBYTE][MAXPOS], jump_low[MAXBYTE][MAXPOS]; int high[MAXPOS]; void init() { for (int i = 0; (1 << i) < MAXPOS; i++) high[1 << 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; /*AUTOWIRE*/ // Beginning of au...
/** * 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...
////////////////////////////////////////////////////////////////// // // // Barrel Shifter for Amber 2 Core // // // // The design is optimized for Altera family of FPG...
/* * 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 (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> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { template <class 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 la...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, a, b; cin >> n >> a >> b; int N = n; if (abs(a - b) > 1) { cout << -1 << n ; continue; } if (a + b > n - 2) { cout << -1 << n ; continu...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (win64) Build Wed Oct 4 19:58:22 MDT 2017 // Date : Fri Nov 17 14:50:25 2017 // Host : egk-pc running 64-bit major release (build...
#include <bits/stdc++.h> using namespace std; const int maxN = 40; int a[maxN][maxN]; int b[maxN][maxN]; int flips[maxN][maxN]; int n, x; int check(int mask) { memset(flips, 0, sizeof(flips)); for (int i = 0; i < x; ++i) { if (mask & (1 << i)) { flips[x - 1][i] = 1; } } ...
// fpgaTop_illite.v - ssiegel 2009-03-17 module fpgaTop( input wire sys0_clkp, // sys0 Clock + input wire sys0_clkn, // sys0 Clock - input wire pci0_clkp, // PCIe Clock + input wire pci0_clkn, // PCIe Clock - input wire pci0_rstn, // PCIe Reset ou...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t ope...
`include "hglobal.v" `default_nettype none `define NS_DBG_NXT_ADDR(adr) ((adr >= MAX_ADDR)?(MIN_ADDR):(adr + 1)) `define NS_DBG_SRC_ADDR 3 `define NS_DBG_INIT_CK 14 `define NS_DBG_INIT_DAT 5 `define NS_DBG_INIT_RED 15 `define NS_DBG_MAX_SRC_CASE 4 module pakout_io #(parameter MIN_ADDR=1, MAX_ADDR=1, PSZ...
#include <bits/stdc++.h> using namespace std; int N; int x, y, root = -1; vector<int> g[200100]; int len[200100], viz[3][200100]; int dmax = 0, ind; int stacky[200100], l = 0; void dfs(int x) { viz[0][x] = 1; if (g[x].size() == 1) { len[x] = 1; } else { int okk = 1; int kid...
/** * 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...
//====================================================================== // // system_m6502.v // -------------- // A simple test system that can be implemented a FPGA device. // It basically instantiates a m6502 cpu core, provides some // memory and some address mapped I/O. // // // Author: Joachim Strombergson // Copy...
/* * 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 top; reg passed; reg [9*8:1] check; reg [71:0] value; reg [7:0] nval; real rval; initial begin passed = 1'b1; // Look for the hex value using a runtime string. check = "hex=%h"; if (! $value$plusargs(check, value)) begin $display("FAILED: Unable to get hex value."); passe...
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const long long INFL = LLONG_MAX; int N, w, W[100100], b, B[100100], C[100100], S[100100]; int main() { ios_base::sync_with_stdio(0); cin >> N; for (int(i) = 1; (i) <= (N); (i)++) { cin >> C[i] >> S[i]; if (C[i]) ...
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; for (int t = 0; t < test; t++) { int n; cin >> n; int k = 2; while (n % (int)(pow(2, k) - 1) != 0) { k++; } int ans = n / (pow(2, k) - 1); cout << ans << endl; } re...
/* * pll_adv_example.v: Example program working in simulation as well as it should on real hardware. * To be tested on Digilent Basys 3. * author: Till Mahlburg * year: 2019 * organization: Universität Leipzig * license: ISC * */ `timescale 1 ns / 1 ps module pll_adv_example ( input clk, input RST, output...
#include <bits/stdc++.h> using namespace std; int main() { char s[200001], t1[200001]; long long n, x, y, t, con = 0; cin >> n >> x >> y; getchar(); gets(s); t = n - x; for (long long i = t; s[i] != 0 ; i++) { if (i == n - 1 - y && s[i] != 1 ) con++; if (i != n - 1 - y && ...
// Copyright (c) 2014 CERN // Maciej Suminski <> // // 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) // any late...
/** * 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) 2000-2013 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...
#include <bits/stdc++.h> using namespace std; long long x, y, c; int n; const int maxn = 300009; char str[maxn]; long long cnt = 0; int main() { cin >> n >> x >> y; cin >> str; int now = 0; for (int i = 0; i < n; ++i) { if (str[i] == 1 ) { if (now != 0) cnt++; now = ...
#include <bits/stdc++.h> using namespace std; const int maxn = 50005; const long long UP = 2.2e9; long long num[maxn], sum[maxn]; int cnt, wei[15]; inline void init() { long long up = 0, pre = 0, x = 0, cut = 0; cnt = 0; int flag = 0; for (int k = 1; k <= 9; ++k) { cut = x; x = x...
`default_nettype none `include "processor.h" module core_interrupt_manager( //System input wire iCLOCK, input wire inRESET, //Free input wire iFREE_IRQ_SETCONDITION, //Interrupt Configlation Table input wire iICT_VALID, input wire [5:0] iICT_ENTRY, input wire iICT_CONF_MASK, input wire iICT_CONF_VA...
#include <bits/stdc++.h> using namespace std; int it[200041], n, io; int down(int x) { int s = 0, rs = x; while (x <= n * 2) { s = max(it[x], s); x += x & (-x); } return s; } void up(int x, int u) { while (x > 0) { it[x] = max(it[x], u); x -= x & (-x); } } i...
#include <bits/stdc++.h> using namespace std; long long powmod(long long base, long long exponent, long long mod) { long long result = 1; while (exponent > 0) { if (exponent % 2 == 0) { exponent /= 2; base = (base * base) % mod; } else { result = (result * base) % mod; ...
#include <bits/stdc++.h> using namespace std; const int Maxn = 10005; const int Inf = 1000000000; int n; int a[Maxn]; set<pair<int, int> > S; long long res; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); for (int i = 0; i < n; i++) S.insert(pair<int, int>(i - a...
/** * 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 "lo_read.v" /* pck0 - input main 24Mhz clock (PLL / 4) [7:0] adc_d - input data from A/D converter lo_is_125khz - input freq selector (1=125Khz, 0=136Khz) pwr_lo - output to coil drivers (ssp_clk / 8) adc_clk - output A/D clock signal ssp_frame - output SSS frame indicator (goes high whi...
#include <bits/stdc++.h> using namespace std; unsigned long long int gcd(unsigned long long int a, unsigned long long int b) { unsigned long long int max = a > b ? a : b; unsigned long long int min = a < b ? a : b; if (max % min == 0) return min; if (max % min == 1) return 1; return gcd(min, max...
#include <bits/stdc++.h> bool choice_first(std::vector<size_t> a, std::vector<size_t> b) { uint64_t sum_a, sum_b; sum_a = sum_b = 0; for (auto elem : a) { sum_a += elem; } for (auto elem : b) { sum_b += elem; } return sum_a > sum_b || (sum_a == sum_b && a < b); } int main()...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2017 Xilinx, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // /...
// // ram.v -- main memory, using SDRAM // module ram(clk, clk_ok, reset, en, wr, size, addr, data_in, data_out, wt, sdram_cke, sdram_cs_n, sdram_ras_n, sdram_cas_n, sdram_we_n, sdram_ba, sdram_a, sdram_udqm, sdram_ldqm, sdram_dq); // internal inte...
/** * 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) 2011 Kiel Friedt * * 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 * (at your option) any later version. * * This p...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n]; vector<long long> v; for (long long i =...
`timescale 1ns / 1ps `include "cordic.vh" // synopsys_ template module cordic #( parameter DEC = 2, // decimal points parameter FRAC = 14, // fraction points parameter MOD = `MOD_CIR, // MOD = {`MOD_CIR=1,`MOD_LIN=0,`MOD_HYP=-1} parameter DIR = `DIR_ROT // DIR = {`DIR_ROT=0, `DIR_VEC=1} ) ( clk, rst, g...
//altiobuf_out CBX_AUTO_BLACKBOX="ALL" CBX_SINGLE_OUTPUT_FILE="ON" DEVICE_FAMILY="Cyclone V" ENABLE_BUS_HOLD="FALSE" NUMBER_OF_CHANNELS=1 OPEN_DRAIN_OUTPUT="FALSE" PSEUDO_DIFFERENTIAL_MODE="TRUE" USE_DIFFERENTIAL_MODE="TRUE" USE_OE="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN1="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN2="FALSE" USE_TE...
/* * 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() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a, b; int c[4]; int minC = INT_MAX; for (int i = 0; i < 4; i++) { cin >> c[i]; if (minC > c[i]) minC = c[i]; } cin >> a >> b; int minXX = min(...
/* Copyright (c) 2018 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; int main() { ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> v(n); vector<int> cnt(n + 1, 0); for (int i = 0; i < n; i++) { cin >> ...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T pow(T a, T b, long long m) { T ans = 1; while (b > 0) { if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m; b /= 2; a = (...
#include <bits/stdc++.h> using namespace std; struct trio { int64_t first, second, trd; friend ostream &operator<<(ostream &o, trio &a) { o << ( << a.first << , << a.second << , << a.trd << ) ; return o; } }; template <typename T> inline T max() { return numeric_limits<T>::m...
/* * 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...
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed ...
// this is the sprite parallel to serial converter // clk is 7.09379 MHz (low resolution pixel clock) // the sprdata assign circuitry is constructed differently from the hardware // as described in the amiga hardware reference manual // this is to make sure that the horizontal start position of a sprite // aligns with...
#include <bits/stdc++.h> using namespace std; int ans[100009]; int cmp(int a, int b) { return a <= b; } int main() { int n; while (scanf( %d , &n) != EOF) { for (int i = 0; i < n; i++) scanf( %d , &ans[i]); sort(ans, ans + n); int vaule = 0; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; const int N = 8; const int dxs[] = {2, 1, -1, -2, -2, -1, 1, 2}; const int dys[] = {-1, -2, -2, -1, 1, 2, 2, 1}; char s0[8], s1[8]; bool flds[N][N]; inline void readpos(char s[], int &x, int &y) { x = s[0] - a ; y = s[1] - 1 ; } inline void setkn...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; vector<int> level[MAXN]; vector<pair<int, int>> adj[MAXN]; vector<pair<int, pair<int, int>>> edges; int dp[MAXN], d[MAXN], prv[MAXN]; bool OnPath[MAXN]; int main() { int n, m, a, b, c, cnt = 0; scanf( %d%d , &n, &m); for ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: jbi_ncrd_timeout.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 ...
/* * Copyright 2018-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 to in...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, ans = 0; cin >> n; string x; cin >> x; for (long long int i = 0; i < x.length(); i++) { if (x[i] == 0 || x[i] == 2 || x[i] == 4 || x[i] == 6 || x[i] == 8 ) { ans += (i + 1); } }...
#include <bits/stdc++.h> using namespace std; struct trie { trie* child[2]; int cnt; trie() { child[0] = child[1] = NULL; cnt = 0; } } * root; int n, k, sum; long long res; void add(int val) { trie* node = root; for (int i = 29; i >= 0; i--) { int j = (val >> i) & 1...
#include <bits/stdc++.h> using namespace std; long long n, x, a[200000]; long long bs(long long xx, long long yy, long long k) { long long m = (xx + yy) / 2; if (yy - xx <= 1) return xx; if (a[m] <= k) return bs(m, yy, k); else return bs(xx, m, k); } int main() { cin >> n; ...
#include <bits/stdc++.h> using namespace std; int H[100000][5], V[100000][5]; long long dp[32]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1; i < m; ++i) for (int j = 0; j < n; ++j) cin >> H[i][j]; for (int i = 0; i < m; ++i) for (...
/** * 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 maxi = 1e6 + 6; int b, di; string a, c, t; pair<int, int> d[maxi], d1[maxi]; int ob[maxi]; int main() { cin >> b >> di; cin >> a; cin >> c; int n = a.size(); int m = c.size(); for (int i = 0; i < m; i++) { int id = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a[101][101] = {0}, d = 0; cin >> n; for (long long int i = 1; i <= n; i++) { long long int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; for (long long int j = x1; j <= x2; j++) { for (long long int k = ...
/** * 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 gcd(int a, int b) { while (b) { int r = a % b; a = b; b = r; } return a; } int64_t lcm(int a, int b) { return 1LL * a * b / gcd(a, b); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >...
#include <bits/stdc++.h> using namespace std; int n, p[200001], bl, cnt, cntbl, visited[200001], flag; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> p[i]; } for (int i = 1; i <= n; i++) { if (!visited[i]) { int j = i, tmp = j; while (!visited[j]) { ...