text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; void read_file(bool outToFile = true) {} int n, m; bool vis[500 + 9][500 + 9]; string s; int l; int x, y; int ans[100000 + 1 + 9]; string alpha = *URDL ; int dij[5][2] = {{0, 0}, {-1, 0}, {0, +1}, {+1, 0}, {0, -1}}; bool valid(int i, int j) { 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() { int a, b, c, d, e = 0, all = 0, i = 0; cin >> a >> b; c = a; d = b; while (c) { if ((c % 10) > e) { e = c % 10; } c = c / 10; } while (d) { if ((d % 10) > e) { e = d % 10; } 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...
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 10; long long int vis[N]; vector<vector<int> > v; int dfs(int t) { vis[t] = 1; for (int i = 0; i < v[t].size(); i++) { if (vis[v[t][t]] == 0) { dfs(v[t][i]); } } return 0; } int main() { long lon...
/** * 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); int n; cin >> n; int a[n][n]; int dp[2][n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int ...
#include <bits/stdc++.h> using namespace std; int n, m, i, x, q, w[110000]; long long ans; int f(int x) { return x * (x / 2) + x % 2; } bool cmp(int x, int y) { return x > y; } int main() { scanf( %d%d , &n, &m); for (i = 0; i < m; i++) scanf( %d%d , &q, w + i); sort(w, w + m, cmp); while (f...
//================================================================================================== // Filename : RKOA_OPCHANGE.v // Created On : 2016-10-26 23:25:59 // Last Modified : 2016-10-31 16:17:32 // Revision : // Author : Jorge Esteban Sequeira Rojas // Company : Instituto Tec...
#include <bits/stdc++.h> using namespace std; int n, i, j, k, l, w[200005], h[200005], a, b, m, m1; int main() { scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d%d , &w[i], &h[i]); if (h[m] <= h[i]) { m1 = m; m = i; } else if (h[m1] <= h[i]) { m1 = 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; bool isPrime(int num); int main() { int n; cin >> n; for (int i = 1; i <= 1000; i++) { if (!(isPrime(n * i + 1))) { cout << i; break; } } return 0; } bool isPrime(int num) { if (num <= 1) return false; ...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int t[N]; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; t[0] = 0; t[n + 1] = 0; for (int i = 1; i <= n; ++i) { cin >> t[i]; t[i] = min(t[i - 1] + 1, t[i]); } for (int i = n; i > 0; --i) ...
module de0_top ( input CLOCK_50, // Clock 50 MHz input CLOCK_50_2, // Clock 50 MHz input [ 2:0] BUTTON, // Pushbutton[2:0] input [ 9:0] SW, // Toggle Switch[9:0] output [ 6:0] HEX0_D, // Seve...
#include <bits/stdc++.h> using namespace std; long long a[300005], m[300005], t[300005], ans, sum, n, x, qwq; int main() { scanf( %lld , &n); for (long long i = 1; i <= n; i++) { scanf( %lld%lld , &a[i], &m[i]); x = m[i]; while (x) { x >>= 1ll; t[i]++; } sum +...
#include <bits/stdc++.h> using namespace std; int n, sn, i, j, sum, temp, nl; map<int, int> myMap; vector<int> t[105]; int main() { cin >> n; j = 0; sn = n * n; for (i = sn; i > sn / 2; i--) { t[j % n].push_back(i); t[j % n].push_back(sn - i + 1); j++; } for (i = 0; i...
#include <bits/stdc++.h> const int mod = 1000000007; const int inf = 1000000009; const long long INF = 1000000000000000009; const long long big = 1000000000000000; const long double eps = 0.0000000001; using namespace std; int DP[2005][2005], T[2005]; int main() { ios::sync_with_stdio(false); ci...
`timescale 1ns / 1ps module KeyBoard_ctrl(CLK, RESET, ROW, COLUMN, DECODE_BCD1, DECODE_BCD0); input CLK; input RESET; input [3:0] COLUMN; output [3:0] ROW; output [3:0] DECODE_BCD0; output [3:0] DECODE_BCD1; reg [3:0] ROW; reg [3:0] DEBOUNCE_COUNT; reg [3:0] SCAN_CODE; reg ...
#include <bits/stdc++.h> using namespace std; long long Gcd(long long a, long long b) { if (a % b == 0) return b; return Gcd(b, a % b); } long long Max(long long a, long long b) { if (a > b) return a; return b; } long long Min(long long a, long long b) { if (a < b) return a; return b...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; for (long long i = 0; i < n; ++i) { if (i % 4 < 2) putchar( a ); else putchar( b ); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<long long int> cost(n); for (long long int i = 0; i < n; i++) { cin >> cost[i]; } sort(cost.begin(), cost.end()); long long int m; cin >> m; vector<long long int> coup(m); for (...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b; while (cin >> n >> m >> a >> b) { a--; b--; int oa, pa, ob, pb; oa = a / m; pa = a % m; ob = b / m; pb = b % m; if (b == n - 1) { pb = m - 1; } if (oa == ob) { ...
module lab5dram(CLK, RESET, ADDR, DATA, MW, Q, IOA, IOB, IOC, IOD, IOE, IOF, IOG); input CLK; input RESET; input [7:0] ADDR; // 8-bit addresses input [7:0] DATA; // 8-bit data words input MW; output [7:0] Q; input [7:0] IOA; input [7:0] IOB; input [7:0] IOC; ...
#include <bits/stdc++.h> using namespace std; long long pow_mod(long long x, long long y) { long long ret = 1; while (y) { if (y & 1) ret = (ret * x) % 1000000007; x = (x * x) % 1000000007; y >>= 1; } return ret; } long long f[2000010]; void init() { f[0] = 1; for (in...
module PushBtnInterface(clock,reset,button,button_pressed); parameter Wait = 40000; parameter Size = 16; input wire clock; input wire reset; input wire button; output wire button_pressed; reg [Size-1:0] s_Counter; reg s_DoneCount; reg s...
`timescale 1 ns / 1 ps module engine ( input clk, input rst, output done, input [63:0] num_rows_in, input [63:0] rows_size_in, // size is passed in bytes input [63:0] row_start_in, // what row ...
#include <bits/stdc++.h> using namespace std; const long long int N = 1001; long long int n, m, k; vector<pair<long long int, long long int> > adj[N]; vector<long long int> func(long long int x) { vector<long long int> dis(n + 1, INT_MAX); if (x == 0) { return dis; } vector<int> vis(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...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; long long int a[n]; for (long long int i = 0; i < n; i++) { a[i] = 0; } long long int x; for (long long int i = 0; i < m; i++) { cin >> x; a[x - 1] += 1; } long long in...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; const int INF = 0x7fffffff; vector<int> G[maxn]; long long weight[maxn]; long long dp[maxn]; int ans; long long maxsum = -INF; void dfs(int now, int fa) { dp[now] = weight[now]; for (int v : G[now]) { if (v != fa) { ...
#include <bits/stdc++.h> using namespace std; inline void optimizeIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const int nmax = 150005; const long long LINF = 1e17; int ara[110]; set<int> SET; int main() { optimizeIO(); int n; cin >> n; for (int i = 1; i <= n; i++) {...
#include <bits/stdc++.h> using namespace std; const int N = 100005; const int M = 100005; int n, m; int in_degree[N]; bool visited[N]; bool tree_edge[M]; bool directed[M]; vector<int> choose[N]; vector<pair<int, int> > adj[N]; inline void dfs(int u, int p) { visited[u] = true; for (auto ed...
//Legal Notice: (C)2018 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; const double PI = acos(-1.0); int freq[26]; int main() { string s; cin >> s; int mx = -1; char g = s[0]; for (int i = 0; i < s.size(); i++) { freq[s[i] - a ]++; if (s[i] >= g) { mx = max(mx, freq[s[i] - a ]); g = s[i...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-11; int n, d; const int M = 30001; int f[M][250 * 2]; int v[M]; int solve(int i, int j) { if (i >= M) return 0; int jj = j - (d - 250); if (f[i][jj] != -1) return f[i][jj]; f[i][jj] = 0; int res = 0; if (j == ...
#include <bits/stdc++.h> using namespace std; double eps = 1e-10; int main() { ios::sync_with_stdio(false); cin.tie(0); long long h, l; while (cin >> h >> l) { double L = 0.0, R = 10000000.0; long long ans = l * l - h * h; printf( %.13f n , ans / (2.0 * h)); } 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...
// based on https://people.ece.cornell.edu/land/courses/ece5760/DE2/indexVGA.html // read sram or switch and output color to screen module vgaram ( input wire clk50, input wire [3:0] key, input wire [17:0] sw, inout wire [15:0] sram_dq, output wire [19:0] sram_addr, output wire sram_ub_n, outp...
#include <bits/stdc++.h> using namespace std; long long a[300005]; vector<long long> adjlist[1048585]; int main() { long long n, i; scanf( %lld , &n); for (i = 0; i < n; i++) { scanf( %lld , a + i); } for (i = 1; i < n; i++) { a[i] = a[i - 1] ^ a[i]; } adjlist[0].push_bac...
`timescale 1ns/1ns // READ: Tag response to a 'read' command. // Copyright 2010 University of Washington // License: http://creativecommons.org/licenses/by/3.0/ // 2008 Dan Yeager // readbit* = talking to tx module // read_sample_* = talking to external source (adc or msp430) // which supplies sample...
#include <bits/stdc++.h> int n, m, num; char tab[100][100]; int xx[10000][4]; int yy[10000][4]; int ch[100][100]; int id[100][100]; int getdir(int cd, int dd) { if (cd == 1) return (dd + 1) % 4; else return dd; } int main() { scanf( %d %d , &n, &num); for (int i = 0; i < n;...
#include <bits/stdc++.h> using namespace std; char str[2010][2010]; void go(int x, int y) { int l, r, u, d; d = (int)(str[x + 1][y] == . ); u = (int)(str[x - 1][y] == . ); r = (int)(str[x][y + 1] == . ); l = (int)(str[x][y - 1] == . ); if (!d && !u && !r && !l) { cout << Not uni...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1000000000 ) using namespace std; const bool db = false; int n, m, x, y; int a[1010][1010], b[1010][1010]; long long s[1010][1010], cs[1010][1010]; vector<pair<int, int> > ans; char mark[1010][1010]; pair<long long, pair<int, int> > st[1010 * 10...
//Legal Notice: (C)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 associate...
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { return (!y ? x : gcd(y, x % y)); } const int maxn = 2e5; vector<int> g[maxn], tree[maxn]; map<pair<int, int>, int> we; int par[maxn]; int gpar(int v) { return (par[v] == v ? v : par[v] = gpar(par[v])); } bool mrg(int u, int v) { u...
`timescale 1ns / 1ps // KCP53001 2-to-1 bus arbiter. // // This module can be used for two purposes: // 1. To adapt a Harvard-architecture processor to a Von Neumann-architecture // memory bus. This use-case explains why the input ports are named I- // and D-ports. // // 2. To support multiple bus masters on a ...
#include <bits/stdc++.h> using namespace std; int main() { int sum, a, b, c, ans = 0; cin >> sum >> a >> b >> c; for (int i = 0; i <= a; i += 2) for (int j = 0; j <= c; ++j) if (sum - i / 2 - 2 * j <= b && sum - i / 2 - 2 * j >= 0) ans++; cout << ans << endl; return 0; }
module top; function real copy(input real r); copy = r; endfunction real a, b, c, d, e, f; initial begin a = 0.4; b = 0.5; c = 0.6; d = 2.4; e = 2.5; f = 2.6; $display("a: %.1f %0d %0x %0b", copy(a), copy(a), copy(a), copy(a)); $display("b: %.1f %0d ...
#include <bits/stdc++.h> using namespace std; int sieve(vector<bool> &arr, vector<int> &ans) { int res = INT_MAX; for (int i = 2; i <= sqrt(arr.size()); i++) { if (arr[i]) { for (int j = i * i; j < arr.size(); j += i) { arr[j] = false; if (ans[j] == ans[i]) ans[j]++; ...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: R_SEQ.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ==================================...
/* This file is part of JT12. JT12 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. JT12 is distributed in the hope tha...
/** * 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[5050]; int solve(int l, int r, int h) { int m, i; if (l > r) return 0; else if (l == r) return (a[l] > h); else for (i = m = l; i <= r; i++) if (a[m] > a[i]) m = i; return min(r - l + 1, a[m] - h + sol...
/** * 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 MXN = 1e5 + 20; int n, a[MXN], b[MXN], c[MXN]; vector<int> ans; void IN() { int tmp; cin >> n; for (int i = 0; i < n; i++) { cin >> tmp; a[i] = tmp; } for (int i = 0; i < n - 1; i++) { cin >> tmp; b[i] = tmp; ...
/** * 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...
//----------------------------------------------------------------------------- // (c) Copyright 2012 - 2013 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 proper...
#include <bits/stdc++.h> using namespace std; const char nl = n ; const int MAX_N = 100011; const long long INF = (1 << 29) + 123; const long long MOD = 1000000007; const long double PI = 4 * atan((long double)1); template <typename T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 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; long long basis[62], a[200005], pref[200005]; int siz = 0; bool ins(long long x) { for (int i = 0; i < 62; i++) { if (!(x & (1LL << i))) continue; if (!basis[i]) { basis[i] = x; siz++; return true; } else { x ^= ...
`default_nettype none // ============================================================================ module error_counter # ( parameter COUNT_WIDTH = 24, parameter DELAY_TAPS = 32, parameter TRIGGER_INTERVAL = 20,//100000000, parameter HOLDOFF_TIME = 4,//10, parameter MEASURE_TIME = 10//50000 ) ( input wi...
#include <bits/stdc++.h> using namespace std; int main() { int number; cin >> number; long long ans = number; while (1) { int x = 100000000; for (int i = 2; i <= sqrt(number); i++) { if (number % i == 0) { x = min(x, i); } } if (x == 100000000) break...
#include <bits/stdc++.h> using namespace std; int mat[100001], mat2[100001]; long long k, suma, a, b, s, c; int n; map<int, int> mapa; long long ct; int main() { cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> mat[i]; mapa[mat[i]]++; } sort(mat, mat + n); suma = 1; ...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-9; long double _A[19][100009], _b[19], _c[100009]; struct LPSolver { int m, n; vector<int> B, N; vector<vector<long double> > D; LPSolver(const vector<vector<long double> > &A, const vector<long double> &b, con...
#include <bits/stdc++.h> using namespace std; const int N = 1100, M = 2 * 1e5 + 10, INF = 1e9 + 10; pair<int, int> e[M]; int dp[N][N]; vector<pair<pair<int, int>, pair<int, int> > > que[M]; bool ans[M]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, q; cin >> n >> m >> q;...
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, a[N] = {}, tot = 0; bool v[N] = {}; void dfs(int s) { v[s] = true; if (!v[s * 2 % n]) dfs(s * 2 % n); if (!v[s * 2 % n + 1]) dfs(s * 2 % n + 1); a[++tot] = s; } int main() { cin >> n; if (n % 2) puts( ...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ll = long long; void solve() { string s; cin >> s; int m = ((int)(s).size()); vi a(m); a[0] = ((s[0] == - ) ? -1 : 1); for (__typeof(m) i = (1) - ((1) > (m)); i != (m) - ((1) > (m)); i += 1 - 2 * ((1) >...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:26:30 10/31/2016 // Design Name: SeparadorNumeros // Module Name: /home/fede/DatosWindows/Facultad/Arquitectura de Computadoras/WorkspaceXilinxIse/UART/UART_Arquit...
`timescale 1 ps / 1 ps (* message_disable = "14320" *) module alt_mem_ddrx_fifo # ( parameter CTL_FIFO_DATA_WIDTH = 8, CTL_FIFO_ADDR_WIDTH = 3 ) ( // general ctl_clk, ctl_reset_n, // pop free fifo entry get_valid, get_ready, get_data, ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5, M = 1e5; int dfn, cur[M + 1], in[N + 1], pre[N + 1], fin[N + 1], r[N + 1], sz[N + 1]; vector<int> adj[N + 1]; int dfs(int u, int a) { sz[u] = 1; r[u] = a; pre[u] = ++dfn; for (auto v : adj[u]) sz[u] += dfs(v, a); fin[u] = ++d...
// (C) 1992-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 simulati...
#include <bits/stdc++.h> int isprime(long long p) { int i; double max = sqrt(p); for (i = 2; i <= max; i++) if (p % i == 0) break; if (i > max && p != 1) return 1; return 0; } long long gcd(long long a, long long b) { long long i; for (i = a < b ? a : b; i > 0; i--) if ((a ...
#include <bits/stdc++.h> namespace { using namespace std; template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; } template <typename T> bool space(vector<T>) { return false; } template <typename T> bool space(T) { return true; } ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int MAXN = 33333; const int mod = 998244353, G = 3; int n, k, T, a[MAXN], W, rev[MAXN], gen[MAXN]; vector<int> vec[MAXN]; inline int qpow(int a, int b) { int re = 1; for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) re = 1ll * re * a % mod...
// 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 main() { int k, i, j, l = 0; cin >> k >> i; for (j = 1; j <= 10; j++) { l = k * j; if (l % 10 == 0 || l % 10 == i) { cout << j; break; } } }
module membus_2_connect( // unused input wire clk, input wire reset, // Master input wire m_wr_rs, input wire m_rq_cyc, input wire m_rd_rq, input wire m_wr_rq, input wire [21:35] m_ma, input wire [18:21] m_sel, input wire m_fmc_select, input wire [0:35] m_mb_write, output wire m_addr_ack, output wire m_r...
#include <bits/stdc++.h> using namespace std; vector<int> tree[100005]; int cat[100005]; bool vis[100005]; int n, m, ans = 0; void dfs(int root, int num) { vis[root] = true; if (cat[root]) num++; else num = 0; if (num > m) return; if (tree[root].size() == 1 && vis[tree[root][...
/** * 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 n, A, cf, cm, m; struct node { long long x; int i; } a[100001]; long long sum[100001]; long long ans = 0; bool cmp(node a, node b) { return a.x < b.x; } bool cmp1(node a, node b) { return a.i < b.i; } long long minc = 0; long long bsear...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:17:06 09/03/2013 // Design Name: // Module Name: lab2_labkit // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: /...
// part of NeoGS project // // (c) NedoPC 2007-2008 // // modelling is in tb_dma1.* // look also at dma_access.png module dma_access( input clk, input rst_n, input dma_req, // DMA request input [20:0] dma_addr, // DMA address (2mb) input dma_rnw...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 4; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ; cin >> s; long long n = s.size(); long long sub = 0; for (int k = 1; k <= 8; k++) { for (int i = 0; i + k <...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int h[n]; for (int i = 0; i < n; ++i) { cin >> h[i]; } vector<int> v(n, 0); int maxx = 0; for (int i = n - 1; i >= 0; 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<iostream> #include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #define INF 100000007 #define MAX 1000000 #define nl n #define F first #define S second #define pb(a) push_back(a) typedef vector<ll> vi; typedef priority_queue<ll , vector<ll> , great...
// megafunction wizard: %RAM: 2-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: altera_dpram.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =======================...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64000000 ) using std::cerr; using std::cin; using std::cos; using std::cout; using std::endl; using std::make_pair; using std::map; using std::max; using std::min; using std::next_permutation; using std::pair; using std::priority_queue; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; string s; cin >> n >> k >> s; for (int i = 0; i < s.size(); i++) { if (!k) break; if (i + 2 < s.size() && s[i] == 4 && s[i + 1] == 7 && s[i + 2] == 7 && i % 2 == 0) { if (k % 2) s[i + 1] = 4 ; ...
#include <bits/stdc++.h> using namespace std; string mirror = AHIMOTUVWXY ; string letter = ABCDEFGHIJKLMNOPQRSTUVWXYZ ; int main() { long long n, m, i, j, k, x, y, z, t; cin >> x >> y; if ((x == 0 || x == 1) && y == 0) { cout << 0 << endl; return 0; } if (x == 1 && y == 1) { ...
#include <bits/stdc++.h> using namespace std; int t; int main() { scanf( %d , &t); while (t--) { int a, b; scanf( %d%d , &a, &b); int k = min(max(2 * a, b), max(a, 2 * b)); printf( %d n , k * k); } }
#include <bits/stdc++.h> using namespace std; int n; int b[3100]; int a[3100]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &b[i]); int bb = b[i] - b[i - 1], l; if (bb > 0) { youginzi: l = 1; while (bb) { while (a[l] == 9) l...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m, count = 0; cin >> n >> m; long long a[m]; for (long long i = 0; i < m; i++) { cin >> a[i]; for (long long j = 0; j < i; j++) { if (a[j] < a[i]) count++; } } cout << count << n ; } int...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e17; const long long MOD = 1000000007; const long long MAX = 4000001; const long double eps = 1E-14; long long max(long long a, long long b) { if (a > b) { return a; } return b; } long long min(long long a, long long ...
/* Copyright (c) 2015-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 N = 1e5 + 17; int l1[N], r1[N], a[N], use[N]; map<int, bool> mt; void dfs(int v, int l, int r) { if (a[v] > l && a[v] < r) mt[a[v]] = 1; if (l1[v] != -1) dfs(l1[v], l, min(r, a[v])); if (r1[v] != -1) dfs(r1[v], max(l, a[v]), r); } int mai...