text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; char ch[100010]; int flag[26]; int main() { while (~scanf( %s , ch)) { memset(flag, 0, sizeof(flag)); flag[0] = 1; flag[ H - A ] = 1; flag[ I - A ] = 1; flag[ M - A ] = 1; flag[ O - A ] = 1; flag[ T - A ] = 1; ...
#include <bits/stdc++.h> using namespace std; int a[5005] = {0}; void ge(int a) { if (a == 1) printf( one n ); else if (a == 2) printf( two n ); else if (a == 3) printf( three n ); else if (a == 4) printf( four n ); else if (a == 5) printf( five n ); else if (...
/** * 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 int x[1000007], y[1000007], z[1000007], n; string s, S; vector<long long int> v; int main() { { long long int a = 0, b = 0, c = 0, d, e, f, g, i, j, k, l, m, p, q, r, u, w, t, tc, in, mod, loc, diff, val, sz, lo, hi, mid, ...
#include <bits/stdc++.h> using namespace std; int p[12]; int main() { long long n; cin >> n; if (n < 5) { cout << (n * (n - 1) / 2) << endl; return 0; } long long p = 5; for (int i = 1;; ++i) { if (p > n) { p /= 10; long long tot = p * 2; --i; ...
#include <bits/stdc++.h> using namespace std; long long int ar[500009], br[500009]; int main() { long long int a, b, c, i, j = 999999999999, k, e, f, g, w, h, i1, j1; string s, d; cin >> a >> b >> c; e = a; c = c * 5; j = a; for (i = 1;; i++) { a = e; if (a - (i * b) < 0) {...
/*************************************************************** * IDecoder ***************************************************************/ module idecoder( input iAZERO, input [31:0] iINST, output oWRDTA, output oWRGPR, output ...
// SystemVerilog parameter type test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2012 by Iztok Jeras. module test (); // logic vector logic [15:0] lv; // error counter bit err = 0; // system clock (does not have any real function in the test) log...
#include <bits/stdc++.h> using namespace std; int main() { long long k, n; cin >> n >> k; long long d, f = 0, f2 = 0; d = n / k; long long a[n + 1]; if (d < 3) { cout << -1 << endl; } else { while (n--) cout << ((n / k) % 2 + n) % k + 1 << ; cout << endl; } ...
//====================================================================== // // tb_blake2_G.v // ------------- // Testbench for the Blake2 G function. // // // Author: Joachim Strömbergson // Copyright (c) 2014, Secworks Sweden AB // All rights reserved. // // Redistribution and use in source and binary forms, with or /...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> prime(n + 1, 0); vector<int> div(n + 1, 0); prime[1] = 1; for (long long i = 2; i <= n; i++) { if (!prime[i]) { for (long long j = i; j <= n; j += i) { prime[j] = i; ...
`ifndef _EQ_wrap `define _EQ_wrap `timescale 1ns/1ns `include "../common_defines.v" /* * Event_Queue module * All inputs are defined in TUBOSIM spec * * PARAMETERS: * data_wd: width of single Q entry. * q_add_wd: address width of event q store element (RAM). for example * q_add_wd=5 => maximal numbers o...
/* * 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; const int N = 2e5 + 5; long long n, m, u, v, st, cnt, a[N], check[N], num[N], low[N]; long long sz[N], val[N], sub[N], good[N]; vector<int> adj[N]; vector<pair<int, int> > edge; map<pair<int, int>, bool> bridge; void dfs(int u, int p) { check[u] = 1; ...
#include <bits/stdc++.h> using namespace std; int n, m, s, C[1001][2001]; int main() { for (int i = 0; i <= 1000; i++) { C[i][0] = C[i][i] = 1; for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007; } scanf( %d%d%d , &n, &m, &s); printf( %d n , int(...
#include <bits/stdc++.h> using namespace std; const int N = 13 * 16, M = 1e9 + 7; int n, m, k; struct zz { int a[N][N]; } A; inline zz cf(zz x, zz y) { zz z; memset(z.a, 0, sizeof z.a); for (int i = 0; i < (1 << m) * (k + 1); i++) for (int j = 0; j < (1 << m) * (k + 1); j++) fo...
/** * 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; int t, n; string str; int main() { cin >> t; while (t--) { cin >> n >> str; int x = n, res = n; for (int i = 0; i < n; i++) if (str[i] == 1 ) { res = max(res, max(n + 1, 2 * max(i + 1, n - i))); } cout << re...
#include <bits/stdc++.h> using namespace std; long long begtime = clock(); template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* c...
#include <bits/stdc++.h> using namespace std; void Solve() { long long T; cin >> T; while (T--) { long long b, w; cin >> b >> w; if (b > w * 3 + 1 || w > b * 3 + 1) { cout << NO n ; continue; } cout << YES n ; long long x = 2, y = 2; while (b &...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; template <typename T> using pair2 = pair<T, T>; using pii = pair<int, int>; using pli = pair<ll, int>; using pll = pair<ll, ll>; mt19937_64 rng(chr...
// Copyright (c) 2014 Takashi Toyoshima <>. // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. module LEDSample( clk, rst_x, o_a, o_b, o_c, o_d, o_e, o_f, o_g, o_dp); input clk; input r...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; struct BIT { vector<int> tree; BIT(int sz) { tree = vector<int>(sz + 1, 0); } void upd(int idx, int v) { for (idx++; idx < tree.size(); idx ...
/** * 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() { long long int n, sum; cin >> n; long long int arr[n]; sum = 0; for (long long int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } sort(arr, arr + n); long long int curr = 0; long long int cnt = 0; lon...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d%d , &n, &m); int c[n]; memset(c, 0, sizeof(c)); while (m--) { int x, y = 0, p = 0; for (int i = 0; i < n; i++) { scanf( %d , &x); if (x > y) { y = x; p = i; } ...
// test_psi2c.v `timescale 1 ns / 1 ps module tbm_hub ( input scl, input sda, output rda ); reg [4:0]hub = 20; reg [2:0]port = 1; reg tbm_rw = 0; reg [6:0]tbm_reg = 7'h12; reg [7:0]tbm_dat = 8'h5a; reg gate = 0; reg [5:0]count = 0; always @(negedge sda) if (scl) gate <= 1; al...
module register_io (clk, reset, enable, addr, datain, dataout, debugbus, addr_wr, data_wr, strobe_wr, rssi_0, rssi_1, rssi_2, rssi_3, threshhold, rssi_wait, reg_0, reg_1, reg_2, reg_3, atr_tx_delay, atr_rx_delay, master_controls, debug_en, interp_rate, decim_rate, atr_mask_0, atr_txval_0, atr_rxval_0, at...
module ByteMuxOct ( (* intersynth_conntype = "Byte" *) input[7:0] A_i, (* intersynth_conntype = "Byte" *) input[7:0] B_i, (* intersynth_conntype = "Byte" *) input[7:0] C_i, (* intersynth_conntype = "Byte" *) input[7:0] D_i, (* intersynth_conntype = "Byte" *) input[7:0] E_i, (* intersynth_conntype ...
// 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 : Wed May 31 20:13:47 2017 // Host : GILAMONSTER running 64-bit major release (...
/* * 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:58:14 05/23/2014 // Design Name: // Module Name: add_32bits // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: //...
/** * 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_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, s = 0, c = 0; cin >> n; for (long long int i = 0; i < n; i++) { long long x; cin >> x; s += x; if (x % 2 != 0) c = 1; } if ...
/* * 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 Header Begin ========================================== // // OpenSPARC T1 Processor File: i2c_fdp.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/or //...
//deps: sdram_controller3.v, IS42S16160.v `timescale 1ns/1ps module sdram_controller3_tb; /*AUTOWIRE*/ // Beginning of automatic wires (for undeclared instantiated-module outputs) wire [12:0] DRAM_ADDR; // From controller of sdram_controller3.v wire [1:0] DRAM_BA; ...
/** * 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 = 200200; int n; int a[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } int cnt_0 = 0, cnt_neg = 0, pos = -1; vector<int> used(n); for (int i = 0; i <...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, N = 2e5 + 5; const long long inf = 1e18; inline int read() { int sum = 0, f = 1; char c = getchar(); while (c > 9 || c < 0 ) { if (c == - ) f = -f; c = getchar(); } while (c >= 0 && c <= 9 ) sum = su...
#include <bits/stdc++.h> using namespace std; const int Maxn = 1e5 + 7; int H, ans; int cnt[10007][444], a[Maxn], flag[Maxn]; int mark[Maxn]; vector<int> luck; void lucky(int p) { if (p > 10000) return; luck.push_back(p); mark[p] = true; p *= 10; lucky(p + 4); lucky(p + 7); } v...
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; const int MAXM = 105; const int inf = 0x3f3f3f3fLL; struct NODE { long long a, b; int c, id; }; struct ANS { int prei, prej, prek; long long val; ANS() {} ANS(int _i, int _j, int _k, long long _val) : prei(_...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int found; string s = +------------------------+ ; string r1 = |#.#.#.#.#.#.#.#.#.#.#.|D|) ; string r2 = |#.#.#.#.#.#.#.#.#.#.#.|.| ; string r3 = |#.......................| ; string r4 = |#.#.#.#.#.#.#.#...
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T> inline void gmax(T &a, T b) { if (b > a) a = b; } template <class T> inline void gmin(T &a, T b) { if (b < a) a = 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 law...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100; const int M = 26; const long long mod = 1e9 + 7; const long long MOD = 998244353; const int P = 1336; const long double eps = 0.000000001; const long long inf = 1e18 + 7; mt19937 gen(time(0)); vector<int> g[N]; int sz[N], a[N];...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, ans = 0, a, b = 0, N; cin >> N; for (long long i = 1; i <= 1e6; i++) { n = N; a = i * 2; n -= a; b = ((i - 1) * (i * 3) / 2); n -= b; ...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T pow(T a, T b, long long m) { T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; ...
#include <bits/stdc++.h> using namespace std; bool m(int i, int j) { return (i % 10) > (j % 10); } int main() { int x, y; cin >> y >> x; vector<int> vi; int i = 0, j = 0; int k = 0; for (i = 0; i < y; i++) { cin >> j; k += (j % 10); vi.push_back(j); } sort(vi.begi...
#include <bits/stdc++.h> using namespace std; int a[200000], b[200000], c[200000]; int main() { int n, i, j, max1 = -1; scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d , &a[i]); b[0] = 1; for (i = 1; i < n; i++) { if (a[i] > a[i - 1]) { b[i] = b[i - 1] + 1; } else ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(); int n; cin >> n; int t; int speed = 0; int ans = 0; int c = 0; int bs; stack<int> s; cin >> t >> speed; for (int i = 1; i < n; i++) { cin >> t; if (t ==...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if (n == 1) cout << 1; else if (abs(n - m) > abs(m - 1)) { cout << m + 1; } else { cout << m - 1; } }
`timescale 1ns/100ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit must be 1 10 or 100 * -base is the time base for each unit, ranging from seconds * to femtoseconds, and must be...
#include <bits/stdc++.h> const int maxn = 1e5 + 10; const int N = 2e5; using namespace std; long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); } long long qmul(long long p, long long q, long long mo) { long long f = 0; while (q) { if (q & 1) f = (f + p) % mo; p = ...
#include <bits/stdc++.h> using namespace std; int main() { string s; int count = 0, count1 = 0; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] >= 97 && s[i] <= 122) count++; else count1++; } if (count >= count1) { for (int i = 0; i < s.size(); i++) ...
#include <bits/stdc++.h> using namespace std; int mod = 1000000007; const int inf = 1034567891; const long long LL_INF = 1234567890123456789ll; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << : << arg1 << n ; } template <typename Arg1, typename... Args> voi...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, t; cin >> n >> t; string s; cin >> s; char temp; while (t--) { for (int i = 0; i < n - 1; i++) { if (s[i] != s[i + 1] && s[i] == B ) { temp = s[i + 1]; s[i + 1] = s[i]; s[...
////////////////////////////////////////////////////////////////////// //// //// //// eth_clockgen.v //// //// //// //// This file is part of the Ether...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int low = 0, up = 0; for (int i = 0; i < s.size(); i++) { if (s[i] < 93) { up++; } else { low++; } } if (low >= up) { for (int i = 0; i < s.size(); i++) { s[i] = tol...
/* * 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() { int n, k; cin >> n >> k; if (n < k * 1ll * (k + 1) / 2) { cout << NO << endl; return 0; } int nn = n - k * (k + 1) / 2; vector<int> a(k); for (int i = 0; i < k; ++i) { a[i] = i + 1 + (nn / k) + (i >= k - nn % ...
#include <bits/stdc++.h> using namespace std; long long a[10]; int n; int cnt[10], sump; vector<long long> tree; int rec(int cur, int trees, int treessum) { if (cur > n) return treessum + (trees > 1) + n - sump; int ans = (int)1e9; for (int i = 0; i < tree.size(); ++i) if (tree[i] % a[cur]...
#include <bits/stdc++.h> using namespace std; char mainstr[111111]; char substr1[111]; char substr2[111]; int main() { while (scanf( %s %s %s , mainstr, substr1, substr2) != EOF) { bool flag1 = false, flag2 = false; int len = strlen(mainstr); int len1 = strlen(substr1); int len2 = ...
#include <bits/stdc++.h> using namespace std; int arr[50100]; int tmp[50100]; int ans[50100]; map<int, bool> vis; int n; bool Check(int mid) { vis.clear(); for (int i = 1; i <= n; ++i) { tmp[i] = arr[i]; while (tmp[i] > mid) tmp[i] >>= 1; if (tmp[i] == 0) return false; whil...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * ------------------------------------------------------------------------------- * * Tree Matrix Arbiter * * - 'multist...
#include <bits/stdc++.h> using namespace std; int m, l, r, a[1200000]; string s; int main() { cin >> s; m = s.size(); l = 1; r = m; for (int i = 0; i < m; i++) if (s[i] == l ) { a[r] = i + 1; r--; } else { a[l] = i + 1; l++; } for (int i...
#include bits/stdc++.h using namespace std; const int MAXN = 3e5+10; int cores[MAXN]; int pos[51]; int n, m; int solve(int cor){ int ans = pos[cor]; for(int i = 1; i <= 50; i++){ if(pos[i] < pos[cor] && pos[i]) pos[i]++; } pos[cor] = 1; return ans; } ...
/** * 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; void solve() { int n; cin >> n; int a[n], b[n]; map<pair<int, int>, int> mpa, mpb; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } for (int i = 0, j = n - 1; i < j; i++, j--) { ...
// Double buffering with dual-port RAM // Uses single-port RAM to write switches to a section while reading from the same section to control LEDs, // so each switch acts as if connected directly to the corresponding LED. // Flip SW0 to change sections. module top ( input clk, input [15:0] sw, ...
/* SPDX-License-Identifier: MIT */ /* (c) Copyright 2018 David M. Koltak, all rights reserved. */ // // Tawas Module Toplevel: A simple multi-threaded RISC core. // `define RTL_VERSION 32'hB0010001 module tawas ( input clk, input rst, output ics, output [23:0] iaddr, input [31:0] idata, out...
#include <bits/stdc++.h> using namespace std; uint64_t log4(uint64_t n) { return log2(n) / 2; } uint64_t getA(uint64_t triple) { if (triple == 0) { return 1; } uint64_t doubleBits; if (triple == 1) { doubleBits = 1; } else { doubleBits = log4(triple * 3 + 1); } uint64...
/** * 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 dx[] = {1, 0, -1, 0}; const int dy[] = {0, -1, 0, 1}; const double EPS = 1e-9; const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int daysleap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int n, k; ...
//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved. //////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor: Xilinx // \ \ \/ Vers...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > g[100005]; long long n, ans, ans2; void dfs(long long u, long long p, long long cur) { ans2 = max(ans2, cur); for (auto e : g[u]) if (e.first != p) dfs(e.first, u, cur + e.second); } signed main() { ios_base:...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); } return f...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int a = 0, b = 0; int i, j; int n = s.size(); for (i = 1; i < n; ++i) { if (s[i] == b && s[i - 1] == a ) { ++a; } if (s[i] == a && s[i - 1] == b ) { ++b; } } ...
// file: pll_tb.v // // (c) Copyright 2008 - 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 lic...
#include <bits/stdc++.h> using namespace std; int cnt2 = 0; int en = 0; struct Dinic { static const int MXN = 100000; struct Edge { int v, f, re; Edge(int a, int b, int c) : v(a), f(b), re(c) {} }; int n, s, t, level[MXN]; vector<Edge> E[MXN]; void init(int _n, int _s, int _t...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 55; int x[MAX]; int main() { int n; cin >> n; double sum = 0; int a[n + 1]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n, greater<int>()); for (int i = 0; i < n; i++) { if (i % 2 == 0) sum += ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 5, mod = 1e9 + 7; long long n, k, pre[N], suf[N], fac[N], qx[N], qy[N]; long long mul(long long x, long long n, long long mod) { long long ans = mod != 1; for (x %= mod; n; n >>= 1, x = x * x % mod) if (n & 1) ans = ans * x % ...
`timescale 1ns / 1ps module fifo_test(); parameter WIDTH = 8; parameter DEPTH = 12; `include "dut.v" integer i; reg [WIDTH-1:0] tempdata; reg tempstart; reg tempend; initial begin #15 reset = 0; fork data_in.sync_write(8'hAA); data_in_start.sync_write(1); join for ( i = 1; i < 100...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 18:52:13 02/22/2015 // Design Name: // Module Name: Pack_z // Project Name: // Target Devices: // Tool versions: // Description: // // Dependen...
/** * 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 i, j = 0, k = 0, l = 0, m = 0, n, t = 0, sum = 0, r = 0, q = 0, p = 0, z = 0; int a[2000005]; vector<int> v; int main() { ios_base::sync_with_stdio(false); string s, f, g; cin >> m >> f >> g; n = g.size(); if (g[n - 1] ...
#include <bits/stdc++.h> using namespace std; bitset<101> b; int number; vector<int> primes; void sieve() { b.set(); b[0] = 0; b[1] = 1; for (int i = 2; i <= number; i++) { if (b[i] == 1) { primes.push_back(i); for (int j = i * i; j <= number; j += i) b[j] = 0; } ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long sum = 1; long long sum1 = 0; long long sum2 = 0; long long cnt1 = 0; long long cnt2 = 0; long long res = ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, b; cin >> n >> b; std::vector<long long int> v(n); long long int maxp = 0, minp = 0; long long int m1, m2 = 0; for (long long int i = 0; i < n; ++i) { cin >> v[i]; if (i == 0) m1 = v[i]; if (m2 < v[...
#include <bits/stdc++.h> using namespace std; const int Maxn = 200010; const int inf = 2147483647; const double pi = acos(-1.0); int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <=...
#include <bits/stdc++.h> using namespace std; int main() { int a[1000], b, c, d; cin >> b >> c >> d; a[0] = b; a[1] = c; for (int i = 2; i <= d; i++) { a[i] = a[i - 1] + a[i - 2]; } cout << a[d]; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using pi = pair<ll, ll>; const ll inf = 0x3f3f3f3f3f3f3f3f; const ll minf = 0xc0c0c0c0c0c0c0c0; ll A[400400]; ll B[400400]; inline bool between(ll le, ll ri, ll first) { return le <= first && first <= ri; } signed main() { i...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:57:00 09/29/2016 // Design Name: // Module Name: vga_controller // 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; int n, i, j; pair<pair<int, int>, int> a[100002]; bool lav(int i) { int x1, u1, x2, u2, x3, u3; x1 = a[i].first.first; u1 = a[i].first.second; x2 = a[i + 1].first.first; u2 = a[i + 1].first.second; x3 = a[i + 2].first.first; u3 = a[i + 2]...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long n, m, a, b, c, k, temp, x, y; const int MAXN = 1e5 + 11, mod = 1e9 + 7; inline long long max(long long a, long long b) { return ((a > b) ? a : b...