text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; void printReverseStack(stack<int> &ans) { int x = ans.top(); ans.pop(); if (!ans.empty()) printReverseStack(ans); cout << x << ; } int main() { int n, d, l, x; stack<int> ans; cin >> n >> d >> l; ans.push(d); while (ans.size() ...
module pulsar (clk, drv); input clk /* synthesis chip_pin = "R8" */; output drv /* synthesis chip_pin = "B5" */ ; // JP1.10 GPIO_07 // clk = 50MHz (20ns) // run[0] = 25MHz (40ns) // run[1] = 12.5MHz (80ns) // run[2] = 6.25MHz (160ns) // run[3] = 3.125MHz (320ns) // run[4] = 1.5625MHz (640ns) // run[5] = 0.78125MHz (1...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long linf = 1e18 + 5; long long int gcd(long long int a, long long int b) { return (b == 0 ? a : gcd(b, a % b)); } long long int lcm(int a, int b) { return (a * (b / gcd(a, b))); } long long int max(long long int a, long l...
// ============================================================== // 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 1 ns / 1 ps m...
//***************************************************************************** // (c) Copyright 2009 - 2012 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property /...
#include <bits/stdc++.h> using namespace std; const long long INF64 = 1e18; clock_t time_p = clock(); void time() { time_p = clock() - time_p; cerr << Time Taken : << (float)(time_p) / CLOCKS_PER_SEC << n ; } void doc() { freopen( input.txt , r , stdin); freopen( output.txt , w , stdo...
#include <bits/stdc++.h> using namespace std; struct single_node { long long total; long long prefix; long long suffix; }; vector<pair<long long, pair<int, int> > > v; set<int> bounds; long long a[300000 + 50]; long long d[300000 + 50]; long long c[300000 + 50]; long long lazy[1200000 + 50...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int n, m; int k[200010]; int rem[200010]; int idx[200010]; vector<int> special[200010]; vector<int> days[200010]; bool pos(const long long M) { long long coins = 0; memset(idx, 0, sizeof(idx)); for (int i = 0; i < n; i++) r...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:33:50 11/11/2015 // Design Name: // Module Name: GameWithSound // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int dp(int a, int b, int row) { if (row == 1 && a < 3 && b >= 3) { return -1; } if (row == 0 && a < 3 && b >= 3) { return 0; } if (row == 1 && a < 3 && b < 3) { return 1; } if (row == 0 && a < 3 && b < 3) { 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...
#include <bits/stdc++.h> using namespace std; const int oo = 1e9, mxn = 100010; int A[mxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; for (int i = (0); i < (n); ++i) cin >> A[i]; vector<bool> visited(n); int curr = 0; ...
#include <bits/stdc++.h> using namespace std; const long long int E = 1e18 + 7; const long long int MOD = 1000000007; int main() { long long int n; cin >> n; while (n--) { string s; cin >> s; bool P = true; bool same = true; for (int i = 0; i < s.size(); i++) { ...
//***************************************************************************** // (c) Copyright 2008-2009 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // ...
#include <bits/stdc++.h> using namespace std; inline int in() { int32_t x; scanf( %d , &x); return x; } inline long long lin() { long long x; scanf( %lld , &x); return x; } inline int mul(int a, int b) { long long x = a; x *= (long long)b; if (x >= 1000000007) x %= 100000...
#include <bits/stdc++.h> using namespace std; int a[101]; int b[101]; int storage[200001]; int storage2[200001]; int* value = storage + 100000; int* prevalue = storage2 + 100000; int n, k; int main() { scanf( %d%d , &n, &k); int gtzero = 0, lezero = 0; for (int i = 0; i < n; i++) scanf( %d...
module eth2dma_intercon ( input aclk, input aresetn, input s_rxs0_axis_tvalid, input s_rxs1_axis_tvalid, input s_rxs2_axis_tvalid, input s_rxs3_axis_tvalid, output s_rxs0_axis_tready, output s_rxs1_axis_tready, output s_rxs2_axis_tready, output s_rxs3_axis_tready, input [31 : 0] s_rxs0...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/05/24 15:18:58 // Design Name: // Module Name: add_two_values_task_tb // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies...
module wb_upsizer #(parameter DW_IN = 0, parameter SCALE = 0, parameter AW = 32) (input wb_clk_i, input wb_rst_i, input [AW-1:0] wbs_adr_i, input [DW_IN-1:0] wbs_dat_i, input [DW_IN/8-1:0] wbs_sel_i, input wbs_we_i, input wbs_cyc_i, input wbs_stb_i, ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59}; int fack[62]; int dp[110][1 << 17]; int pre[110][1 << 17]; int x[110][1 << 17]; int n; int a[110]; void init() { memset(fack, 0, sizeof(fack)); for (int i = 1; i <= 60;...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int MN = 105; bool mark[500][500]; char s[MN]; int dis[500][500]; int ask(pair<int, int> now) { int res = INF; if (mark[now.first][now.second]) res = min(res, dis[now.first][now.second]); if (mark[now.first - 1][now.secon...
`timescale 1 ns / 1 ps module scale_1d # ( parameter integer C_M_WIDTH = 12, parameter integer C_S_WIDTH = 10, parameter integer C_S_ADDR_WIDTH = 32 ) ( input wire clk, input wire resetn, input wire [C_S_WIDTH-1:0] s_width, input wire [C_M_WIDTH-1:0] m_width, input wire start, output wire o_valid, output...
module brushless_motor( // Qsys bus interface input rsi_MRST_reset, input csi_MCLK_clk, input [31:0] avs_ctrl_writedata, output [31:0] avs_ctrl_readdata, input [3:0] avs_ctrl_byteenable, input [2:0] avs_ctrl_address, input avs_ctrl_write, input avs_ctrl_read, output ...
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize( Ofast ) #pragma GCC optimize( inline ) using namespace std; const long long p = 998244353, g = 3, gv = 332748118, N = 1e6 + 5; long long qpow(long long a, int b) { long long ret = 1; while (b) { if...
/** * 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...
module check (input signed [22:0] a, b, c); wire signed [22:0] int_AB; assign int_AB = a / b; always @(a, b, int_AB, c) begin #1; if (int_AB !== c) begin $display("ERROR: mismatch in div for %d and %d", a , b); $display("VHDL = %d, Verilog = %d", c, int_AB); $finish; end end endmodule module s...
#include <bits/stdc++.h> using namespace std; constexpr int inf = 1e9; int main() { int n, q; cin >> n >> q; vector<int> t(q), l(q), r(q), v(q); vector<int> added(n), ub(n, inf); for (int j = 0; j < q; ++j) { cin >> t[j] >> l[j] >> r[j] >> v[j]; l[j]--; if (t[j] == 1) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.first << << p.second; return os; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (int i...
//***************************************************************************** // (c) Copyright 2008 - 2010 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property /...
#include <bits/stdc++.h> using namespace std; int n, p; int sum[200000]; int main() { scanf( %d %d , &n, &p); for (int i = 1; i <= n; ++i) { scanf( %d , &sum[i]); sum[i] = (sum[i - 1] + sum[i]) % p; } int ans = 0; int l, r; for (int i = 1; i < n; ++i) { l = sum[i]; ...
#include <bits/stdc++.h> using namespace std; int n, a[5]; int c[100]; int main() { ios_base::sync_with_stdio(false); cin >> n >> a[0] >> a[1]; for (int i = 1; i <= n; i++) cin >> c[i]; int m = min(a[0], a[1]); int ans = 0; for (int i = 1; i <= n / 2 + n % 2; i++) { if (c[i] == 2 &...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int x, long long int y) { if (y > x) { return gcd(y, x); } if (y == 0) { return x; } return gcd(y, x % y); } bool prime(long long int x) { for (long long int i = 2; i <= sqrt(x); i++) { if (x % i ...
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005]; int main() { int n, m, i; long long sum = 0; scanf( %d%d , &n, &m); for (i = 1; i <= m; i++) { scanf( %d , &a[i]); sum += a[i]; if (a[i] + i > n + 1) { printf( -1 ); return 0; } } ...
/* * BCH Encode/Decoder Modules * * Copyright 2014 - Russ Dill <> * Distributed under 2-clause BSD license as contained in COPYING file. */ `timescale 1ns / 1ps `include "bch_defs.vh" module sim #( parameter [`BCH_PARAM_SZ-1:0] P = `BCH_SANE, parameter OPTION = "SERIAL", parameter BITS = 1, parameter REG_RAT...
#include <bits/stdc++.h> using namespace std; template <typename _Tp, typename _Up> bool maximize(_Tp &__a, _Up __b) { if (__a < __b) { __a = __b; return true; } return false; } template <typename _Tp, typename _Up> bool minimize(_Tp &__a, _Up __b) { if (__a > __b) { __a = ...
`timescale 1ns / 1ps //File: vsyncModule.v //Author: Adam Michael, CM1884 // Mohammad Almisbaa, CM2060 //Date: November 5, 2015 //The line increment is synchronized with the hsync pulse //synch pulse is generated at the end of the line: Active Video-BackPorch-SynchPulse-FrontPorch //this is how it is do...
// $Id: c_one_hot_det.v 1749 2010-02-03 23:45:14Z dub $ /* Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimization( O3 ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( avx,avx2,fma ) using namespace std; int main() { long double r, x1, y1, x2, y2; cin >> r >> x1 >> y1 >> x2 >> y2; long double x = sqrt((y1 - y2) * (y1 - ...
`default_nettype none //--------------------------------------------------------------------- //-- -- //-- Company: University of Bonn -- //-- Engineer: John Bieling -- //-- ...
#include <bits/stdc++.h> using namespace std; int main() { int t, m; cin >> t >> m; vector<int> A; A.resize(m); int c = 0; for (int i = 0; i < m; ++i) A[i] = 0; for (int i = 0; i < t; ++i) { string z; int tmp; cin >> z; if (z[0] == d ) { for (int j = 0; j...
/* SPDX-License-Identifier: MIT */ /* (c) Copyright 2018 David M. Koltak, all rights reserved. */ // // Tawas Register File // module tawas_regfile ( input clk, input rst, input thread_load_en, input [4:0] thread_load, output reg [31:0] reg0, output reg [31:0] reg1, output reg [31:0] reg...
`timescale 1ns/1ns module lspc_regs( input RESET, input RESETP, input [3:1] M68K_ADDR, input [15:0] M68K_DATA, input LSPOE, input LSPWE, input VMODE, input [8:0] RASTERC, input [2:0] AA_COUNT, input [15:0] VRAM_LOW_READ, input [15:0] VRAM_HIGH_READ, output WR_VRAM_ADDR, output...
`timescale 10ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09:38:47 03/06/2016 // Design Name: DPWM // Module Name: C:/Users/Jafet/Documents/Proyectos Dis.Sist.Digitales/I_Proyecto_Laboratorio_Sistemas_Digitales/DPWM_TestBen...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: Adam LLC // Engineer: Adam Michael // // Create Date: 15:44:08 09/12/2015 // Design Name: 4:3 Encoder // Module Name: C:/Users/adam/Documents/GitHub/Digital Systems/hw1problem1/encoder43TB.v // Proje...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int pre[N][32], suf[N][32], mx[N][32]; int n, a[N]; long long ans; void init() { for (int i = 0; i < n; i++) mx[i][0] = i; for (int i = 1; (1 << i) < N; i++) { for (int j = 0; j < n; j++) { mx[j][i] = (a[mx[j][i - 1]...
// -- (c) Copyright 2010 - 2011 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...
// (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...
#define y1 askjdkasldjlkasd #include <bits/stdc++.h> #undef y1 using namespace std; #define pb push_back #define mp make_pair #define fi(a, b) for(int i=a; i<=b; i++) #define fj(a, b) for(int j=a; j<=b; j++) #define fo(a, b) for(int o=a; o<=b; o++) #define fdi(a, b) for(int i=a; i>=b; i--) #de...
#include <bits/stdc++.h> using namespace std; struct node { string name; vector<struct node *> sub; }; typedef struct node *NODE; class cf56c { public: int ans = 0; void solve(std::istream &in, std::ostream &out) { string s; int n; in >> s; n = s.length(); stac...
//Legal Notice: (C)2012 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 associate...
#include <bits/stdc++.h> using namespace std; int n, m, k, a[300]; double p[300], d[202][202][402], ans; int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; ++i) { scanf( %lf , &p[i]); p[i] /= 100; } for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); } if ...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, m, l, r, q, nr; string s; string t; cin >> n >> m >> q; cin >> s >> t; int cnt[1001] = {0}; for (int i = 0; i <= n - m; i++) { if (s.substr(i, m) == t) { cnt[i] = 1; } } l = 0; r = 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...
#include <bits/stdc++.h> using namespace std; const int tinf = (int)1e9 + 7; const long long inf = (long long)1e18 + 7; const int N = 1e3 + 5; int main() { { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } long long n, k; cin >> n >> k; long long a[n], Min = inf, ...
//Legal Notice: (C)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 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 law...
#include <bits/stdc++.h> using namespace std; const unsigned long long l = 1000000007; const int MAX_ = 2000; int T; void solve(int t) { long long n; cin >> n; vector<int> p[n]; for (int i = 0; i < n; i++) { int k; cin >> k; p[i] = vector<int>(k); for (int j = 0; j < k;...
#include <bits/stdc++.h> using namespace std; long long int pc; void PrintCase() { printf( Case %lli: , ++pc); } long long int GCD(long long int a, long long int b) { if (a < b) swap(a, b); if (b == 1) return 1; if (!b) return a; if (!(a % b)) return b; else return (a, a % b); ...
#include <bits/stdc++.h> using namespace std; long long n, h, f[100], g[100][100]; long long fun(long long x) { int i; if (f[x] > -1) return 0; f[x] = 0; for (i = 0; i < x; ++i) { fun(i); fun(x - i - 1); f[x] += f[i] * f[x - i - 1]; } return 0; } long long rec(long lo...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.4 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
`timescale 1ns / 1ps ///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE revB.2 compliant I2C Master controller Top-level //// //// //// //// ...
// NeoGeo logic definition (simulation only) // Copyright (C) 2018 Sean Gonsalves // // 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) an...
#include <bits/stdc++.h> const double EPS = 0.0000000001; const long long mod1 = 998244353; const long long mod2 = 1000000007; const long long mod3 = 1000000009; const long long mod4 = 998244353; const long long inf = 10000000000000000; using namespace std; signed main() { cin.tie(0); cout.tie(0...
#include <bits/stdc++.h> int main() { char n[100]; scanf( %s , n); int l = strlen(n); int t = 0; for (int i = 0; i < l; i++) { if (n[i] == 4 || n[i] == 7 ) { t += 1; } } if (t == 4 || t == 7) { printf( YES ); } else { printf( NO ); } }
/** * 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 a[100000]; vector<int> p; long long fact[100001]; long long inv[100001]; long long finv[100001]; void init(int n) { int i; fact[0] = 1; for (i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % 1000000007; inv[0] = 1; inv[1] = 1; for (i ...
#include <bits/stdc++.h> using namespace std; const int N = 55; int n, m; int sz, inp; long long ans[N]; long long sum[N]; long long suf[N]; long long pre[N]; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= n; ++i) { scanf( %d , &sz); ans[i] = pre[i] = -1e9; while (...
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; bool Finish_read; template <class T> inline void read(T &x) { Finish_read = 0; x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; if (ch == EOF) return; ch = getchar();...
/** * 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...
///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE DMA WISHBONE Slave Interface //// //// //// //// ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n, res = 0, t, b; cin >> n; while (n) { res++; t = n; b = -1; while (t) { b = max(b, t % 10); t...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> bool isFile; using namespace std; const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; void _(); void faster() { _(); if (isFile) { freopen( taskA ...
module rc4_tb(); wire control_out; wire [7:0] streamvalue; reg clk, rst_n, control_in, write, read; reg [7:0] keylength, keydata; rc4 U1( .control_out(control_out), .streamvalue(streamvalue), .clk(clk), .rst_n(rst_n), .control_in(control_in), .keylength(keylength), .keydata(keydata), .write(write), ...
#include <bits/stdc++.h> using namespace std; long long exp(long long x, long long y, long long p) { long long res = 1; while (y) { if (y % 2) res = (res * x % p) % p; x = (x * x) % p; y /= 2; } return res; } long long exp(long long x, long long y) { long long res = 1; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = (1LL << 21) + 10; int N, T, len, Imakf, bits[MAXN]; long long a[MAXN], b[MAXN]; char tem[MAXN]; void fi(const char* tem) { if (!strlen(tem)) return; char A[50]; const char B[4] = { . , i , n , 0}, C[5] = { . , o , u , t , 0}; ...
#include <bits/stdc++.h> using namespace std; const long long mx = 1e5 + 10; long long n, m, a[mx], cnt[mx], r[mx], l[mx], p[mx], ans[mx]; int main() { cin >> n >> m; for (long long i = 1; i <= n; i++) { cin >> a[i]; if (a[i] < mx) cnt[a[i]]++; } for (long long i = 0; i < m; i++) cin...
#include <bits/stdc++.h> using namespace std; long long int m; long long int power(long long int x, long long int y) { long long int res = 1; while (y > 0) { if (y & 1) res = res * x; res %= m; y = y >> 1; x = x * x; x %= m; } return res; } long long int inv(long ...
// *************************************************************************** // *************************************************************************** // Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved. // // In this HDL repository, there are many different and unique modules, consisting // of...
#include <bits/stdc++.h> using namespace std; char table[500 + 10][500 + 10]; int vis[500 + 10][500 + 10]; int n, m; int dirr[4] = {1, -1, 0, 0}; int dirc[4] = {0, 0, 1, -1}; vector<tuple<int, int, int> > ans; int dfs(int i, int j, int depth) { if (i < 0 || i >= n || j < 0 || j >= m) return 0; i...
// 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 `ifdef TEST_VERBOSE `define WRITE_VERBOSE(args) $write args `else `define WRITE_VERBOSE(args) `endif mo...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int x = sqrt(a * c / b), y = sqrt(a * b / c), z = sqrt(b * c / a); cout << (x + y + z) * 4; return 0; }
#include <bits/stdc++.h> using namespace std; char s[601000]; long long m; long long ans = 0; long long len; long long ll; long long mod = 1; long long reget(long long x) { long long reans = (10 * (ll - ((long long)(s[x] - 0 ) * mod) % m + m) % m + (long long)(s[x] - 0 ) + m...
#include <bits/stdc++.h> using namespace std; void add(long long &a, long long b) { a += b; if (a >= (233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 + 23333 * 7 + 2333 + 233 * 4 + 23 * 3 + 2 + 2 + 2 + 3 + 3 + 3)) { a -= (233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 + ...
//------------------------------------------------------------------------- // COPYRIGHT (C) 2016 Univ. of Nebraska - Lincoln // // 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 ve...
/* * 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() { map<char, string> mp = {{ > , 1000 }, { < , 1001 }, { + , 1010 }, { - , 1011 }, { . , 1100 }, { , , 1101 }, { [ , 1110 }, { ] , 1111 }}; string in; cin >> in; string s; for ...
#include <bits/stdc++.h> using namespace std; int n; int mh, currx = 1, level[110], l = 0; char sc[110]; char mas[4 * 110][4 * 110]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> sc[i]; if (sc[i] == [ ) { l++; level[i] = l; } else { level[i] ...
#include <bits/stdc++.h> using namespace std; void solve() { vector<long long> v, ans; long long n; cin >> n; for (long long i = 0; i < n; i++) { long long q; cin >> q; v.push_back(q); } sort(v.begin(), v.end()); bool cur = 0; while (!v.empty()) { if (!cur) { ...
`timescale 1ns/1ps ////////////////////////////////////////////////////////////////////////////////// //Company: //Engineer: // //CreateDate:15:24:1809/10/2015 //DesignName: //ModuleName:VGA_test //ProjectName: //TargetDevices: //Toolversions: //Description: // //Dependencies: // //Revision: //Revision0.01-FileCreated ...
#include <bits/stdc++.h> using namespace std; set<int> st[200000 + 7]; set<int>::iterator it; vector<int> graph[200000 + 7], edge[200000 + 7]; pair<int, int> edges[200000 + 7], path[200000 + 7]; int sid[200000 + 7], prio[200000 + 7], pr_id, can[200000 + 7], neg[200000 + 7], rev[200000 + 7]; long lon...
/* Copyright (c) 2014-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, distri...
/** * bsg_fpu_classify.v * * in the spirit of RISC-V FCLASS instruction. * * o[0] = neg infty. * o[1] = neg normal number * o[2] = neg subnormal number * o[3] = neg zero * o[4] = pos zero * o[5] = pos subnormal number * o[6] = pos normal number * o[7] = pos infty * o[8] = sig nan * o[9] = quit...
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1; else v = (c & 15); while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15); x = v * f;...
/** * 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 500ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10/05/2015 01:48:32 PM // Design Name: // Module Name: pwm_tb // Project Name: // Target Devices: // Tool Versions: // Description: // // D...
#include <bits/stdc++.h> long long int MOD = 1000000007; using namespace std; template <class T> inline void sary(T* st, T* nd) { while (st < nd) cin >> *st++; } template <class T> inline double sarys(T* st, T* nd, T sum) { while (st < nd) { cin >> *st++; sum += *st; } return s...
#include <bits/stdc++.h> using namespace std; bool solve() { char s[500]; if (scanf( %s , s) == EOF) return false; int in = 0, out = 0; for (int i = 0; s[i]; ++i) { if (s[i] == + ) { if (out) { out--; in++; } else { in++; } } else { ...