text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; string solve() { int a, b, n; string number = ; cin >> a >> b >> n; bool added; added = false; a *= 10; for (int j = 1; j < 11; j++) { if (a % b == 0) { added = true; break; } a++; } if (!added) ret...
#include <bits/stdc++.h> using namespace std; ofstream outfile; ifstream infile; int main() { infile.open( input.txt ); outfile.open( output.txt ); long long int a, b; cin >> a >> b; if (a > b) { cout << 0 n ; return 0; } else if (b - a <= 20) { long long int digit = 1...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k, n2; long long dip, cert, losers; cin >> n >> k; dip = n / (2 * (k + 1)); cert = k * dip; losers = n - dip - cert; cout << dip << << cert << << losers; return 0; }
module \$_DFF_N_ (input D, C, output Q); SB_DFFN _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C)); endmodule module \$_DFF_P_ (input D, C, output Q); SB_DFF _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C)); endmodule module \$_DFFE_NN_ (input D, C, E, output Q); SB_DFFNE _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(!E)); endmodule mo...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * ------------------------------------------------------------------------------- * * VC allocator * Allocates new virtua...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: BMSTU // Engineer: Oleg Odintsov // // Create Date: 11:44:32 02/24/2012 // Design Name: // Module Name: ag_video // Project Name: Agat Hardware Project // Target Devices: // Too...
/** * 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 module impelements a counter. // // Note: // - Syntax works and compiles with Verilog2LPN compiler // - async. design follows dual rail encoding that maps // input to output and output to internal states // // author: Tramy Nguyen // ---------------------------- module counte...
module RGB1_RGB2( input clk, input Btn_R, input Btn_L, output reg [2:0] RGB1 = 0, output reg [2:0] RGB2 = 0 ); reg [1:0]state = 0; reg [1:0]nextState = 0; always @ (posedge clk) begin state <= nextState; case(state) 0: ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:40:43 05/17/2016 // Design Name: // Module Name: MAIN // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenci...
/* * Copyright (c) 2001 Stephen Williams () * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * ...
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { if (n == 1) { printf( a na nb nb n ); continue; } if (n % 2 == 0) { for (int i = 0; i < 4; i++) { for (int j = 0; j < n; j++) { if (i % 4 < 2) { ...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int child[N], w[N]; long long dp[N][35][3], ans[N][2]; void pre(int n) { for (int i = 0; i < n; i++) { dp[i][0][0] = w[i]; dp[i][0][2] = w[i]; dp[i][0][1] = child[i]; } for (int j = 1; j < 35; j++) { for (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 law...
#include <bits/stdc++.h> using namespace std; const long long N = (long long)(5 * 1e5 + 10); void precision(long long a) { cout << setprecision(a) << fixed; } long long expo(long long a, long long b, long long m) { long long res = 1; while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a...
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, m, k; int t, x; int c[200010]; int f1[200010]; int f2[200010]; vector<int> w, a, b; vector<int> d; vector<ll> ww, aa, bb, dd; int main() { ios::sync_with_stdio(false); cin >> n >> m >> k; for (int i = 0; i < n; ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable 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 la...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.1 (win64) Build Mon Apr 27 19:22:08 MDT 2015 // Date : Tue Mar 22 03:39:21 2016 // Host : DESKTOP-5FTSDRT running 64-bit major releas...
#include <bits/stdc++.h> #pragma GCC optimize( O3 , unroll-all-loops ) #pragma GCC target( sse4.2 ) using namespace std; ifstream in; ofstream out; const long long kk = 1000; const long long ml = kk * kk; const long long mod = 998244353; const long long inf = ml * ml * ml + 7; const int C = 5; mt...
#include <bits/stdc++.h> using namespace std; const int mmmm = 1111; int n; char s[mmmm]; int a[mmmm], f[mmmm]; void qwe() { a[0] = 1989; f[0] = 1; for (int i = 1; i <= 9; i++) { f[i] = f[i - 1] * 10; a[i] = a[i - 1] + f[i]; } } int main() { qwe(); while (scanf( %d , ...
#include <bits/stdc++.h> unsigned long long int factorial(unsigned long long int n) { unsigned long long int facto; if (n == 0) return 1; return facto = n * factorial(n - 1); } int main() { long long int a, b, GCD; unsigned long long int fa, fb; scanf( %I64d %I64d , &a, &b); if (a > b)...
#include <bits/stdc++.h> using namespace std; const int K = 26; struct Vertex { int next[K]; long long int leaf = 0; int p = -1; char pch; int link = -1; int go[K]; long long int count = -1; int leaflink = 0; Vertex(int p = -1, char ch = $ ) : p(p), pch(ch) { fill(begin(...
#include <bits/stdc++.h> using namespace std; const int NMax = 5e3 + 5; const int MMax = 1e3 + 5; int N, M; char input[NMax][MMax + 101]; short bit[NMax][MMax][2]; char solMin[MMax], solMax[MMax]; map<string, int> ID; struct elem { bool known; int op1, op2; char tor; } v[NMax]; int com...
//Legal Notice: (C)2020 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...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; string ans = s; int k_prime = 1; for (int k = 0; k < n; k++) { string t = s; rotate(t.begin(), t.begin() + k, t.end());...
#include <bits/stdc++.h> using namespace std; template <typename F, typename S> ostream &operator<<(ostream &os, const pair<F, S> &p) { return os << ( << p.first << , << p.second << ) ; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << { ; typename vecto...
//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...
/* :Project FPGA-Imaging-Library :Design ColorRGB24toVGA :Function Covert 24bits-RGB to VGA. :Module Main module :Version 1.0 :Modified 2015-05-12 Copyright (C) 2015 Tianyu Dai (dtysky) <> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Li...
////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2013, Andrew "bunnie" Huang // // See the NOTICE file distributed with this work for additional // information regarding copyright ownership. The copyright holder // licenses this file to you under the Apache License...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; int len = s.size(); int ok = 1; for (int i = 0; i < len; i++) { if (i == len) { if (s[i - 1] != a ) s[i] = a ; else 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 la...
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 4; long long int a[N][20], pre[N][20], ans; struct node { node *left, *right; long long int cnt; node() { left = NULL; right = NULL; cnt = 0; } }; struct trie { node *x; }; void insert(node *t, long l...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: ucb_bus_out.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 and/o...
#include <bits/stdc++.h> using namespace std; int main() { int a[200]; int t, n, x; for (int i = 0; i <= 100; i++) a[i] = 0; for (int i = 0; i <= 100; i++) for (int j = 0; j <= 100; j++) { t = 3 * i + 7 * j; if (t > 100) break; a[t] = 1; } cin >> n; for (i...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2015 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 // /...
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-10; const int maxn = 1000 * 1000 * 1000 + 2; int n; int a[3][5 * 100 * 1000 + 2]; long double s, e = maxn; bool check(long double x) { long double maxr = -1000000001; for (int i = 0; i < n; i++) { if (a[2][i] > 0 && ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Tecnológico de Costa Rica // Engineer: Juan José Rojas Salazar // // Create Date: 10/22/2016 08:49:25 PM // Design Name: // Module Name: multiplier // Project Name: // Target Devices: // Tool Versions...
#include <bits/stdc++.h> using namespace std; using int64 = long long; struct Primal_Dual { const int INF = 1 << 30; struct edge { int to, cap, cost, rev; }; vector<vector<edge> > graph; vector<int> potential, min_cost, prevv, preve; Primal_Dual(int V) : graph(V) {} void add_edge...
/* * 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...
//---------------------------------------------------------------------------- //-- Prueba de tranmision 2. Transmision continua del caracter K cuando se //-- activa la señal DTR //---------------------------------------------------------------------------- //-- (C) BQ. September 2015. Written by Juan Gonzalez (Obijuan...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000009; long long modexp_recursion(long long a, long long b, long long n) { long long t = 1; if (b == 0) return 1; if (b == 1) return a % n; t = modexp_recursion(a, b >> 1, n); t = t * t % n; if (b & 0x1) { t = t...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : ...
#include <bits/stdc++.h> using namespace std; const int N = 110; const int M = 1010; double f[N][M * N], sum[N * M]; int a[N], n, m, s; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , a + i); s += a[i]; } f[0][0] = 1; sum[0] = 1.0; for (int ...
#include <bits/stdc++.h> using namespace std; const int N = 5010; int Case, n, a[N], la[N], fn[N]; int f[N][N]; int main() { scanf( %d , &Case); while (Case--) { scanf( %d , &n); for (int i = 1; i <= n; ++i) fn[i] = 0; for (int i = 1; i <= n; ++i) { scanf( %d , a + i); ...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Expert(TM) in wire load mode // Version : L-2016.03-SP3 // Date : Wed Oct 19 14:30:33 2016 ///////////////////////////////////////////////////////////// module FSM_Add_Subtract ( clk, rst, rst_FSM, beg_FSM, zero_flag_i, ...
#include <bits/stdc++.h> using namespace std; long long a[1000006]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); long long score = 0; for (int i = 0; i < n - 1; i++) score += 1ll * (i + 2) * a[i]; score += a[n - 1] * n; cout << score << end...
module reg_128x32b_3r_2w_fpga (/*AUTOARG*/ // Outputs rd0_data, rd1_data, rd2_data, // Inputs clk, rd0_addr, rd1_addr, rd2_addr, wr0_addr, wr1_addr, wr0_en, wr1_en, wr0_data, wr1_data ); input clk; output [31:0] rd0_data; output [31:0] rd1_data; output [31:0] rd2_data; input [6:0] rd0_addr; input [6...
#include <bits/stdc++.h> using namespace std; const int N = 3e4 + 7, M = 2e2 + 7; bool fl[N]; int n, k, tot, fs[N], sum[N], pos[M], f[M][N]; map<int, bool> s[N]; struct edge { int u, v; } ed[N * M]; struct node { int ch[M], num; } qt[N]; inline int read() { int num = 0; char g = getc...
`timescale 1ns/1ps `include "../global.v" module ExpRegisterFile_tb(); parameter HCP = 10; //half clock period reg clk, reset; reg writeEnableA, writeEnableB; reg [8:0] writeValueA, writeValueB; reg [2:0] readSelectA, readSelectB; wire [8:0] readResultA, readResultB; defpara...
#include <bits/stdc++.h> using namespace std; const long long nax = 100001; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (auto& x : a) { cin >> x; } ...
#include <bits/stdc++.h> using namespace std; int main(void) { int level[26]; for (int i = 0; i < 26; i++) cin >> level[i]; string s; cin >> s; long long ans = 0; for (char ch = a ; ch <= z ; ch++) { map<long long, long long> m; long long sum = 0; for (int i = 0; i < s.le...
#include <bits/stdc++.h> using namespace std; int n, m, a[102], b[102]; int main(void) { scanf( %d %d , &n, &m); for (int i = 0; i < m; ++i) scanf( %d %d , &a[i], &b[i]); for (int x = 1; x <= n; ++x) { int c = 0; for (int i = 0; i < m; ++i) if (x >= a[i] && x <= b[i]) ++c; if...
// (C) 2001-2016 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
#include <bits/stdc++.h> using namespace std; int a[40005]; int main() { int i, j; int n, m, x; while (scanf( %d %d , &n, &m) != EOF) { if ((n == 1 || n == 2) && m == 1) { printf( -1 n ); continue; } if (n < (2 * m + 1)) { if (m == 1) { printf( %d n ...
#include <bits/stdc++.h> using namespace std; int main() { int T, a, b, c, i, count = 0; cin >> T; for (i = 0; i < T; i++) { cin >> a >> b >> c; if ((a + b + c) >= 2) { count++; } } cout << count << n ; return 0; }
module etx_io (/*AUTOARG*/ // Outputs txo_lclk_p, txo_lclk_n, txo_frame_p, txo_frame_n, txo_data_p, txo_data_n, tx_wr_wait, tx_rd_wait, // Inputs tx_lclk_io, tx_lclk_div4, tx_lclk90, txi_wr_wait_p, txi_wr_wait_n, txi_rd_wait_p, txi_rd_wait_n, tx_data_slow, tx_frame_slow ); parameter IOSTD_EL...
/* * 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 K, P, cd; int cal(int ct, vector<pair<int, int> > vt) { int t = vt.size(), res = 0; for (int st = 1; st < (1 << t); st++) { int val = 1, sl = 0; for (int j = 0; j < t; j++) { if ((st >> j) % 2 == 1) val *= vt[j].first, sl++; } ...
/** * 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 = 1e9 + 7; inline int read() { int s = 0, w = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) w |= (ch == - ), ch = getchar(); while (ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0 , ch = getchar(); return w ? -s : s; } struct...
`timescale 1ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:42:40 06/01/2015 // Design Name: // Module Name: scancode_to_speccy // Project Name: // Target Devices: // Tool versions: // Descrip...
#include <bits/stdc++.h> using namespace std; void solve() { long long n, su = 0; cin >> n; vector<long long> a(n); for (long long i = 0; i < n; ++i) { cin >> a[i]; su += a[i]; } if (su % 2) { cout << NO n ; return; } long long s = 0, ind = -1; for (long ...
#include <bits/stdc++.h> using namespace std; void input() {} int main() { input(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; if (n % 2 == 0) cout << -1 << n ; else { for (int i = 0; i < n; i++) cout << i << ; cout << n ; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1123; const int MAXK = 312345; struct S2DSum { long long x[MAXN][MAXN]; void integrate(int n, int m) { for (int j = 0; j < m; j++) { for (int i = 1; i < n; i++) { x[i][j] += x[i - 1][j]; } } for (i...
////////////////////////////////////////////////////////////////////////////////// // NPCG_Toggle_BNC_P_read_DT00h for Cosmos OpenSSD // Copyright (c) 2015 Hanyang University ENC Lab. // Contributed by Kibin Park <> // Ilyong Jung <> // Yong Ho Song <> // // This file is part of Cosmos Ope...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.2 (win64) Build Fri Jun 26 16:35:25 MDT 2015 // Date : Sun Jun 12 16:30:48 2016 // Host : 804-066 running 64-bit Service Pack 1 (bui...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; cin >> n; set<int> row; set<int> col; map<int, int> row_map; map<int, int> col_map; for (i = 1; i <= n; i++) { string s; cin >> s; for (j = 1; j <= n; j++) { if (s[j - 1] == . ) { ...
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, z; cin >> x >> y >> z; long long ans1 = x / z + y / z, ans2 = 0; x %= z; y %= z; if (x + y >= z) { ans1++; ans2 = min(z - x, z - y); } cout << ans1 << << ans2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int h, q, v, e; string s; map<int, int> xx; inline double dfs(int x, int mx) { if (xx[x] <= mx) return mx; return 0.5 * (dfs(x << 1, max(mx, xx[x] - xx[x << 1])) + dfs(x << 1 | 1, max(mx, xx[x] - xx[x << 1 | 1]))); } int main() { ...
//Legal Notice: (C)2010 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...
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b; cin >> r >> g >> b; int ans = 0; ans = r / 3 + g / 3 + b / 3; if (min(r, min(g, b)) >= 1) ans = max(ans, (r - 1) / 3 + (g - 1) / 3 + (b - 1) / 3 + 1); if (min(r, min(g, b)) >= 2) ans = max(ans, (r - 2) / 3 + ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; const int maxm = 2e1 + 7; int n, m; int ar[maxn]; char ch[maxn]; int main() { int k; scanf( %d%d , &n, &k); int d = (n - k) / 2; for (int i = 0; i < n; i++) { ch[i] = 0 + (i % (d + 1) == d); } printf( %...
module test_wb_ppfifo_2_mem ( input clk, input rst, //wishbone slave signals input i_wbs_we, input i_wbs_stb, input i_wbs_cyc, input [3:0] i_wbs_sel, input [31:0] i_wbs_adr, input [31:0] i_wbs_dat, output r...
#include <bits/stdc++.h> using namespace std; int f(int n, vector<int> &a); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i <= n - 1; i++) { cin >> a[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; const double eps = 1e-9; const double pi = acos(-1); const int M = 3e5 + 10; const int inf = 2e9 + 10; const int mod = 1e9 + 7; int n, stk[M], le[M], ri[M], f[M], cnt[M]; char s[M], s1[M]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; int ans, flag, a[20][300010], n, i, x, anx[20], as[20]; void dfs(int x, int y) { if (y >= ans) return; if (x < 2) { anx[1] = 0; if (a[x][0]) { y++; anx[1] = -1; } if (a[x][2]) { y++; anx[1] = 1; } ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; int n; int inDegree[MAXN]; long long A[MAXN], _A[MAXN], B[MAXN]; vector<int> adj[MAXN]; void build() { for (int i = 0; i < n; i++) { if (B[i] == -1) continue; adj[i].push_back(B[i]); inDegree[B[i]]++; } } ...
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; const int N = 200005; int from[N], to[N]; stack<pair<int, int> > G[MAX]; stack<int> res; bool visited[2 * N]; void dfs(int src, int ind = -1) { if (ind != -1) { visited[ind] = true; } while (!G[src].empty()) { ...
// Must synthesize into 3 * 8x2048 brams module vram(input clk, input [19:0] p1_addr, input [7:0] p1_data, output [7:0] p1_data_out, input p1_we, input p1_re, input [19:0] p2_addr, output [7:0] p2_data); reg [7:0] mem[0:...
#include <bits/stdc++.h> constexpr const int64_t mod = 998244353; int64_t dp[1005][2005][4]; int n, k; int main(int argc, char* argv[]) { scanf( %d%d , &n, &k); std::fill(dp[1][0], dp[1][0] + 4, 1LL); for (int i = 2; i <= n; ++i) { for (int j = 0; j < k; ++j) { dp[i][j][0] = dp[i - 1][...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, m; string in[1003]; int a[1003][1003]; int X[] = {-1, 0, 0, 1}; int Y[] = {0, -1, 1, 0}; bool d[1003][1003]; int getSm(int i, int j, int u, int v) { return a[u][v] - a[i - 1][v] - a[u][j - 1] + a[i - 1][j - 1]; } bool check() { for (int i ...
#include <bits/stdc++.h> using namespace std; const int INF = (1 << 30) + 7; const int N = 1e5 + 7; int main() { ios::sync_with_stdio(false); int q, l, r, d, ans; cin >> q; while (q--) { cin >> l >> r >> d; ans = (r / d + 1) * d; if (d < l) ans = d; else a...
module basic(); // -------- Variable Section ---------- // --- User Variables ---- reg signed [31:0] A [0:10] ; reg signed [31:0] I ; reg signed [31:0] Y ; // --- Control Bits ---- reg clk ; reg [63:0] cycle_count ; reg c_bit_00000_start ; reg c_bit_00010_dim ; reg c_bit_00020_00_...
`timescale 1ns / 1ps module MainActivity ( input [7:0] estado, input [7:0]RG1_P, input [7:0]RG2_P, input [7:0]RG3_P, input escribiendo, input en_out, input [3:0] dig0, dig1, input [3:0] direccion, input clk, reset, off_alarma,on_alarma,//clock signal 100M output [7:0] COLOUR_OUT,//b...
#include <bits/stdc++.h> using namespace std; long long n, m, k; string s; bool flag; void solve() { int n, k; cin >> n >> k; unordered_set<int> s; queue<int> q; vector<int> a(n); for (auto i = 0; i < n; i++) cin >> a[i]; ; for (auto i = 0; i < n; i++) { if (s.find(a[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; long long a[500006]; long long dp[500006]; long long vis[500006]; vector<long long> v[500006]; long long on; long long n, d, che; void dfs(long long root, long long parent) { vis[root] = 1; dp[root] = 1; for (auto it : v[root]) { if (!vis[i...
#include <bits/stdc++.h> using namespace std; using namespace rel_ops; using ll = int64_t; using Pii = pair<int, int>; using ull = uint64_t; using Vi = vector<int>; void run(); int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); run(); return 0; } ...
#include <bits/stdc++.h> using namespace std; const int www = 9; const int Size = 10000; char buffer[Size]; int dr[] = {-1, 0, 1, 0}; int dc[] = {0, 1, 0, -1}; const int inf = 0x0fffffff; const int size = 1000; int d[size]; int solution(int nTest) { int k, a, b; scanf( %d%d%d , &k, &a, &b); ...
#include <bits/stdc++.h> using namespace std; vector<int> fail(string s) { int n = s.size(); vector<int> z(n); int l = 0, r = 0; for (int i = 1; i < n; ++i) { if (i <= r) z[i] = min(z[i - l], r - i + 1); while (z[i] + i < n && s[z[i] + i] == s[z[i]]) ++z[i]; if (z[i] + i - 1 > r) {...
/* 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...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 100; int bitRow[maxn][maxn], bitCol[maxn][maxn], n, m; bool a[maxn][maxn]; void addRow(int fi, int idx, int val) { while (idx <= 1000) { bitRow[fi][idx] += val; idx += idx & (-idx); } } void addCol(int fi, int idx, i...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; int cnt = 0; vector<int> v; char last = * ; for (int i = 0, to = n; i < to; i++) { if (last != s[i]) { if (cnt > 0) v.push_back(cnt); cnt = 1; last = s[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> #define ll long long #define f(i, n) for (i = 0; i < n; ++i) #define all(n) n.begin(), n.end() #define P long(1e9 + 7) #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) using namespace std; ll solve(vector<vector<ll>>& dp, ve...
#include <bits/stdc++.h> using namespace std; vector<long long> lucky; void backtrack(long long x) { if (x > 1e10) return; lucky.push_back(x); backtrack(x * 10 + 4); backtrack(x * 10 + 7); } int main() { long long ans = 0; backtrack(0); sort(lucky.begin(), lucky.end()); int a, ...