text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; constexpr int N = 1e6 + 10; constexpr int M = 30; long long a1 = 2, a2 = 4, n, ans = 2, t = 4, dis[N], dp[N][M], v, dist1, dist2; int get_lca(int a, int b) { if (dis[a] < dis[b]) swap(a, b); while (dis[a] != dis[b]) a = dp[a][(int)log2(dis[a] - dis[b])]; ...
#include <bits/stdc++.h> using namespace std; queue<int> d[110]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { for (int j = (n / 2) * (i - 1) + 1, g = 1; g <= (n / 2); j++, g++) { d[i].push(j); } } for (int i = 1; i <= n; i++) { for (int j = (n /...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> perm; void generate(vector<int>& curr, int n) { if (n == 4) perm.push_back(curr); else { for (int i = n; i < 4; i++) { swap(curr[n], curr[i]); generate(curr, n + 1); swap(curr[n], curr[i]); } } ...
#include <bits/stdc++.h> using namespace std; int num[26][5] = { {1,0,0,1,0}, // a {1,1,0,2,0}, // b {2,0,0,1,1}, // c {2,1,0,1,2}, // d {1,1,0,1,1}, // e {2,1,0,2,1}, // f {2,2,0,2,2}, // g {1,2,0,2,1}, // h {1,1,0,1,1}, // i {1,2,0,1,2}, // j {1...
#include <bits/stdc++.h> using namespace std; int main() { long long i, n, ans, ghor, j, k, flag = 0; cin >> n; for (i = 0;; i++) { ans = (n - 1) / (5 * pow(2, i)); if (ans == 0) break; n = n - (5 * pow(2, i)); } ghor = i + 1; long long p = pow(2, i); long long cnt = 1;...
#include <bits/stdc++.h> using namespace std; bool is_pal(string a) { string b = a; reverse(b.begin(), b.end()); return b == a; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ; string second; cin >> second; for (int i = 0; i < second.size(); i++) { string ...
//----------------------------------------------------------------- // RISC-V Top // V0.6 // Ultra-Embedded.com // Copyright 2014-2019 // // // // License: BSD //--------------------------...
`timescale 1ns / 1ps /* -- Module Name: DES Node -- Description: Top level de un nodo de la red en-chip. Vale la pena notar que las interfaces fuera del modulo son las mismas que las de un router de red, la razon de esto es que el puerto del elemento de procesamiento de cada nodo solo tiene acceso ex...
#include <bits/stdc++.h> using namespace std; const int NMAX = 20, LMAX = 400000, INF = ~0u >> 1; int K, L = 1, f1[2 * LMAX], f2[LMAX], f3[LMAX]; long long A, B; int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } int main() { int i, j; scanf( %I64d %I64d %d , &B, &A, &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; long long solve(long long h, long long n, bool left) { if (h == 1) return left ? n : 3 - n; long long p = 1ll << (h - 1); if (left) { if (n > p) return ((long long)1 << h) + solve(h - 1, n - p, left); else return 1 + solve(h - 1, ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2010; int n, m, k; long long sum[maxn][maxn]; char s[maxn][maxn]; long long calc(int x, int y) { if (x <= 0 || y <= 0) return 0; long long ans = 0; int a = x % n, b = y % m; ans = (1ll * x * y - 1ll * a * b) / 2; if ((__built...
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, k; cin >> t; while (t--) { cin >> k >> n; cout << n + (9 * (k - 1)) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int a[200010], b[200010], n, cnt = 0; int main() { ios::sync_with_stdio(0); cin >> n; for (int i = 2; i <= n; i++) cin >> a[i]; for (int tmp = n; tmp; tmp = a[tmp]) b[++cnt] = tmp; reverse(b + 1, b + cnt + 1); for (int i = 1; i <= cnt; i++) cou...
#include <bits/stdc++.h> using namespace std; double a[19][19]; bool bz[19]; int b[19]; double f[270000][19]; int n; int _2[19]; int main() { cin >> n; _2[0] = 1; for (int i = 1; i <= n; i++) _2[i] = _2[i - 1] * 2; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf( %l...
/** * 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 h1, h2, m1, m2, h3, m3; char s1, s2; cin >> h1 >> s1 >> m1 >> h2 >> s2 >> m2; if (h1 == 0) h1 = 24; if (h2 == 0) h2 = 24; if (m1 < m2) { h1--; m3 = m1 + 60 - m2; } else m3 = m1 - m2; if (h1 < h2) { ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int n, m; string s[100000]; int a[100000]; int b[100000]; string name; int id; vector<pair<int, string> > All; bool canMaxi(int k) { pair<int, string> He = make_pair(-a[id], name); He.first -= b[n - 1]; ...
#include <bits/stdc++.h> using namespace std; int n, sl, fh; struct node { int s, m, r, t; } a[100010]; struct seg { vector<long long> tim, pre, suf; vector<node> a; int lt; void resize(int l) { pre.resize(l); suf.resize(l); } long long getans(int T) { if (!lt) { ...
#include <bits/stdc++.h> using namespace std; clock_t T; constexpr auto EPS = 1e-7; const int mod = (int)1e9 + 7; const double pi = acos(-1); int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; long long gcd(long long a, long long b) { return (a) ? gcd(b % a, a) : b; } long...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const char nl = n ; const int MX = 100001; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t; cin >> t; for (int tt = 0; tt < (t); tt++) { int n; cin >> n; ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2007 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); `ifdef verilator // Otherwise need it in every module, including test, but that'll make a mess timeunit 1n...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; vector<int> graph[maxn]; vector<int> g[maxn]; bool mark[maxn]; int n, m; int par[maxn]; int cm[maxn]; bool comp[maxn]; int mk[maxn]; int moalefe[maxn]; void dfs(int x, int y) { mark[x] = 1; cm[x] = y; moalefe[y]...
#include <bits/stdc++.h> using namespace std; const double PI = 3.1415926535897932384626433832795; const double EPS = 1e-9; const int MAX_NUMBER = 25 * 1000 * 1000; const int ROOT = 10000; bool isPrime[MAX_NUMBER]; int primesAmount; bool canMult(int a, int b) { if (b == 0) { return true; }...
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) const int MAX_N = 1000009; const long long mod = 998244353; long long modpow(long long a, long long b, long long m) { long long p = 1, q = a; for (int i = 0; i < 32; i++) { if ((b / (1LL << i)) % 2 == 1) { p *=...
#include <bits/stdc++.h> using namespace std; void solve(int n, int k) { int i; for (i = 1; i <= 2 * k; ++i) if (i & 1) printf( %d %d , 2 * i - 1, 2 * i); else printf( %d %d , 2 * i, 2 * i - 1); for (i = 4 * k + 1; i <= 2 * n; ++i) printf( %d , i); putchar( n ); } ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Iztok Jeras. module t (/*AUTOARG*/ // Inputs clk ); input clk; // parameters for array sizes localparam WA = 4; // address dimension size localparam WB...
#include <bits/stdc++.h> using namespace std; int firstOne(string s) { int len = s.length(); for (int i = len - 1; i >= 0; i--) { if (s[i] == 1 ) { return len - i; } } } int firstOneAfter(string s, int idx) { int len = s.length(); for (int i = len - idx; i >= 0; i--) { ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2021 by Krzysztof Bieganski. // SPDX-License-Identifier: CC0-1.0 `define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__L...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2008 by Wilson Snyder. `include "verilated.v" module t; // Note $sscanf already tested elsewhere reg [3:0] n; reg [63:0] q; reg [16*8:1] wide; reg [8:1] ochar; ...
/* * 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...
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); while (n--) { int tenth = 10; int F = 0; char input[15]; char A[15] = { 0, }; scanf( %s , input); for (int i = 4; i < strlen(input); i++) A[i - 4] = input[i]; for (int i = 1; i < strlen(...
// ============================================================== // RTL generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.2 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // =========================================================== `timescale 1 ns / 1 ps (* CO...
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define int long long int #define double long double #define endl n const int mod = 1000000007; using namespace std; int modExpo(int x , int n) { int ans = 1; while (n > 0) { if ( n & 1 ==...
`timescale 1ns / 1ps module DE0_NANO_SOC_Default(); wire [31:0] cpuDataOut; wire [31:0] cpuDataIn; wire [31:0] cpuDataInAddr; wire [31:0] cpuDataOutAddr; wire cpuWrEn; wire [31:0] instrBus; wire [31:0] pcBus; wire [31:0] CPU_StatusBus; wire forceRoot; wire flushing; wire [31:0] instrCacheAddr; wire [...
#include <bits/stdc++.h> using namespace std; int main(void) { int n, max_len = 0, tmpl, tmpr; pair<int, int> fmaxl, fminr, smaxl(-1, -1), sminr(-1, -1); cin >> n >> tmpl >> tmpr; fmaxl = make_pair(tmpl, tmpr); fminr = make_pair(tmpl, tmpr); for (int i = 1; i < n; i++) { cin >> tmpl >>...
#include <bits/stdc++.h> using namespace std; long long f[20]; vector<long long> lu; void go(int x, int y, long long p) { if (x == y) return; lu.push_back(p * 10 + 4); lu.push_back(p * 10 + 7); go(x, y + 1, p * 10 + 4); go(x, y + 1, p * 10 + 7); } bool ok(long long x) { if (!x) retur...
// -- (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...
//Legal Notice: (C)2017 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> int main() { int n, mxpos = 0, mx = 0, temp, i; scanf( %d , &n); int p[n]; for (i = 0; i < n; i++) { scanf( %d , &p[i]); if (mx < p[i]) { mx = p[i]; mxpos = i; } } int loopno = 0, j; int notsorted = 1; while (notsorted) { ...
#include <bits/stdc++.h> using namespace std; char a[6][6]; char tl[2] = { x , o }; int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; bool judge(int x, int y, int nu) { for (int i = 0; i < 8; i++) { int xx = x + dx[i]; int yy = y + dy[i]; if (a[xx][yy] ...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const long long INF = 1e18; const int N = 100010; struct E { int to, nxt; } e[N << 3]; vector<int> a[N]; int n, m, head[N], cnt, f[N], ans[N], t, g[N]; int Write[20]; int read() { int d = 0, f = 1; char c = getchar(); ...
#include <bits/stdc++.h> using namespace std; bool isPrime(int n) { if (n <= 3) { return true; } if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } int main() { ios_base::sync_wit...
/* 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...
/* * 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; long long n, i, j, m, x, c, count, nr, OK, suma, k, level, val, y[100], z; void inmultire_y(long long nr) { int i = 0; int j = 0; int Max = 0; for (; i < 100; i++) y[i] = 0; long long x2 = nr; int n = 0; while (x2) { n++; x2 /= ...
// (c) Copyright 1995-2015 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 license and does not grant ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n, m; cin >> n; vector<int> v(2 * n), v2; for (int i = 0; i < 2 * n; i++) { cin >> v[i]; } for (int i = 0; i < 2 * n; i++) { int d = 1; ...
#include <bits/stdc++.h> template <typename Y> inline bool updmin(Y &a, Y b) { if (a > b) { a = b; return 1; } return 0; } template <typename Y> inline bool updmax(Y &a, Y b) { if (a < b) { a = b; return 1; } return 0; } template <typename Y> inline Y abs(...
module VGA_Controller( // Host Side iCursor_RGB_EN, iCursor_X, iCursor_Y, iCursor_R, iCursor_G, iCursor_B, iRed, iGreen, iBlue, oAddress, oCoord_X, oCoord_Y, // VGA Side oVGA_R, oVGA_G, oVGA_B, oVGA_H_SYNC, oVGA_...
#include <bits/stdc++.h> using namespace std; int main() { vector<set<string> > N, F; vector<pair<string, string> > ans; set<string> p; for (int i = 0; i < 26; ++i) { N.push_back(p); F.push_back(p); } int n, k, c; cin >> n; c = (int) A ; string s; for (int i = 0; ...
`timescale 1ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:33:13 04/27/2014 // Design Name: // Module Name: turbosound // Project Name: // Target Devices: // Tool versions: // Description: ...
/** * 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 = 5005; int dp[mxn][mxn], ans, n, a[mxn]; int md7[8], pos[114514]; inline void ckmax(int& x, int y) { if (x < y) x = y; } int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; for (int i = 1; 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 la...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e3 + 5; const int md = 1e9 + 7; string mat[2], pat; long long n, m, dp[2][maxn][2], pr[2][maxn][2], re, is[2][maxn][maxn], ris[2][maxn][maxn]; long long sum(long long a, long long b) { return (a + b) % md; } long long mul(long long a, l...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, m, i, a[5]; cin >> n; for (i = 0; i < 5; i++) { a[i] = n % 10; n /= 10; } n = a[3] + 10 * a[1] + 100 * a[0] + 1000 * a[2] + 10000 * a[4]; m = n; ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:536870912 ) #pragma warning(disable : 4996) using namespace std; const int N = 2e5 + 100, X[2] = {997, 449}; char s[N], t[N]; long long int h[2][N], p[2][N]; int w[N], g[N], lb[N], rb[N]; int n; pair<long long int, long long int> getH(int l, int...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0 , ch = getchar(); return s * w; } v...
/******************************************************************************* * 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; const int Maxn = 7005; const int Maxm = 1000006; int n, m; int a[Maxn], b[Maxn], c[Maxn], d[Maxn], e[Maxn]; int mn[Maxn], mx[Maxn]; bool has[Maxm]; vector<int> tk; int main() { scanf( %d %d , &n, &m); for (int i = 0; i < m; i++) { scanf( %d %...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int arr[3]; cin >> arr[0] >> arr[1] >> arr[2]; sort(arr, arr + 3); int d = arr[1] - arr[0]; d += arr[2] - arr[1]; cout << d; return 0; }
#include <bits/stdc++.h> using namespace std; long q, n, arp[3000], s, ans, ar[2100][2100]; vector<long> pp; void dfs(long a, long b) { arp[a] = 1; ans = max(ans, b); for (int i = 1; i <= n; i++) if (ar[a][i] == 1 && arp[i] == 0) { dfs(i, b + 1); } } int main() { cin >> n...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; int c[4][11][11][maxn + 5]; char s[maxn + 50]; char t[15]; int n; int getnum(char c) { if (c == A ) return 0; if (c == T ) return 1; if (c == G ) return 2; if (c == C ) return 3; } int lowbit(int x) { return x & (-...
#include <bits/stdc++.h> using namespace std; double calc(pair<double, double> v1, pair<double, double> v2) { double dx = v1.first - v2.first; double dy = v1.second - v2.second; return sqrt(dx * dx + dy * dy); } int main() { int a, b, c; scanf( %d%d%d , &a, &b, &c); double x1, y1, x2, y2...
// Copyright 2013 by Rok Krajnc // // This file is part of Minimig // // Minimig 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. // ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long n, m; cin >> n >> m; vector<long long> v, h; for (long long idx = 0; idx < n; ++idx) { long long x; cin >> x; v.push_back(x); } ...
`timescale 1ns / 1ps // Copyright (c) 2018 Cees Wolfs // // Module: int_controller // Project: Ceespu // Description: The interrupt controller, that can interrupt the processor if something happens module intr_controller( input I_clk, input I_rst, input [2:0] I_intr_rq, input I_intr...
/* * 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, k, x[105], y[105]; double s; int main(void) { cin >> n >> k; for (int i = 0; i < n; i++) cin >> x[i] >> y[i]; int j = 1; while (j < n) { s += sqrt((double)(y[j] - y[j - 1]) * (y[j] - y[j - 1]) + (double)(x[j] - x[j - 1]) ...
#include <bits/stdc++.h> using namespace std; const int ROOT = 0, MAXN = 100000; const char WHITE = 0, GRAY = 1, BLACK = 2; vector<int> graph[MAXN]; int n, m, a, b, i; char k[MAXN] = {WHITE}; inline int dfs(const int& v = ROOT) { k[v] = GRAY; int i, t, p = -1; for (i = 0; i < (int)(graph[v].si...
#include <bits/stdc++.h> using namespace std; int m, n, nums[1010][35], P[1010] = {0}, nCr[1010][1010], basis[1010][35], sz = 0, pivots[1010]; char buf[1010]; int main() { int mask = 0x1F, shift = 5; scanf( %d%d , &m, &n); for (int i = 0; i < n; i++) { scanf( %s , b...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; const int LOG = 18; int n, m, par[MAX][LOG], h[MAX]; vector<int> graph[MAX]; int par_tree[MAX], mini[MAX]; void lca_dfs(int node, int p) { if (p + 1) h[node] = h[p] + 1; par[node][0] = p; for (int k = 1; k < LOG; k++) ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << (n - 2) * (n - 2); return 0; }
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Jafet Chaves Barrantes // // Create Date: 21:25:31 04/04/2016 // Design Name: // Module Name: contadores_configuracion // Project Name: // Target Devices: // Tool versions: // D...
#include <bits/stdc++.h> using namespace std; int n, k, p[200005]; int vis[200005], cntn; int pre[200005], nxt[200005]; int flag = 0; struct node { int p, s; node(int p = 0, int s = 0) : p(p), s(s) {} bool operator<(const node &b) const { return p < b.p; } }; void del(int x) { nxt[pre[x]...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 2; int n; struct Node { int l, r; }; Node a[maxn]; bool cmp(Node x, Node y) { if (x.r == y.r) return x.l < y.l; return x.r < y.r; } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { int x, w; ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 18:13:45 02/02/2016 // Design Name: pipeline // Module Name: D:/workspace-ISE/Pipeline/pipeline_tb.v // Project Name: Pipeline // Target Device: // Tool versions: ...
/* * 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...
#include <bits/stdc++.h> using namespace std; pair<int, int> a[100000]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { int go; cin >> go; a[i].first = go; a[i].second = i; } sort(a, a + n); int an = 0; for (int i = 0; i < n; i++) { k -...
#include <bits/stdc++.h> using namespace std; int mida; void update(vector<int>& T, int p, int x) { T[mida + p] = x; for (int i = (mida + p) / 2; i > 0; i /= 2) T[i] = T[2 * i] + T[2 * i + 1]; } int suma(vector<int>& T, int a, int b, int c = 0, int d = mida - 1, int p = 1) { if (a <= c and d <= b)...
module MatrixInput #(parameter DEPTH = 256, ADDRESS_WIDTH =8, WIDTH = 8) ( Data_in, Data_out, valid, CLK, WEN, REN, RESET, Full_out, Empty_out); input wire [WIDTH-1:0] Data_in [DEPTH-1:0]; output wire [WIDTH-1:0] Data_out [DEPTH-1:0]; output wire [DEPTH-1:0] Full_out; output wire [DEPTH-1:0] Empty_out; input wire vali...
#include <bits/stdc++.h> using namespace std; int d[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}; int a, b, res; int main() { scanf( %d%d , &a, &b); for (int i = a; i <= b; i++) { int t = i; while (t) { res += d[t % 10]; t /= 10; } } printf( %d n , res); return 0; }...
#include <bits/stdc++.h> #ifdef LOCAL #include debuger.hpp #else #define DUMP(...) 1145141919810 #define CHECK(...) (__VA_ARGS__) #endif const int kN = 200000 + 5; const int INF = 0x3f3f3f3f; std::vector<int> edges[kN]; int n, q; int header[kN],dfn[kN],tim,parent[kN],sz[kN]; int depth[kN]; ...
/** * 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 INF = 1e9 + 7; const int maxn = 1e5 + 5; const int MAX = 314000000; int n, m; int dis[maxn], tot[maxn], sum[maxn], dp[maxn]; vector<int> have[maxn]; queue<int> q; priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pa...
// Copyright 2009, Brian Swetland. Use at your own risk. // Hacked by Travis Geiselbrecht, 2009-2012 /* * Copyright (c) 2011-2012 Travis Geiselbrecht * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files * (the "Software"), to deal i...
#include <bits/stdc++.h> using namespace std; int N, K; long long Time; int Free; multiset<long long> Working; int main() { scanf( %d%d , &N, &K); Free = K; Time = 0; long long S, M; for (int i = 0; i < N; ++i) { scanf( %I64d%I64d , &S, &M); S = max(S, Time); if (Free >...
/** * 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...
/** * 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 = 100010; int v[maxn], b[maxn]; int n, k; long long base, sum; int cmp(const int &i, const int &j) { return i > j; } int main() { while (scanf( %d %d , &n, &k) != EOF) { scanf( %I64d , &base); sum = 0; for (int i = 0; i < n...
#include <bits/stdc++.h> using namespace std; const int N = 100000; const double pi = acos(-1.0); int n, q, a[100100], seg[1700000], rev[1700000], tag[1700000]; char s[10]; int read() { int x = 0, f = 1; char ch = getchar(); while ((ch < 0 ) || (ch > 9 )) { if (ch == - ) f = -1; c...
/* * Copyright (c) 2002 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, m; cin >> n >> m; vector<int> vi1, vi2; for (int i = 0; i < n; i++) { int x; cin >> x; vi1.push_back(x); } sort(vi1.begin(), vi1.end()); vi1.push_back(1e9); for (int i = 0; i < m; i++) { int a, ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13:03:50 05/19/2015 // Design Name: // Module Name: control_unit // Project Name: // Target Devices: // Tool versions: // Description: // // De...
#include <bits/stdc++.h> using namespace std; int cnt[(1 << 19)], mn[(1 << 19)], mx[(1 << 19)], ans[(1 << 19)]; void solve(int L, int R) { if (L + 1 == R) { ans[L] = 0x3f3f3f3f; mn[L] = cnt[L] ? 0 : 0x3f3f3f3f; mx[L] = cnt[L] ? 0 : -0x3f3f3f3f; } else { int M = (L + R) / 2, i, H = ...
#include <bits/stdc++.h> using namespace std; int main() { int d; cin >> d; for (int i = 0; i < d; ++i) { long long n; cin >> n; if (n * (n - 4) >= 0) { cout << Y << fixed << setprecision(9) << (n + sqrt(n * n - 4 * n)) / 2 << << n - (n + sqrt(n * n - 4 * n)...