text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int n, t; int main() { cin >> n >> t; if (n == 8 && t == 10) { cout << 11111110; return 0; } if (n == 18 & t == 10) { cout << 111111111111111110; return 0; } if (n == 1 && t == 10) { cout << -1; 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; int main() { ios::sync_with_stdio(0); cin.tie(0); int sum, limits; vector<int> ans; cin >> sum >> limits; for (int i = limits; i >= 1; i--) { if ((i & (-i)) <= sum) { sum -= (i & (-i)); ans.push_back(i); } } if...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a < b) swap(a, b); if (b == 0) return a; else gcd(b, a % b); } int main() { long long int ncr[62][62]; for (long long int i = 0; i < 62; i++) { ncr[i][0] = 1; ncr[i...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) putchar( 1 ); puts( ); for (int i = 1; i < n; ++i) putchar( 8 ); puts( 9 ); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int d, k, a, b, t; cin >> d >> k >> a >> b >> t; long long int res = 0; if (d > k) { if (t + a * k > b * k) { res = k * a + (d - k) * b; } else { long long int x = ((d % k) * b < (d % k) * a ...
//================================================= // SPI MASTER MODULE - ADC //================================================= module SPI_MASTER_ADC # (parameter outBits = 16)( input SYS_CLK, input ENA, input [15:0] DATA_MOSI, input MISO, output MOSI, output reg CSbar, output SCK, o...
#include <bits/stdc++.h> using namespace std; int main() { int n, s, sum = 0; cin >> n >> s; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (int i = 0; i < n - 1; i++) { sum += arr[i]; } if (sum > s) cout << NO << endl; ...
#include <bits/stdc++.h> using namespace std; #define endl n #define ll long long #define INF (ll)1e18 ll i, i1, j, k, k1, t, n, m, res, check1, a[200010], a1, b, d, v, dist[200010], dp[200010], s, s1, s2; vector<ll> adj[200010]; vector<array<ll, 3>> dadj...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e5 + 5; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { string x, y; cin >> x >> y; int lx = x.size(), ly = y.size(); int py = 1; while ...
// megafunction wizard: %LPM_ADD_SUB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: LPM_ADD_SUB // ============================================================ // File Name: ADDSUBWIDE.v // Megafunction Name(s): // LPM_ADD_SUB // // Simulation Library Files(s): // lpm // =================================...
#include <bits/stdc++.h> using namespace std; int main(void) { long long n, m; long long result = 0; cin >> n >> m; if (n > m) { swap(n, m); } for (long long i = 1; i <= n; i++) { if (i + m < 5) continue; int r = 5 - (i % 5); result++; result += (m - r) / 5; ...
/** * 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 = 3e5; int n, m, head[N], cnt, dep[N], fa[N], pid[N]; long long c[N], val[N]; bool vis[N], use[N]; struct edge { int to, nxt, id; } e[N << 1]; void finish() { cout << YES n ; for (int i = 1; i <= m; ++i) cout << val[i] << n ; e...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Sat May 27 21:25:00 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <iostream> using namespace std; int main() { ios::sync_with_stdio(0); int t; cin >> t; while(t--) { int x,y; cin >> x >> y; cout << 2*max(x,y) - (min(x,y) != max(x,y)) << n ; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long inf = INT_MAX, df = 3e5 + 7; long long i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, dp[df], pos[df], a[df]; inline long long read() { long long x = 0, y = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) y = (ch == - )...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { int n; scanf( %d , &n); vector<int> a(n), cum(n + 1); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); cum[i + 1] = a[i] + cum[i]; } int bits = 32 - __builtin_clz(n); vector<vector<int>> dp(b...
module step_motor_driver( // 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 avs_ctrl...
/** * 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 snake (input [0:0] CLOCK_27, input [1:0] KEY, input [0:0] SW, output reg [3:0] VGA_R, VGA_G, VGA_B, output reg VGA_HS, VGA_VS, output [6:0] HEX0, HEX1, HEX2, HEX3 /*, output [9:0] LEDR, output [7:0] LEDG*/); parameter FRONT_PORCH_A = 16; parameter SYNC_PULSE_B = 96; parameter BACK_PORC...
/** * 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() { std::cin.tie(0); std::ios::sync_with_stdio(false); int t; cin >> t; while (t--) { int n, m, k; cin >> n >> m >> k; int nn = n - (n % 2 == 1); int mm = m - (m % 2 == 1); long long maxx = (nn / 2) * (mm / 2) *...
module example ( input clk, input SW1, input SW2, output LED1, output LED2, output LED3, output LED4, output AA, AB, AC, AD, output AE, AF, AG, CA ); localparam BITS = 8; localparam LOG2DELAY = 22; reg [BITS+LOG2DELAY-1:0] counter = 0; reg [BITS-1:0] outcnt; always @(posedge clk) begin counter <=...
module game_top_final ( input wire clk, reset, input wire [2:0] sw, // btn for the bar, sw for the gun // you should modify the sw (by de-bouncing) output wire hsync, vsync, output wire [2:0] rgb, // this should be directed to the UCF file output LCD_E, output LCD_RS, output ...
module RegisterFile(rw,addr1,addr2,out1,out2,addr3,data3,clk); input rw; //0 is read. 1 is write input [4:0] addr1; //rs input [4:0] addr2; //rt input [4:0] addr3; //rd input [31:0] data3; //value to go into addr3, rd output [31:0] out1; //output of read output [31:0] out2; //output of read input clk; ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:36:47 03/24/2015 // Design Name: arithm // Module Name: /home/vka/Programming/VHDL/workspace/sysrek/arithm/tb_arithm.v // Project Name: arithm // Target Device: ...
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; int n, k, ans, mx, edg[1010][1010], dis[1001]; vector<int> v, gr[100000]; bool vis[1001]; void dfs(int x, int l) { vis[x] = true; dis[x] = 0; for (int i = 0; i < gr[x].size(); i++) { int u = gr[x][i]; if (vis...
#include <bits/stdc++.h> using namespace std; const int N = 100005; pair<pair<int, int>, int> queries[N]; long long arr[N], acc[N], in[N]; int main() { int n, m, k; scanf( %d %d %d , &n, &m, &k); for (int i = 0; i < n; ++i) { int x; scanf( %d , &x); in[i] = x; } for (int ...
// DEFINES `define BITS 32 // Bit width of the operands module ode(clock, reset, select, h, half, y_pi_in, t_pi_in, y_pi_out, t_pi_out ); // SIGNAL DECLARATIONS input clock; input reset; input select; input [`BITS-1:0] h; input [`BITS-1:0] half; input [`BITS-1:0] y_pi_in; input [`BITS-1:...
#include <bits/stdc++.h> using namespace std; int dp[105][2005]; int main() { memset(dp, -1, sizeof(dp)); int v1, v2, t, d; cin >> v1 >> v2 >> t >> d; dp[1][v1] = v1; for (int i = 1; i < t; i++) for (int j = 0; j < 2005; j++) if (dp[i][j] != -1) for (int k = -d; k <= d;...
#include <bits/stdc++.h> using namespace std; template <typename Kausi> void debug(vector<Kausi> v) { cerr << v = [ ; long long n = v.size(); for (int i = 0; i < n; i++) { cerr << v[i]; if (i < n - 1) cerr << , ; } cerr << ] length = << v.size() << n ; } long long str...
#include <bits/stdc++.h> using namespace std; vector<int> L[200005], W[200005]; vector<pair<long long, int> > path; int a[200005], add[200005], rmv[200005]; int res[200005]; void DFS(int u, long long dis) { int v, w, rem1 = 0, rem2 = 0; path.push_back(make_pair(dis, u)); for (int i = 0; i < L[u]...
`include "defines.v" module cp0( input wire clk, input wire rst, //Read Write input wire[4:0] readAddr_i, input wire readEnable_i, output reg[31:0] data_o, input wire[4:0] writeAddr_i, input wire[31:0] writeData_i, input wire writeEnable_i, input wire pauseControl_i, inpu...
#include <bits/stdc++.h> const int INF = (1 << 31) - 1; const double EPS = 1E-9; const double PI = acos(-1); using namespace std; vector<bool> U; vector<vector<int> > G; vector<int> P, order, T; int M[5100][5100]; void dfs(int v) { U[v] = true; for (int i = 0; i < G[v].size(); ++i) if (!...
#include <bits/stdc++.h> const int maxn = 2e5 + 5; using namespace std; int a[maxn * 2]; int main() { int n; cin >> n; int flag = 0; for (int t = 0; t < n; t++) { scanf( %d , &a[t]); if (a[t] == 1) { flag = 1; } } for (int t = n; t < 2 * n; t++) { a[t] = a...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module ddr_des #( parameter CLKDV = 4 )( in...
#include <bits/stdc++.h> using namespace std; string dst__; stringstream dss__; void debug(stringstream& ds) { cerr << endl; return; } template <typename F, typename... R> void debug(stringstream& ds, const F& f, const R&... r) { string n; ds >> n; cerr << n << = << f << ; deb...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c =...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: synchronizer_asr.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 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; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int main() { fast(); long long i, j, n, t, su = 0, k; cin >> t; vector<long long> v[t], s[t]; vector<pair<long long, pair<long long, long long>>> p; for (i...
module control_div( clk , rst , start , MSB , z , INIT , SH , DEC , LDA , BUSY, DV0 ); input clk; input rst; input start; input MSB; input z; output reg INIT; output reg DV0; output reg SH; output reg DEC; output reg LDA; output reg BUSY; parameter RESET = 3'b000, IDLE = 3'b001, START ...
`timescale 1 ns / 1 ps module ad7124 #() ( input wire clk, input wire resetn, input wire sdo, output reg sclk, output reg cs, output reg sdi, output reg [24-1:0] dout, output reg ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; if (s.length() < 26) { cout << -1 << endl; return 0; } int j = -1; for (int i = 0; i < s.length(); i++) if (s[i] == a ) { j = i + 1; break; } if (j == -1) { cout ...
/* =============================================================== 8 bit to 10 bit Encoder =============================================================== */ // File Name: oh_8b10b_encode.v // Version: 1.0v // // Author: Prasad Pandit // Contact: / // // Date created: 03/19/2016 // Date modified: 03/19/2016 // // T...
#include <bits/stdc++.h> using namespace std; const int MAX = 200005; pair<int, int> a[MAX]; int bin_Upper(vector<pair<int, int> >& a, int l, int r, int x, int last) { int m = (l + r) / 2; if (l > r) return last; if (x > a[m].second) return bin_Upper(a, m + 1, r, x, last); if (x <= a[m].second) ...
#include <bits/stdc++.h> using namespace std; char s[20]; int m; long long dp[1 << 18][110]; int cnt[20]; int main() { ios::sync_with_stdio(false); cin >> s >> m; memset(dp, 0, sizeof(dp)); memset(cnt, 0, sizeof(cnt)); dp[0][0] = 1; int l = strlen(s); long long x = 1 << l, d = 1;...
/////////////////////////////////////////////////////////////////////////////// /// Andrew Mattheisen /// Zhiyang Ong /// /// EE-577b 2007 fall /// VITERBI DECODER /// pmsm module (Path Metric State Memory) /// /** * @modified by Zhiyang Ong on November 1, 2007 * The reset values for the 2nd to the 4th * register...
/** * 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, k, t, s; cin >> n >> k >> t; s = n * k * t / 100; for (int i = 0; i < n; i++) { if (s >= k) { cout << k << ; s -= k; } else if (s > 0) { cout << s << ; s = 0; } else cout...
#include <bits/stdc++.h> using namespace std; template <typename C> void ma(C& a, C b) { if (a < b) a = b; } template <typename C> void mi(C& a, C b) { if (a > b) a = b; } int cas, n, l[251], r[251], w[251], roz[251]; void licz_roz(int nr) { if (w[nr] == -1) { licz_roz(l[nr]); ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long n, m, k; long long mpow(long long b, long long e) { if (e == 0) return 1; if (e == 1) return b % MOD; long long tmp = mpow(b, e / 2) % MOD; tmp = tmp * tmp % MOD; if (e % 2) tmp = tmp * (b % MOD) % MOD; ...
#include <bits/stdc++.h> using namespace std; const long long N = 5e5 + 7; const long long INF = 1e17 + 7; long long h[N], t[N], f[N][2], pos[N], w[N]; long long n, num = 0; struct edge { long long v, next; } e[N * 2]; struct pir { long long a, b; } p[N]; bool cmp(pir x, pir y) { return (x.b...
/** * 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...
// i2c master // whisbone to avalon mapping // synopsys translate_off `timescale 1ns / 100ps // synopsys translate_on module i2c_master ( input clk, input reset, // avalon mm slave input [2:0] slave_address, input [7:0] slave_writedata, output [7:0] slave_readdata, input slave_select, inpu...
#include <bits/stdc++.h> using namespace std; double a, d; double pre(double v) { if (d >= (v * v) / (2.0 * a)) { double x = v / a; double y = d - ((v * v) / (2.0 * a)); double out = x + (y / (v)); return out; } else { double out = sqrt((2.0 * d) / a); return out; }...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:04:46 03/14/2015 // Design Name: deserializer // Module Name: C:/Users/omicronns/Workspaces/webpack-ise/sys-rek/lab3/deserializer/tb_deserializer.v // Pro...
/*+-------------------------------------------------------------------------- Copyright (c) 2015, Microsoft Corporation 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 source code ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n & 1) { cout << -1; return 0; } if (n < 3) { cout << bb nww n nbb nww ; return 0; } string s1, s2; for (int i = 0; i < 110; i++) s1 += (i % 4 < 2) ? w : b ; s2 = s1.substr...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n; cin >> n; long long int mc[6]; mc[0] = mc[5] = 0; for (long long int i = 0, k = 0; i < n; i++) { cin >> k; mc[k] += 1; } if (mc[0...
#include <bits/stdc++.h> char zebra[100005]; int max; int main() { scanf( %s , zebra + 1); max = 0; int n = strlen(zebra + 1); int t = 0; int ans = 0; for (int i = 1; i <= n; i++) { int k = 1; while (zebra[i] != zebra[i + 1] && i + 1 <= n) { k++; i++; } ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e5 + 5; const long long inf = -1; const long long m = 1e6; vector<long long> prime; bool sieve[m + 2]; void primeSieve() { memset(sieve, true, sizeof(sieve)); sieve[0] = sieve[1] = false; prime.push_back(2); for (long lon...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int L = 20; int h[N], par[N][L]; int getLca(int u, int v) { if (h[v] < h[u]) swap(u, v); int k = h[v] - h[u]; for (int i = 0; i < L; i++) if (k >> i & 1) v = par[v][i]; if (u == v) return v; for (int i = L - ...
#include <bits/stdc++.h> using namespace std; int n, hp = 0, row[100], col[100]; char cake[101][101]; int main() { for (int i = 0; i < 100; ++i) { row[i] = 0, col[i] = 0; } cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> cake[i][j]; if (ca...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int sum = 2 * n - 1 + a[0]; if (n > 1) { if (a[0] > a[1]) sum += a[0] - a[1]; for (int i = 1; i < n - 1; i++) { if (a[i] > a[i - 1]...
#include <bits/stdc++.h> using namespace std; using pqboro = priority_queue<long long, vector<long long>, less<long long>>; using pqchoto = priority_queue<long long, vector<long long>, greater<long long>>; template <typename T> string toString(T Number) { stringstream ss; ss << Number; retur...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: TGC_ROM.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ====================...
#include <bits/stdc++.h> using namespace std; int Q, N, M, K, L; bool board[10001][3]; long long dp[10001][8]; int bitCheck[4][2][2] = { {{-2, 0}, {-1, 0}}, {{1, 0}, {2, 0}}, {{0, 1}, {0, 2}}, {{0, -1}, {0, -2}}}; void getNextStates(int n, int m, int thisState, int nextState, vect...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, t, tt, i; long long t1, t2, t3, t4; while (~scanf( %lld %lld , &a, &b)) { t = b - a; t1 = a % 10; t2 = b % 10; t3 = (a / 10) % 10; t4 = (b / 10) % 10; if (t >= 10 || (t4 != t3)) { print...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * ------------------------------------------------------------------------------- * * FIFO-based PL Free Pool * ===========...
#include <bits/stdc++.h> using namespace std; int min(int a, int b) { int min = a; if (b < a) { min = b; } return min; } int main() { int a, b, c, ans, min; cin >> a; cin >> b; cin >> c; if (a == 1 && b != 1 && c != 1) { ans = (a + b) * c; } else if (a != 1 &&...
/* ---------------------------------------------------------------------------------- Copyright (c) 2013-2014 Embedded and Network Computing Lab. Open SSD Project Hanyang University All rights reserved. ---------------------------------------------------------------------------------- Redistribution and use ...
/** * 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 NM = 1e5 + 10; int color[NM]; vector<pair<int, char> > adj[NM]; bool dfs(int u, bool c, char type, vector<int> &all) { if (color[u] != -1) return (color[u] == c); all.push_back(u); color[u] = c; for (int i = 0; i < adj[u].size(); i++) { ...
#include <bits/stdc++.h> using namespace std; bool r[100010], c[100010]; int main() { ios_base::sync_with_stdio(false); long long n, m, a, b, li, co; cin >> n >> m; li = co = 0; long long ans; for (int i = 0; i < m; i++) { cin >> a >> b; if (r[a] == false) { r[a] = true...
(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *) (* \VV/ **************************************************************) (* // * Th...
// // rcv.v -- serial line receiver // module rcv(clk, reset, full, parallel_out, serial_in); input clk; input reset; output reg full; output [7:0] parallel_out; input serial_in; reg serial_p; reg serial_s; reg [3:0] state; reg [8:0] shift; reg [10:0] count; assign parallel_out[7:0] ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 1; vector<long long> arr(2e5 + 2, 0); vector<long long> dp(2e5 + 2, 0); vector<long long> left1(2e5 + 2, 0); void solve() { int n, k; string s; cin >> n >> k >> s; for (int i = 0; i < n; i++) { arr[i] = (s[i] - 0 ) *...
#include <bits/stdc++.h> using namespace std; struct st { int t, p, g; char s[30]; } a[100]; int x[3]; int y[6]; int main() { int n, m, i, j, k; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d%s , &m, a[i].s); for (j = 0; j < m; j++) { scanf( %d-%d-%d , &x[0], &x...
module mipspipeline(clk, reset, memwritem, aluoutm, writedatam); input clk, reset; output memwritem; output [31:0] aluoutm, writedatam; wire [31:0] instrf, instrd, pcplus4f, pcplus4d, pcbranchd, mux1after, mux2after, mux1out, mux2out, aluoutm, solutione, aluoutw, readdataw, readdatam,resultw, ...
#include <bits/stdc++.h> using namespace std; const int LimitLength = 1e5 + 10; const int oo = 1e9 + 7; const int Shift = a ; vector<vector<int> > F; int Next[LimitLength][27]; int nS, nT; char S[2 * LimitLength], T[LimitLength]; int KMP[2 * LimitLength]; int main() { cin >> S + 1 >> T + 1; ...
#include <bits/stdc++.h> using namespace std; int n; int a[100], b[100]; int res[100][3001][101] = {0}; bool us[100][3001][101] = {0}; const int mod = 1000000007; int work(int ll, int pr = -1, int lpred = -1) { if (ll < 0) return 0; if (ll == 0) return 1; if (pr != -1 && us[pr][ll][lpred] != 0...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-10; const long long MOD = 1e9 + 7; const long double PI = 3.1415926535897932384626433832795028841; long long powmod(long long a, long long b) { long long res = 1; a %= MOD; for (; b; b >>= 1) { if (b & 1) res = res * a ...
#include <bits/stdc++.h> using namespace std; inline int read() { int neg = 1, num = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) neg = -1; for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c - 0 ; return neg * num; } int n, a, b; char s[30...
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T& x) { x = 0; char s = (char)getchar(); bool f = false; while (!(s >= 0 && s <= 9 )) { if (s == - ) f = true; s = (char)getchar(); } while (s >= 0 && s <= 9 ) { x = (x << 1) + (x ...
#include <bits/stdc++.h> using namespace std; long long n, k, q, a, b, x, y, i = 1, j, p[150000], mas[150005]; pair<int, int> m[10]; int main() { cin >> n >> k >> q; while (i <= n) { cin >> p[i]; i++; } i = 0; while (i < q) { cin >> a >> b; if (a == 1) { if (p...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); ...
#include <bits/stdc++.h> using namespace std; void solve() { int n, t; cin >> n >> t; for (int i = 1; i <= n; i++) { int val; cin >> val; t -= (86400 - val); if (t <= 0) { cout << i << n ; return; } } } int main() { solve(); return 0; } ...
#include <bits/stdc++.h> using namespace std; pair<int, int> operator-(const pair<int, int>& lhs, const pair<int, int>& rhs) { return pair<int, int>(lhs.first - rhs.first, lhs.second - rhs.second); } int x[19] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 2, 3, 4}; int y[19] = {0, 0, 0, 1, 1, 1, 1, 2...
#include <bits/stdc++.h> using namespace std; int main() { bool ok[999]; memset(ok, false, sizeof(ok)); ok[ A ] = true; ok[ H ] = true; ok[ I ] = true; ok[ M ] = true; ok[ O ] = true; ok[ T ] = true; ok[ U ] = true; ok[ V ] = true; ok[ W ] = true; ok[ X ] = true; ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2019 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 // bug1475 module t (/*AUTOARG*/ // Outputs ID_45, IDa_f4c, // Inputs clk, ID_d9f, IDa_657, ID...
/** * 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 maxx = 1000 + 50; long long DP[maxx]; int main() { int n, m; cin >> n >> m; int t = abs(n - m); DP[1] = 1; DP[2] = 3; for (int i = 3; i <= 1000; i++) DP[i] = DP[i - 1] + i; int ans = 0; ans = 2 * DP[(t / 2)]; if (t % 2 =...
#include <bits/stdc++.h> using namespace std; const int N = (int)4e6 + 11; const long long inf = 1e9 + 7; int n, m, p[1 << 20], can[1 << 20]; int find_parent(int x) { if (x == p[x]) { return x; } return p[x] = find_parent(p[x]); } int main() { scanf( %d %d , &n, &m); for (int i =...
module synth_arb ( clk, reset_n, memadrs, memdata, wreq, synth_ctrl, synth_data, fifo_full); input wire clk, reset_n, wreq, fifo_full; input wire [7:0] memadrs, memdata; output reg [7:0] synth_ctrl, synth_data; reg [7:0] state_reg; reg [3:0] wait_...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 0x3f3f3f3f; long long dp[maxn]; int n, m; struct node { int lb, lu; long long w; }; vector<node> ve[maxn]; int lb, lu; long long w, cost[maxn]; struct seg { long long ma, lazy; } tr[maxn << 2]; ...
#include <bits/stdc++.h> using namespace std; const int maxn = (4000000) + 7; const int inf = (1e9) + 7; const long long LLinf = (1e18) + 7; const long long mod = 1e9 + 7; int main() { int n; scanf( %d , &n); n++; n /= 2; n--; printf( %d , n); return 0; }
module alu_p #(parameter WIDTH=8) (output reg [WIDTH:0] out, input [WIDTH-1:0] a, b, input c_in, input [2:0]op); parameter [2:0] OP_ADD = 0, OP_SUB = 1, OP_SUBB = 2, OP_OR = 3, OP_AND = 4, OP_NOT = 5, OP_XOR = 6, OP_XNOR = 7; always @(a, b, op, c_in) case (op) OP_ADD: out <= a + b + c...