text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int maxn = (int)(1e5) + 5; int l[maxn], r[maxn]; int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> l[i] >> r[i]; sort(l + 1, l + n + 1); sort(r + 1, r + n + 1); long long ret = n; for...
#include <bits/stdc++.h> template <class T1, class T2> inline bool cmin(T1 &a, const T2 &b) { return b < a ? (a = b, true) : false; } template <class T1, class T2> inline bool cmax(T1 &a, const T2 &b) { return a < b ? (a = b, true) : false; } template <class Type> Type read() { Type a; b...
#include <bits/stdc++.h> using namespace std; int main() { char com[200]; char *p; int man = 0; int sum = 0; int i; int word; while (scanf( %c , com) == 1) { i = 1; while ((com[i] = getchar()) != n ) i++; com[i] = 0 ; word = 0; if (com[0] == + ) { ...
#include <bits/stdc++.h> int main(void) { double a, v, l, d, w, t = 0; scanf( %lf%lf%lf%lf%lf , &a, &v, &l, &d, &w); if (2 * a * d <= w * w || w >= v) { if (l * a * 2 >= v * v) { t += v / a; t += (l - v * v / (2 * a)) / v; } else { t += sqrt(2 * l / a); } } el...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> v) { os << ( << v.first << , << v.second ...
//Shrey Dubey #include<iostream> #include<string> #include<algorithm> #include<map> #include<unordered_map> #include<vector> #include<set> #include<list> #include<iomanip> #include<queue> #include<stack> #include <math.h> #include<climits> #include<bitset> #include<cstring> #...
#include <bits/stdc++.h> using namespace std; signed long long p[1000005] = {0}; void sieve() { p[0] = 1; p[1] = 1; for (signed long long i = 2; i * i <= 1000000; i++) { if (p[i] == 0) { for (signed long long j = 2 * i; j <= 1000000; j = j + i) p[j] = 1; } } } int main() { ...
module SysPLL( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire sdr_clk, // interface 'outclk1' output wire sys_clk, // interface 'outclk2' output wire vga_clk, output wire pit_clk, // interface 'locked' output wire locked ); ...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; long long power(long long a, long long b) { if (b == 0) return 1; else if (b == 1) { return a; } else if (b & 1) { return (a % mod * power((a % mod * a % mod) % mod, b / 2)) % mod; } else { retur...
#include <bits/stdc++.h> using namespace std; const int maxn = 2000010; int main() { int len, cnt; char s, d, st[maxn], word[26]; cin >> len >> cnt; cin >> st; for (int i = 0; i < 26; ++i) { word[i] = a + i; } for (int i = 1; i <= cnt; ++i) { cin >> s >> d; if (s ==...
/* * 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) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module gpac_adc_rx_core #( parameter ABUSWIDTH =...
/** * bsg_nonsynth_mem_1rw_sync_mask_write_byte_assoc.v * * bsg_mem_1rw_sync_mask_write_byte implementation using associative array. * * This is for simulating arbitrarily large memories. * */ `include "bsg_defines.v" module bsg_nonsynth_mem_1rw_sync_mask_write_byte_assoc #(parameter `BSG_INV_PARAM(data_...
/*---------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )       ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ --------------------------------------------------------------*/ #include<bits/stdc++.h> #d...
/** * 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...
// tb200.v - A WCI::OCP test bench with BFM, DUT, and Monitor/Observer // Copyright (c) 2010 Atomic Rules LLC - ALL RIGHTS RESERVED // // This testbench instances three components, and provides them with a common clock and reset // These three components are connected together with the WCI0_ signal group // 1. A BFM "I...
#include <bits/stdc++.h> using namespace std; const int N = 305; const int inf = 0x3f3f3f3f; const double eps = 1e-5; int n, c; int dp[605][N][N], a[N][N]; int max(int a, int b, int c, int d) { return max(max(a, b), max(c, d)); } int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; void file() { freopen( alost.in , r , stdin); freopen( output.txt , w , stdout); } bool ar[10000005]; void sieve() { ar[0] = ar[1] = 1; for (long long i = 2; i * i <= (int)1e7; i++) if (!ar[i]) for (...
#include <bits/stdc++.h> using namespace std; bool prime[1500000 + 10]; bool a[1500000 + 10]; int func(int N, int x) { int i, ans = 0; if (x == 2) return 0; if (a[1]) return 1; if (x >= 1500000) return -1; for (i = 2; i <= x - 1; i++) if (prime[i]) if (a[i]) ans++; ...
// (C) 2001-2011 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; const int N = 2e5 + 5; long long a[N], b[N]; void add(int l, int r, int val) { if (l > r) return; b[l] += val; b[r + 1] -= val; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> 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 la...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
//UART FIFO /* 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 u...
#include <bits/stdc++.h> using namespace std; struct node { int x, y; }; vector<node> answer; int dis[1000005], a[1000005], pre[1000005]; bool prime[1000005]; void getprime() { for (int i = 2; i < 1000005 - 5; i++) { if (!prime[i]) { for (int j = i * 2; j < 1000005 - 5; j += i) { ...
/** \file "interleave-c.v" Chain a bunch of inverters between VPI/VCS and prsim, shoelacing. Added inverters in prsim to check for proper event interleaving. $Id: interleave-c.v,v 1.3 2010/04/06 00:08:33 fang Exp $ */ `timescale 1ns/1ps `include "clkgen.v" module timeunit; initial $timeformat(-9,1," ns",9);...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017 // Date : Wed Sep 20 21:28:52 2017 // Host : EffulgentTome running 64-bit major rele...
#include <bits/stdc++.h> using namespace std; int n, m; int main() { scanf( %d%d , &n, &m); while (n--) { int a, b, t, ans; scanf( %d%d%d , &a, &b, &t); if (a == b) { printf( %d n , t); continue; } int d = t / (m - 1); ans = d * (m - 1); if (d % 2 ...
#include <bits/stdc++.h> using namespace std; const int N = 5010; const int mod = 1e9 + 7; const long long INF = 1e15; int nex[N]; long long x[N], a[N], b[N], c[N], d[N]; int main() { int n, s, e; while (~scanf( %d%d%d , &n, &s, &e)) { nex[s] = e; for (int i = 1; i <= n; i++) scanf( %I...
/* * These source files contain a hardware description of a network * automatically generated by CONNECT (CONfigurable NEtwork Creation Tool). * * This product includes a hardware design developed by Carnegie Mellon * University. * * Copyright (c) 2012 by Michael K. Papamichael, Carnegie Mellon University * * ...
#include <bits/stdc++.h> using namespace std; static inline void canhazfast() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T extgcd(T a, T b, T &x, T &y) { ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/06/15 23:06:33 // Design Name: // Module Name: Chip_Decoder // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // ...
`timescale 1ns / 1ps /** Pipelined CPU */ module pipeline ( input wire clk, input wire rst, output i_read_en, output [31:0] i_addr, input [31:0] i_instr_in, input wb_...
#include <bits/stdc++.h> using namespace std; const int max_n = 105; int n; int a[max_n]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); vector<int> V; sort(a, a + n); for (int nb = 1; nb <= n; nb++) { V.clear(); for (int i = 0; i < nb; i++) V.pus...
// megafunction wizard: %RAM: 2-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: twiddle_ram.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ============================...
#include <bits/stdc++.h> using namespace std; int mn[200010 * 4], lazy_value[4 * 200010]; bool lazy[4 * 200010]; void update_node(int idx, int st, int ed, int val) { lazy[idx] = 1; lazy_value[idx] += val; mn[idx] += val; } void update_lazy(int idx, int st, int ed) { if (st == ed) return; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// //deco que pasa de BCD a la salida del display, cada caso es la salida module bcd_to_display( input clk, input rst, input [3:0] BCD, output reg[7:0] DISPLAY ); initial begin DISPLAY = 8'b11111111; ...
#include <bits/stdc++.h> using namespace std; struct edge { int v, c, i, d; edge(int v, int c, int i, int d) : v(v), c(c), i(i), d(d) {} }; vector<vector<edge> > g(200005); int n, m, d[200005], f[200005]; int main() { cin >> n >> m; for (int _n = m, i = 0; i < _n; ++i) { int a, b, c; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 6; int n, l, r, h[N], b[N], ans[N], S; vector<int> X, Y; int main() { scanf( %d%d%d , &n, &l, &r); for (int i = 1; i <= n; ++i) scanf( %d , h + i), S += h[i]; for (int i = 1; i <= n; ++i) scanf( %d , b + i); int _l = S - r, _r =...
#include <bits/stdc++.h> using namespace std; const long long N = 1e18; const long long mod = 1e9; long long dp[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t = 1; cin >> t; while (t--) { long long n, k; cin >> n >> k; ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2004 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; reg [31:0] wr_data; reg wr_en; wire [31:0] rd_d...
#include <bits/stdc++.h> const int maxn = 1e2 + 10; const int dis[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}}; using namespace std; long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); } long long qpow(long long p, long long q) { long long f = 1; while (q) { if (q & 1) 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...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using u64 = uint64_t; using u32 = uint32_t; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vpi = vector<pi>; static conste...
#include <bits/stdc++.h> using namespace std; int main() { { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }; long long t; cin >> t; while (t--) { long long a, b, n, s; cin >> a >> b >> n >> s; bool ans = false; long long f = s / n; ...
#include <bits/stdc++.h> using namespace std; const int M = 2e5 + 5; vector<int> G[M]; int n, A[M], num, ok, res, ans[2][M], C; bool mark[M]; void ma(int a, int b) { if (a == b || mark[a] && mark[b]) return; printf( %d %d n , a, b); ans[0][C] = a; ans[1][C] = b; C++; mark[a] = mark[b...
`include "assert.vh" module cpu_tb(); reg clk = 0; // // ROM // localparam MEM_ADDR = 4; 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_bound = ~0; wire [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 la...
#include <bits/stdc++.h> using namespace std; string s[102]; int main() { int n, i, cnt[27], j, k; cin >> n; for (i = 0; i < n; i++) cin >> s[i]; int ans = 0, temp, first, second, x, r; for (i = 1; i <= 26; i++) { for (j = 1; j <= 26; j++) { temp = 0; for (k = 0; k < n; k...
// -- (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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Adam LLC // Engineer: Adam Michael // // Create Date: 15:35:33 09/12/2015 // Design Name: Truth table implementation of 4:3 encoder. // Module Name: encoder43table ////////////////////////////...
/* * 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 n, m, Q, ans[100005], t[265000]; vector<int> v[100005]; vector<pair<int, int> > vq[100005]; void build(int k, int l, int r) { t[k] = 1e9; if (l == r) return; int mid = (l + r) / 2; build(k * 2, l, mid); build(k * 2 + 1, mid + 1, r); } v...
#include <bits/stdc++.h> using namespace std; int t, n, m, k, a, b, ans; int maxl = 1e9; int num[300005]; int main() { scanf( %d , &t); while (t--) { scanf( %d%d%d , &n, &m, &k); if (m <= k) k = m - 1; a = n - m + 1; b = n - k; for (int i = 1; i <= n; i++) { scanf...
#include <bits/stdc++.h> class MapValue { public: std::string configuration; int s1; MapValue() {} MapValue(std::string configuration, int s1) : configuration(configuration), s1(s1) {} }; class PairHash { public: std::size_t operator()(const std::pair<int, int> &p) const { ...
// megafunction wizard: %RAM: 2-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: uart_fifo_dual_port_ram.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long Inv[1000005]; void inv(int n) { Inv[1] = 1; for (int i = 2; i <= n; i++) { Inv[i] = (mod - mod / i * Inv[mod % i] % mod) % mod; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; ...
#include <bits/stdc++.h> using namespace std; int d1, d2, d3; int r; int main() { cin >> d1 >> d2 >> d3; r = d1 + d2 + d3; r = min(r, d1 + d1 + d2 + d2); r = min(r, d1 + d3 + d1 + d3); r = min(r, d2 + d3 + d2 + d3); cout << r << n ; }
#include <bits/stdc++.h> using namespace std; int n; long long K; vector<int> E[200000 + 5]; void addEdge(int u, int v) { E[u].push_back(v); E[v].push_back(u); } int sz[200000 + 5], deep[200000 + 5], fa[200000 + 5]; int msz[200000 + 5], root; void dfs1(int x, int f) { sz[x] = 1; msz[x]...
module top( input PACKAGEPIN, output [1:0] PLLOUTCORE, output [1:0] PLLOUTGLOBAL, input EXTFEEDBACK, input [7:0] DYNAMICDELAY, output LOCK, input BYPASS, input RESETB, input LATCHINPUTVALUE, //Test Pins output SDO, input SDI, input SCLK ); SB_PLL40_2_PAD #( .FEEDBACK_PATH("DELAY"), ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19.02.2016 18:21:15 // Design Name: // Module Name: toplevelv // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Rev...
#include <bits/stdc++.h> using namespace std; long long MOD_EXPO(long long b, long long p, long long m) { if (p == 0) return 1; long long ret = MOD_EXPO(b, p / 2, m) % m; ret = (ret * ret) % m; return ((p & 1) ? (ret * b) % m : ret % m); } long long POWER(long long N, long long K) { long lon...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int a; priority_queue<long long int> o, e; for (long long int i = 0; i < n; i++) { cin >> a; if (a % 2 == 0) e.push(a); else o.push(a); } if (e.size() == o.si...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if (c <= b / 2 && c <= a / 2) cout << First ; else cout << Second ; }
/** * 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 test; reg fail = 1'b0; reg [3:0] bus = 4'b0; initial begin // Check the initial value. if (bus !== 4'b0) begin $display("FAILED: initial value, got %b, expected 0000.", bus); fail = 1; end // Check a bit force and verify a normal bit assign does nothing. #1 force bus[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; vector<pair<int, int> > v, a; vector<pair<double, int> > ans; int n, sum, del, sx, sy, x, y, Nx, Ny; set<int> u; int cmp(pair<int, int> a, pair<int, int> b) { return ((a.first) * (a.first)) + ((a.second) * (a.second)) < ((b.first) * (b.first)) + (...
module ram0( // Write port input wrclk, input [63:0] di, input wren, input [8:0] wraddr, // Read port input rdclk, input rden, input [8:0] rdaddr, output reg [63:0] do); (* ram_style = "block" *) reg [63:0] ram[0:511]; genvar i; generate for (i=0; i<1024; i...
// Copyright 2012 Sriram Radhakrishnan, Varun Sampath, Shilpa Sarode // // This file is part of PVS. // // PVS 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 ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10, INF = 2147483647; int a[MAXN]; int main() { int T, n, i, res = 0; scanf( %d , &T); while (T--) { res = 0; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); int e...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-10; const long double INF = (int)1e9 + 34; const int N = (int)1e6 + 34; void ret(int x) { cout << x; exit(0); } int n, k; int a[N]; int b[N], len; bool u[N]; int main() { scanf( %d%d , &n, &k); for (int i = 0;...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse4 ) using namespace std; constexpr long long mod = 1000000007; const long long INF = mod * mod; const double eps = 1e-12; const double pi = acosl(-1.0); long long mod_pow(long long x, long long n, long long m = mod) { long...
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009, 2010 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 distri...
/** * 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: 22:44:18 09/23/2013 // Design Name: // Module Name: FSM // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Rev...
#include <stdio.h> #include <stdlib.h> #define N 200000 #define Q 100000 #define N_ ((N + Q * 2) * (LG + 1)) #define LG 20 #define B (1 << LG) int ll[1 + N_], rr[1 + N_], sz[1 + N_], msk0[1 + N_], msk1[1 + N_], lz[1 + N_], _ = 1; void put(int u, int lg, int x) {int tmp, x0, x1;if (u == 0)return;if ((x &...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:13:58 04/26/2015 // Design Name: // Module Name: HallwayRight // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; template <typename Bp, typename Ep, typename Mp> inline Mp __powMod(Bp a, Ep b, const Mp &m) { a %= m; Mp res = 1; while (b > 0) { if (b & 1) { res = ((long long)res * a) % m; } a = ((long long)a * a) % m; b >>= 1; } ...
#include <bits/stdc++.h> using namespace std; long long INF = (1e15) + 1; int n, dp[100004], par[100004]; long long d, arr[100004]; struct Node { Node *leftNode, *rightNode; long long leftBound, rightBound; pair<int, int> mx; Node() { leftNode = rightNode = NULL; leftBound = rightB...
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); int a[200001]; int i; for (i = 0; i < n; i++) { scanf( %d , &a[i]); } long long buy = a[n - 1]; int pre = a[n - 1]; for (i = n - 2; i >= 0; i--) { if (a[i] >= pre - 1) { if (pre - 1 == 0) br...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
module axi_generic_adc ( input adc_clk, output [NUM_CHANNELS-1:0] adc_enable, input adc_dovf, input s_axi_aclk, input s_axi_aresetn, input s_axi_awvalid, input [31:0] s_axi_awaddr, output s_axi_awready, input s_axi_wvalid, input [31:0] s_axi_wdata, input [ 3:0] s_axi_wstrb, output s_axi_wready, o...
`timescale 1 ns / 1 ps /******************************************************************************* * DescriPixtion: Compute pixel value based on context * Latency: 800*1.5 ******************************************************************************/ module lbp #( parameter CTX_SIZE = 3,...
#include <bits/stdc++.h> using namespace std; int main() { short n, before, after; cin >> n; string a; bool flag = false; for (short i = 0; i < n; i++) { cin >> a; cin >> before; cin >> after; if (after >= 2400 && before >= 2400 && after - before > 0) flag = true; } ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const long long MOD = 998244353; struct node { int v; node *d, *r; }; node a[1050][1050]; long long n, m, q; void solve() { cin >> n >> m >> q; for (int i = (int)(1); i <= (int)(n); i += 1) { for (int j = (in...
#include <bits/stdc++.h> using namespace std; long long red[210]; long long green[210]; long long blue[210]; long long dp[210][210][210]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int r, g, b; cin >> r >> g >> b; for (int i = 1; i <= r; i++) cin >> red[i]; for (int i ...
// Copyright (c) 2015 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...
#include <bits/stdc++.h> using namespace std; int n, m, p, l, r, cnt[600000], lg[600000], sum[600000], pre[600000][30], f[600000], g[600000]; bool cov[600000 << 6]; char s[600000]; struct Hash { const long long B1 = 233, mod1 = 998244353, B2 = 377, mod2 = 1000000007; long long h1[600000], pw1[60...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); vector<vector<int>> x(m + 1, vector<int>(n + 1)); for (int i = 1; i <= n; i++) { int k; scanf( %d , &k); for (int j = 1; j <= m; j++) { x[j][i] = x[j][i - 1]; if (j == k) { ...
#include <bits/stdc++.h> using namespace std; int charToDec(char c) { if ((c >= 0 ) && (c <= 9 )) return c - 0 ; if ((c >= A ) && (c <= Z )) return c - A + 10; } char decToChar(int c) { if ((c >= 0) && (c <= 9)) return c + 0 ; if ((c >= 10) && (c <= 26)) return c + A - 10; } long l...
`include "DC_define.v" `include "logfunc.h" `include "scmemc.vh" module DC_1_tagcheck #(parameter Width = 15, Size =256, Forward=0, REQ_BITS=7) //tag 10+counter 2+states 3 =15//29 bits virtual adress ( input clk ,input reset ,input ...
#include <bits/stdc++.h> using namespace std; bool compare(const int &a, const int &b) { return a < b; } int main() { int n; cin >> n; int i = 0; double aux = 0; while (n >= aux) { aux = (1.0 / 6.0) * (i) * (i + 1) * (i + 2); i++; } cout << i - 2 << endl; return 0; } ...
/*████████████████████████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████████████████████████ ███████████████████████████▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓███████████████████████ ███████████████████████████▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███...
#include <bits/stdc++.h> using namespace std; long long T, A, B, res; vector<long long> P; int main() { cin >> T >> A >> B; if (T == 1) { if (A == 1) { if (B == 1) { res = -1; } } else { if (B % A == 0) { ++res; } while (B > 0) { ...
#include <bits/stdc++.h> int n; int a[(200010) << 1], b[(200010) << 1]; int pa[(200010) << 1], sa[(200010) << 1]; int pb[(200010) << 1], sb[(200010) << 1]; struct node { int x, y; } p[(200010)]; long long solve(int t) { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); memset(pa, 0, sizeof...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Jafet Chaves Barrantes // // Create Date: 16:24:58 05/12/2016 // Design Name: // Module Name: keycode_to_ascii // Project Name: // Target Devices: // Tool versions: // Descripti...
/** * 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 MOD = 1000000007; const int UNDEF = -1; const long long INF = 1e18; template <typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; } template <typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ?...