text
stringlengths
59
71.4k
module Processor(input clock, input clear); // PC register wire[31:0] pc_in; wire[31:0] pc_out; PcRegister pc_register( clock, clear, pc_in, pc_out); // Instruction memory wire[31:0] instruction_memory_address; wire[31:0] instruction_memory_instr; InstructionMemory instruction_memory( clock, ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x, y; cin >> x >> y; int u = 0, v = 0, turns = 0, flag = 1, c = 1; while (1) { if (u == x and v == y) break; if (flag == 1) { int d = 0; while (d != c) ...
module charComp(char, enter, cEnter, cEne, cVirgul, cDelete, cNum); input [6:0] char; input enter; output reg cEnter, cEne, cVirgul, cDelete,cNum; always @(char or enter) begin if(enter==0) begin case (char) 7'b0000100:begin cEnter=1; cEne=0; cVirgul=0; cDelete=0; cNum=...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; char c; cin >> n >> m; vector<int> rows(n), cols(m); vector<vector<bool> > A(n); for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) { cin >> c; if (c == * ) { A[i].push_back(true); ...
#include <bits/stdc++.h> using namespace std; void _fill_int(int* p, int val, int rep) { int i; for (i = 0; i < rep; i++) p[i] = val; } int N, M, K; signed long long mo = 1000000007; int L, R; string LL, RR; vector<string> S; int V[201]; vector<vector<int> > TR; vector<int> AC; signed lo...
////////////////////////////////////////////////////////////////////// //// //// //// serialInterface.v //// //// //// //// This file is part of the ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; scanf( %lld , &n); long long int i; for (i = 2; i * i <= n; i++) { while (n % (i * i) == 0) n /= i; } printf( %lld n , n); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 500 + 10; const int INF = 0x3f3f3f3f; const int mod = 1000000007; int n, m; int a[maxn][maxn], b[maxn][maxn]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; ...
/** * 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; int a[300], ans[500][2], tot, v[300]; void sl(int p, int x) { if (p == x || x == 0) return; if (a[x] == 0 || a[x] == x) { ans[tot][0] = p, ans[tot][1] = x; a[x] = x; a[p] = 0; tot++; return; } if (v[x]) { ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long MOD = 998244353; long long INF = 1e18; const int N = 100001; long long dp[N][101]; long long sm[N]; long long cnt[N][...
#include <bits/stdc++.h> using namespace std; int Ask(int x, int y) { printf( ? %d %d n , x, y); fflush(stdout); int t; scanf( %d , &t); return t; } int vis[105], t[105], n; struct bt { bitset<105> A; int id; int operator[](int x) { return A[x]; } friend bool operator<(bt x...
#include <bits/stdc++.h> using namespace std; const int N = 2055, mod = (int)1e9 + 7; template <class o> void qr(o &x) { char c = getchar(); x = 0; while (!isdigit(c)) c = getchar(); while (isdigit(c)) x = x * 10 + c - 0 , c = getchar(); } int n, m, L, last[N], ys[N], tot, vis[N], col[N]; ...
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const long long INFL = LLONG_MAX; int N, ans, P[100100], ord[100100]; int comp(int a, int b) { return P[a] > P[b]; } int main() { ios_base::sync_with_stdio(0); cout.precision(15); cin >> N; for (int(i) = 1; (i) <= (N); (i...
#include <bits/stdc++.h> using namespace std; bool ansnull(int a, int b, int c, int d) { int ans = 0; if (a != 0) ++ans; if (b != 0) ++ans; if (c != 0) ++ans; if (d != 0) ++ans; if (ans >= 2) return true; else return false; } int main() { int a[100010][5]; int n, ...
#include <bits/stdc++.h> using namespace std; int q_pow(int x, int n) { int ret = 1; for (; n; n >>= 1, x = (long long)x * x % 998244353) if (n & 1) ret = (long long)ret * x % 998244353; return ret; } int A[100005 << 2], B[100005 << 2], tmp[100005], tx[100005], ty[100005], Q, n, m; voi...
#include <bits/stdc++.h> using namespace std; int n; int l[6][6], h[6][6], a[6][6]; int in[6]; int cost; int rec(int inNode, int outNode) { if (inNode == n - 1) return 0; int bestCost = -1; for (int f = l[inNode][outNode]; f <= h[inNode][outNode]; f++) { if (in[inNode] >= f && (outNode != ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; long long sum = 0; for (int i = 0; i < n; ++i) sum += a[i]; long long cntWhite = 0; for (...
/** * 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...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: fifo_32x64a.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // ===========================================...
#include <bits/stdc++.h> using namespace std; int N, T, K; int a[200333]; int lo[200333], hi[200333]; int mid[200333]; int main() { scanf( %d%d%d , &N, &T, &K); for (int i = 1; i <= T; i++) scanf( %d , &a[i]); K = N - K - 1; for (int t = 1; t < T; t++) hi[t] = min(a[t], a[t + 1]); for (i...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. `include "verilated.v" module t; `verilator_file_descriptor file; integer chars; reg [1*8:1] letterl; reg [8*8:1] letterq; reg [16*8:1] letterw...
#include <bits/stdc++.h> using namespace std; int main() { int n; int a, b, c; cin >> n; int tong = 0, tong1 = 0, tong2 = 0; for (int i = 0; i < n; i++) { cin >> a >> b >> c; tong += a; tong1 += b; tong2 += c; } if (tong == 0 && tong1 == 0 && tong2 == 0) cou...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n * 2]; for (int i = 0; i < n * 2; i++) { cin >> a[i]; } int room = 0; for (int i = 0; i < n * 2; i++) { if (i % 2 == 0) { if (a[i + 1] - a[i] >= 2) { room++; } }...
#include <bits/stdc++.h> using namespace std; string read(char x[]) { scanf( %s , x); return x; } const int N = 8; const int M = 2e5 + 23; int n, m, x[M], y[M], ans; map<int, pair<long long, long long>> mp; void solve() { scanf( %d %d , &n, &m); for (int i = 0; i < n; i++) scanf( %d , x ...
// ============================================================================ // COPYRIGHT NOTICE // Copyright 2006 (c) Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // This confidential and proprietary software may be used only as authorised by // a licensing agreement from Latti...
#include <bits/stdc++.h> using namespace std; int n; long long A[100000 + 8], mark[20 + 8]; long long result = 0; long long getC(int n, int k) { if (n < k) return 0; if (n == k) return 1; long long result = 1; for (long long i = max(k, n - k) + 1; i <= n; i++) result *= i; return result / ...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, a[102][102]; scanf( %d , &n); ; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) scanf( %d , &a[i][j]); ; } if (i == 1) { printf( 0 n ); return 0; } for (i = 0; i < n; i++) { int f[...
// -------------------------------------------------------------------- // -------------------------------------------------------------------- // Module: sdspi.v // Description: Wishbone Compatible SPI core. // -------------------------------------------------------------------- // -------------------------------...
// v5_mig34.v // //***************************************************************************** // ____ ____ // / /\/ / // /___/ \ / Vendor: Xilinx // \ \ \/ Version: 3.4 // \ \ Application: MIG // / / Filename: mig_v3_4.v // /___/ /\ Date Last Modified: $Date: 2009/11/...
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int n, k; cin >> n >> k; if(2 * k + 1 > n) { cout << -1 n ; return; } vector<int> v(n); int p = n; for(int i = 1; i < 1 + 2 * k; i += 2) v[i] = p--; ...
#include <bits/stdc++.h> using namespace std; long long P = 998244353; double PI = 3.141592653589793; const int sqr = 500; const int arrn = 2e5 + 5; const int arrn2 = 1e3 + 5; long long inv[arrn] = {}; long long fac[arrn] = {}; void prefinv(int n, int p) { inv[0] = 1; inv[1] = 1; fac[1] = ...
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2019 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \VV/ *********...
#include <bits/stdc++.h> using namespace std; const long long N = 1005; int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}; int dy[] = {0, 0, 1, -1, 1, -1, 1, -1}; string toBinary(int x) { string ret = ; while (x) { ret = (x & 1 ? 1 : 0 ) + ret; x >>= 1; } while (((int)(ret).size()) < 8) ...
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265359; const long long MOD = (long long)998244353ll; const long long MAXN = (long long)3e5 + 10; const long long INF = (long long)2242545357980376863; const long double EPS = (long double)1e-8; long long source[MAXN], d0[MAXN], d...
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 10; const long long mod = 1e9 + 7; long long ans; long long n, k; long long a[maxn]; long long z; long long inv[maxn]; long long fact[maxn]; long long pashm[maxn]; void in(); void solve(); long long pwr(long long, long ...
#include <bits/stdc++.h> using namespace std; char arr[300001]; int main(void) { int N; scanf( %d , &N); scanf( %s , arr); int i; char _max = 0; int idx = -1; for (i = 0; i < N; i++) { if (_max < arr[i]) { _max = arr[i]; idx = i; } if (idx != -1 && _ma...
// (C) 2001-2018 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 from any of the foregoing (including device programming or simulation // files), and any associated ...
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; int sz = n + m - 2; int mid = sz / 2; int x; vector<pair<int, int>> a(mid + 1, {0, 0}); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> x; int id = i + j; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { long long n, k; cin >> n >> k; long long ans = 0; while (n != 0) { if (n % k == 0) { n /= k; ans++; } else { ans += n % k; ...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; vector<long long> arr(n, 0); vector<long long> pref(n, 0); vector<long long> suff(n, 0); map<long long, long long> pre; map<lo...
#include <bits/stdc++.h> using namespace std; const double PI = 3.1415926535; double cot(double x) { return cos(x) / sin(x); } int main() { double r, n; cin >> n >> r; cout << fixed << setprecision(9) << n * r * r * sin(PI / n) / (1 + 2 * cos(PI / n)); return 0; }
////////////////////////////////////////////////////////////////////// //// //// //// eth_shiftreg.v //// //// //// //// This file is part of the Ether...
#include <bits/stdc++.h> using namespace std; int parent[5001][5001]; int dp[5001][5001]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, m, t; cin >> n >> m >> t; vector<int> u(m + 1), v(m + 1), tm(m + 1); for (int i = 1; i <= m; i++) { cin >> u[i] >> v[i] ...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 3; map<int, vector<int>> sign; int a[MAX]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; multiset<int> st; for (int i = 1; i <= n; i++) { cin >> a[i]; st.insert(a[i...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int S = 320; int a[N]; int dp[S + 1][N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int q, p, k; cin >> q; for (int j = 1; j <= S; j++) { for (int i = n; i >= 1; i--) { ...
#include <bits/stdc++.h> using namespace std; int a[100000]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int cnt = 0; if (a[0] != 0) cnt = 1; for (int i = 1; i < n; i++) { if (a[i] != 0) { if (a[i] != a[i - 1]) cnt++; } ...
#include <bits/stdc++.h> using namespace std; double A[200009]; double B[200009]; int main() { int N, i; cin >> N; for (i = 0; i < N; i++) { cin >> A[i]; } B[0] = A[0]; for (i = 1; i < N; i++) { B[i] = (B[i - 1] + 1) * A[i]; } double sum = 0; for (i = 0; i < N; i+...
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } char s[1000009], t[1000009]; int cnt...
#include <bits/stdc++.h> using namespace std; const long double pi = 2 * acos(0.0); long long infinity = std::numeric_limits<long long>::max(); long long binary_search(long long dp[], long long n, long long p) { long long l, r, mid; l = 0; r = n - 1; sort(dp, dp + n); while (l <= r && l >= 0...
//***************************************************************************** // (c) Copyright 2008-2009 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 // ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: rulefifo_64_32.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ============================...
#include <bits/stdc++.h> using namespace std; int main() { int a, sum = 0; string s; cin >> a; for (int i = 0; i < a; i++) { cin >> s; if (s == Tetrahedron ) sum = sum + 4; else if (s == Cube ) sum = sum + 6; else if (s == Octahedron ) sum = sum + 8...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template <typename T> inline bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const int N = 3e5 + 10, P = 998244353; int n, c[N]; int add(int ...
/* * 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 inf = 1e9; const int N = 142123; int n, a, b, c, d, s, ce; long long ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> a >> b >> ce >> d; for (int i = 1; i <= n; ++i) { s = a + b + i; c = s - a - ce; ...
#include <bits/stdc++.h> using namespace std; inline void open(const char *s) {} inline int rd() { static int x, f; x = 0; f = 1; char ch = getchar(); for (; ch < 0 || ch > 9 ; ch = getchar()) if (ch == - ) f = -1; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ch - ...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * * (C)2012 Korotkyi Ievgen * National Technical University of Ukraine "Kiev Polytechnic Institute" * ------------------...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; wire [1:0] a = crc[1 +: 2]; wi...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e; cin >> a >> b >> c >> d >> e; if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0) cout << -1; else if ((a + b + c + d + e) % 5 != 0) cout << -1; else cout << (a + b + c + d + e) / 5; return 0; }...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long p1, p2, p3; cin >> p1 >> p2 >> p3; cout << (p1 + p2 + p3) / 2 << endl; } }
// -*- Mode: Verilog -*- // Filename : adxl362_testbench.v // Description : Testbench for proving ADXL362 Model works // Author : Philip Tracton // Created On : Wed Jun 22 21:42:09 2016 // Last Modified By: Philip Tracton // Last Modified On: Wed Jun 22 21:42:09 201...
#include <bits/stdc++.h> using namespace std; struct number { long long sum, a, b; bool operator<(const number& in) const { return sum < in.sum; } bool operator>(const number& in) const { return sum > in.sum; } }; vector<number> v; const long long MN = 2000 + 1; long long a[MN], b[MN]; long lo...
#include <bits/stdc++.h> using namespace std; namespace my_useful_tools { const int INF = 0x3f3f3f3f; inline void pc(char c) { putchar(c); } template <class T> inline T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <class T> inline void W(T p) { if (p < 0) pc( - ), p = -p; ...
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; string conv(int n) { string kq = ; while (n != 0) { int r = n % 26; if (r == 0) r = 26; kq = char(r - 1 + A ) + kq; n = (n - r) / 26; } return kq; } int conv(string s) { int kq = 0; int ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100100; string S; int N; int Z[MAXN]; int len[MAXN]; void Zalg() { int L = 0, R = 0; for (int i = 1; i < N; i++) { if (i > R) { L = R = i; while (R < N && S[R] == S[R - L]) R++; Z[i] = R - L; R--; ...
// This file has been automatically generated by goFB and should not be edited by hand // Compiler written by Hammond Pearce and available at github.com/kiwih/goFB // Verilog support is EXPERIMENTAL ONLY // This file represents the Basic Function Block for BfbWaterPump //defines for state names used internally `defin...
#include <bits/stdc++.h> using namespace std; void solve() { long long n, k; cin >> n >> k; vector<long long> a(n); for (long long &i : a) cin >> i; sort(a.begin(), a.end()); a.resize(unique(a.begin(), a.end()) - a.begin()); n = a.size(); if (k == 1 and n > 1) { cout << -1 << e...
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \VV/ *********...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02:31:10 03/06/2017 // Design Name: XOR // Module Name: D:/Projects/XilinxISE/HW1/Homework1/testXOR.v // Project Name: Homework1 // Target Device: // Tool versions...
#include <bits/stdc++.h> using namespace std; int n; int m; struct st { int dp; int maxt; int cnt; bool use; st() { dp = maxt = cnt = 0; use = false; } }; vector<st> dp[123457]; vector<int> v[123457]; vector<int> nex[123457]; bool oc[123457]; bool visited[123457];...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c != - && (c < 0 || c > 9 )) c = getchar(); if (c == - ) f = -1, c = getchar(); while (c >= 0 && c <= 9 ) x = x * 10 + c - 0 , c = getchar(); return f * x; } const int...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> n >> m >> k; map<int, bool> mp; for (int i = 0; i < m; i++) { int x; cin >> x; mp[x] = 1; } int pos = 1; int ans = -1; if (mp[pos]...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n % 2 << n ; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, t; cin >> n >> t; vector<int> a(n); for (int& ai : a) cin >> ai; auto build = [&](int t) { vector<int> ret; while (t--) { ret.insert(end(ret), begin(a), end(a));...
// 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 : Mon Feb 20 14:00:27 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; const int tmw168 = 1e5; long long a, b, p, q, invp; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } long long test(long long r) { r = r * invp % q; r += a / q * q; if (r < a) r += q; return r; } ...
module Coprocessor0( input clk, input[4:0] C0adr, input[31:0] C0Wdata, input C0Write, input[31:0] InteCause, input Interrupt, output InteAccept, output[31:0] C0State, output reg[31:0] C0Data ); parameter EPCadr = 5'h0; parameter Causeadr = 5'h1; parameter Stateadr = 5'h2; reg[3...
////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2009 Xilinx, Inc. // This design is confidential and proprietary of Xilinx, All Rights Reserved. ////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / ...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ // IMPORTANT: This requires an input text file named "rf1.fill" // Include definition of the control signals `include "control.h" // Non-synthesizable behavioral RTL model for the instruction memory modu...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; const int maxm = 100005; typedef int arr[maxn]; arr head, dfn, low, col, st; int top, depth, color, tot, cnt; pair<int, int> e[maxm * 2], bridge[maxn]; int euler[maxn * 2], d[maxn * 2][30], pos; void add(int x, int y) { e[tot] ...
//Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 //Date : Sun Sep 22 02:31:57 2019 //Host : varun-laptop running 64-bit Service Pack 1 (bui...
#include <bits/stdc++.h> using namespace std; bool isprime(long long n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; for (int i = 3; i * i <= n; i = i + 2) { if (n % i == 0) return false; } return true; } int main() { int w, h, k; cin >>...
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); if (n == 0) { printf( 1 ); } else if (n % 2 == 0) { if (n % 4 == 0) { printf( 6 ); } else { printf( 4 ); } } else if (n % 2 != 0) { if (n % 4 == 1) { printf( 8 ); } else { ...
#include <bits/stdc++.h> using namespace std; long long n, m, num[200001], sum[200001], ans; set<int> s; int main() { cin >> n >> m; for (int i = 0; i < m; i++) s.insert(i); for (int i = 0; i < n; i++) { int d, tmp; cin >> num[i]; d = num[i] % m; if (d > *s.rbegin()) ...
#include <bits/stdc++.h> using namespace std; char s[200005], t[200005]; vector<int> pos[200005]; int main() { int T; scanf( %d , &T); while (T--) { for (int i = 0; i <= 30; i++) pos[i].clear(); scanf( %s%s , s, t); int l1 = strlen(s), l2 = strlen(t); int now = -1, ans = 0; ...
#include <bits/stdc++.h> using namespace std; struct s { char g; long s, e; }; int main() { long n, i, j, c, ans = 0, day = 0, m = 0, f = 0; struct s a[5005]; cin >> n; for (i = 0; i < n; ++i) cin >> a[i].g >> a[i].s >> a[i].e; for (day = 1; day <= 366; ++day) { m = 0; f ...
//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved. //////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor: Xilinx // \ \ \/ Version : ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; ; while (t--) { int a, b, c, d; cin >> a >> b >> c >> d; if ((a == c) && (b + d == a)) cout << YES << endl; else if ((a == d) && (b + c == a)) cout << YES << endl; else if ((...
#include <bits/stdc++.h> using namespace std; const int N = 2002; int n, a[N][N], c[N], p[N], t, A; string s[N]; bool C() { for (int i = 1; i <= n; i++) p[i] = c[i]; sort(p + 1, p + n + 1), t = 0; for (int i = 1; i < n; i++) { t += p[i]; if (t == i * (i - 1) / 2) return false; } ...
#include <bits/stdc++.h> using namespace std; long long ts, tf, t, n, x, ans, lim = 1000000000007; int main() { cin >> ts >> tf >> t; cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (x <= tf - t) { if (max(ts, x - 1) <= tf - t && ts - (x - 1) < lim) { lim = ts - (x -...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double esp = 0.0000000001; const double PI = acos(-1.0); const int mod = 1e9 + 7; const int MY = 1400 + 5; const int MX = 1010 + 5; int num, n, k; vector<int> G[MX]; int d[MX * MX], g[MX][MX], vis[MX]; struct node { ...
#include <bits/stdc++.h> using namespace std; using ll=long long; using pii=pair<int,int>; int np[17][200000]; int pre[(1<<17)+1]; int main() { int n,k; cin >> n >> k; string s; cin >> s; int l=0,r=n/k; while (l<r) { int m=(l+r+1)/2; for (int j=0;j<k;...
#include <bits/stdc++.h> using namespace std; unsigned long long n, a = 1, b = 1, mod = 1000000007, pp = 1000000005; unsigned long long fp(unsigned long long n, unsigned long long p) { if (p == 0) return 1; if (p == 1) return n; unsigned long long res; res = fp(n, p / 2) % mod; res = (res * re...
#include <bits/stdc++.h> using namespace std; const int N = 200010; int n, m; char s[2020][2020]; int dp[2020][2020], a[2020][2020][2], dp1[2020][2020]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) { scanf( %s , s[i]); for (int j = 0; j < m; ++j) { if (j == 0) ...
#include <bits/stdc++.h> using namespace std; const int N = 200020, P = 1000000000; int add(int a, int b) { return a + b >= P ? a + b - P : a + b; } struct mat { int r, c, a[2][2]; void construct(int r_, int c_) { r = r_, c = c_; for (int i = 0; i < r; ++i) for (int j = 0; j < c; ++j...
#include <bits/stdc++.h> using namespace std; int a[300005]; int rev[300005]; int b[300005]; int main() { int n, m; long long ans = 0; scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); rev[a[i]] = i; } for (int i = 0; i < m; i++) { int x, y; ...
#include <bits/stdc++.h> using namespace std; const int MN = 111; int a[MN], n, g[MN][MN], c[MN]; struct Block { int f[MN][MN]; void cal1() { memset(f, 0, sizeof f); for (int from = (1), _b = (100); from <= _b; from++) { for (int to = (from), _b = (100); to <= _b; to++) f[from][to] =...
/** * 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...