text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; using lint = long long int; int main() { lint n; cin >> n; vector<lint> v(n); for (lint i = 0; i < n; i++) { cin >> v[i]; } lint val = 2 * accumulate(v.begin(), v.end(), 0ll) / n; vector<lint> visited(n); for (lint i = 0; i < n; i...
#include <bits/stdc++.h> using namespace std; const int maxm = 2e5 + 10; set<int> g; queue<set<int> > q; int m, n, x, y; int dfs(int top) { if (abs(top) <= 1) return 0; int now = 0; if ((-top) % 2 == 0) now = top / 2; else now = (top + 1) / 2; if (g.find(now) == g.end()) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, x(0); cin >> n; string s; while (n--) { cin >> s; if (s[1] == + ) { ++x; } else { --x; } } cout << x << endl; return 0; }
/* Copyright (c) 2014-2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
// Copyright (c) 2016 Min Chen // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and th...
#include <bits/stdc++.h> using namespace std; long long T; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> T; int a, b, c, d; while (T--) { cin >> a >> b >> c >> d; bool ok = 0; if (a == c) { if (d + b == a) ok = 1; } if ...
//----------------------------------------------------------------------------- // (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 int N = 1e9; const int M = 1e9; int ix, iy, fx, fy; map<pair<int, int>, int> pres; map<pair<int, int>, int> dist; map<pair<int, int>, bool> vis; int dx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; int dy[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; bool check(int x,...
/** * 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...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.1 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; double f, s, v, l, omega, r; const double tol = 1.0e-7; scanf( %d %lf %lf , &n, &r, &v); omega = v / r; double xt, xb, a, b; for (int i = 0; i < n; i++) { scanf( %lf ...
/** * 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; template <class T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); return (b == 0) ? a : gcd(b, a % b); } const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = 1 << 29; const int mod = 100000...
/** * 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...
// Taken from: // http://electrosofts.com/verilog/fifo.html `define BUF_WIDTH 4 // BUF_SIZE = 16 -> BUF_WIDTH = 4, no. of bits to be used in pointer `define BUF_SIZE ( 1<<`BUF_WIDTH ) module fifo(input clk, input reset, input [31:0] data_in, input...
/** * 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 "vscale_hasti_constants.vh" module vscale_hasti_bridge( output [`HASTI_ADDR_WIDTH-1:0] haddr, output hwrite, output [`HASTI_SIZE_WIDTH-1:0] hsize, output [`HASTI_BURST_WIDTH-1...
// DESCRIPTION: Verilator: Verilog Test module // // Use this file as a template for submitting bugs, etc. // This module takes a single clock input, and should either // $write("*-* All Finished *-*\n"); // $finish; // on success, or $stop. // // The code as shown applies a random vector to the Test // module, then ca...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2004 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=0; wire signed [7:0] sgn_wide; wire [7:0] unsgn_wide; ...
module divider(divident,divisor,quotient); input wire [31:0] divident; input wire [31:0] divisor; output reg [31:0] quotient; reg [47:0]tmpDivident; reg [23:0]tmpDivisor; reg [25:0]tmpQuotient; reg [25:0] remainder; reg [8:0]exponent; reg [8:0]tmp; integer i; // 整数,用于计数 always @(divident or divisor) ...
/** * 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...
////////////////////////////////////////////////////////////////////// //// //// //// Round function of main datapath for HIGHT Crypto Core //// //// //// //// This file is part of the HIGHT...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
/** * 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...
module PLLE2_BASE (/*AUTOARG*/ // Outputs LOCKED, CLKOUT0, CLKOUT1, CLKOUT2, CLKOUT3, CLKOUT4, CLKOUT5, CLKFBOUT, // Inputs CLKIN1, RST, PWRDWN, CLKFBIN ); parameter BANDWIDTH = 0; parameter CLKFBOUT_MULT = 1; parameter CLKFBOUT_PHASE = 0; parameter CLKIN1_PERIOD = ...
#include <bits/stdc++.h> using namespace std; long long p(long long b, long long e) { if (e == 0) return 1; if (e == 1) return b; if (e & 1) { return ((b % 998244353) * p((b * b) % 998244353, e / 2)) % 998244353; } return (p((b * b) % 998244353, e / 2)) % 998244353; } int32_t main() { ...
#include <bits/stdc++.h> using namespace std; int main() { long pos = 0; long long distance; int n, flag = 1; char dir[20]; cin >> n; for (int j = 0; j < n; j++) { cin >> distance >> dir; if (pos == 0 && strcmp(dir, South ) != 0) { flag = 0; } else if (pos == 20000...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (a != d) { cout << 0; } else if (c && !a) { cout << 0; } else { cout << 1; } return 0; }
/******************************************************************************* * 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 ...
//----------------------------------------------------------------------------- // Title : Finite Precision Symmetric Reduction module // Introduces 2 clock cycles of latency `timescale 1 ns / 100 ps module FinitePrecRndNrst #( parameter C_IN_SZ=37, C_OUT_SZ=16, C_FRAC_SZ=...
// file: ocxo_clk_pll.v // // (c) Copyright 2008 - 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 property // laws. // // DISCLAIMER // This disclaimer is not...
#include <bits/stdc++.h> using namespace std; const int Z = (int)2e6 + 111; const int inf = (int)1e9 + 111; const long long llinf = (long long)1e18 + 5; const int MOD = (int)1e9 + 7; vector<pair<int, int> > g[Z]; vector<long long> d[Z], pref[Z]; long long f[Z]; void dfs(int v) { for (auto to : g[v...
#include <bits/stdc++.h> using namespace std; long long A; vector<pair<long long, int> > ls; vector<long long> M2[100000]; vector<long long> ls2; long long my_stp(long long first, int stp) { if (stp == 0) { return 1ll; } long long res = my_stp(first, stp / 2); res = res * res; if (...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int i, j; if (k == 1 && n == 1) { cout << a ; return 0; } if (k > n || (k == 1)) { cout << -1; return 0; } i = 1; while (n - i >= k - 2) { cout << char( a + !(i % 2...
#include <bits/stdc++.h> using namespace std; const int N = 100005; struct node { long long x, s[8]; int id; } a[N]; int n, p, t; long long f[N][(1 << 8) + 5]; bool cmp(node a, node b) { return a.x > b.x; } int main() { scanf( %d%d%d , &n, &p, &t); for (int i = 1; i <= n; i++) { sc...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:54:48 02/29/2016 // Design Name: // Module Name: DivFrec // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
// $Id: c_decr.v 1534 2009-09-16 16:10:23Z dub $ /* Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source ...
/* * 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> int main() { int n, m, x, nn, j, mm, y, z, i, tmp, p; int a, b; scanf( %d%d%d%d%d%d , &nn, &mm, &x, &y, &z, &p); for (j = 1; j <= p; j++) { n = nn; m = mm; scanf( %d%d , &a, &b); x %= 4; z %= 4; if (y % 2 == 0) { for (i = 1; i <= (x ...
#include <bits/stdc++.h> using namespace std; int main() { int n; int b[200005]; vector<int> a; cin >> n; a.push_back(31); a.push_back(28); a.push_back(31); a.push_back(30); a.push_back(31); a.push_back(30); a.push_back(31); a.push_back(31); a.push_back(30); a...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.1 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = 1; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); if (f) x = -x; } template <typename F> i...
// Copyright 2020-2022 F4PGA 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Claire Xenia Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; int k; cin >> n >> k; int ar[n]; for (int i = 0; i < n; i++) { cin >> ar[i]; } sort(ar, ar + n); long long lista[n]; int cantidad[n]; int index = 0; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<ld, ld>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vector<ld>; using vs = v...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { int n, k; cin >> n >> k; string N = to_string(n); string ans = 99999999999999 ; set<char> S; for (auto c...
#include <bits/stdc++.h> struct Node { Node(int v = 1, int pos = 1e9) { min = (v == 1 ? int(1e9) : pos); } Node(Node l, Node r) { min = std::min(l.min, r.min); } int min; }; template <class i_t, class e_t> class SegmentTree { public: void init(std::vector<e_t> base) { n = base.size(); ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; string s; cin >> s; sort(s.begin(), s.end()); map<char, int> store; for (int i = 0; i < n; i++) { store[s[i]]++; } if (store.si...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.2 (lin64) Build Fri Jun 26 16:35:25 MDT 2015 // Date : Mon Nov 30 13:52:22 2015 // Host : centennial.andrew.cmu.edu running 64-bit Re...
#include <bits/stdc++.h> using namespace std; const int64_t M = 1e2 + 5; int64_t n, t[M], w[M], dp[M][20005], totalW; int64_t solve(int64_t idx, int64_t wt) { if (idx > n) { if (wt >= 0) return 0; return 1e9; } if (dp[idx][1001 + wt] != -1) return dp[idx][1001 + wt]; int64_t ans = t[...
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n == 1) cout << n; else { cout << n << ; for (i = 1; i < n - 1; i++) cout << i << ; cout << n - 1; } return 0; }
/* -------------------------------------------------------------------------- Pegasus - Copyright (C) 2012 Gregory Matthew James. This file is part of Pegasus. Pegasus is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (abs(a + c - b - d) > 1) { cout << NO n ; } else { vector<int> v(a + b + c + d); if (a + c > b + d) { for (int i = 0; i < v.size(); i += 2) { if (a) { ...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017 // Date : Tue Sep 19 00:29:40 2017 // Host : DarkCube running 64-bit major release ...
#include <bits/stdc++.h> int main() { int i, j, a = 0, b = 0, n, y; char x[10][10]; for (i = 0; i < 8; i++) scanf( %s , x[i]); for (i = 0; i < 8; i++) { n = 0; for (j = 0; j < 8; j++) { if (x[i][j] == B ) { n++; } } if (n == 8) a++; } for (i =...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = (1e-10); int main() { int tc; cin >> tc; while (tc--) { int n; cin >> n; vector<pair<int, int> > stud(n); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long n, k, l, a[1000010], m, p, q, b[1000010], d, c[1000010], f[1000010], g[1000010], ans; struct BIT { long long a[1000010]; void clear() { memset(a, 0, sizeof(a)); } void add(int x, long long v) { for ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Muhammad Ijaz // // Create Date: 05/05/2017 10:52:10 AM // Design Name: // Module Name: IMM_EXTENDER // Project Name: RISC-V // Target Devices: // Tool Versions: // Des...
/** * 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 N = 1e6 + 2; long long arr[N]; long long pos[N]; long long chance[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t, i, j; long long n; cin >> n; for (i = 1; i <= n; i++) { cin >> arr[...
//Legal Notice: (C)2015 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
/** * 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 under the Creative Commons Public Domain, for // any use, without warranty, 2018 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", ...
#include <bits/stdc++.h> using namespace std; vector<int> g[200005]; queue<pair<int, int> > q; int deg[200005], a, n; bool v[200005]; set<int> s[200005]; int main() { scanf( %d , &n); for (int i = 1; i < n; i++) { int a, b; scanf( %d%d , &a, &b); g[a].push_back(b); g[b].pus...
#include <bits/stdc++.h> using namespace std; const int MAX = 505; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; char dc[] = { R , L , D , U }; string ans; int n; bool grid[MAX][MAX], vis[MAX][MAX]; int dp[MAX][MAX][4]; bool valid(int x, int y, int dir) { return dp[x][y][dir] = ~dp[x][y...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Clifford Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * T...
/** * 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 n, k; scanf( %d%d , &n, &k); int mat[n + 1][n + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) mat[i][j] = 0; } int br = 0; for (int i = 1; i <= n; i += 2) { for (int j = 1, x = i; j <= n && x <= ...
/* * 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...
module bemicro ( // Clock inputs input wire CLK_FPGA_50M, // CLK 1 input wire RX_CLK, // CLK 4 input wire TX_CLK, // CLK 5 input wire P1, // CLK 12 / Diff CLK 7n input wire P2, // CLK 13 / Diff CLK 7p input wire P35, // CLK 14 / Diff CLK 6n input ...
//Testbench for the integer instruction pipe. module intpipe_testbench(); reg clk, pause, empty; reg [4:0] opCode; reg [3:0] a; reg [3:0] b; reg [3:0] c; reg [15:0] aDat; reg [15:0] bDat; wire [3:0] aSel; wire [3:0] bSel; wire [3:0] cSel; wire [15:0] cOut; wire cWrite; reg [15:0] ctr; //This allows me to change some ...
#include <bits/stdc++.h> using namespace std; char a[105][105]; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) for (int j = 1; j <= n; j++) cin >> a[i][j]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) cout << a[j][i] <...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int N = 3e5 + 5, M = 1e8 + 5, OO = 1000000; int T, n, m; int u, v; int deg[N]; int main() { scanf( %d , &n); for (int i = 1; i < n; ++i) { scanf( %d %d , &u, &v); ++deg[u], ++deg[v]; } for (int i = 1...
#include <bits/stdc++.h> using namespace std; #pragma optimize( -Ofast ) const int mod = 998244353; struct num { int x; num(int x_ = 0) { x = x_; } } G, _1[2222222], X[2222222], rot[2222222], inv[2222222]; inline bool operator<(const num x, const num y) { return x.x > y.x; } inline num operator+(c...
#include <bits/stdc++.h> using namespace std; int main() { int i = 0, a = 0, b = 0; string s; cin >> s; while (s[i] != 0 ) { if (s[i] >= 65 && s[i] <= 90) { a++; } else if (s[i] >= 97 && s[i] <= 122) b++; i++; } i = 0; if (a > b) { while (s[i] !=...
#include <bits/stdc++.h> using namespace std; const int maxn = 3700, maxd = 1850, mod = 998244353; int h, w, tr[maxn], tc[maxn], x, y, n; vector<int> rs, cs; long long f[maxd], c[maxn][maxn], dpr[maxn][maxd], dpc[maxn][maxd], ans; long long C(int a, int b) { if (a < 0 || b < 0 || a < b) return 0; re...
// File : ../RTL/hostController/softransmit.v // Generated : 11/10/06 05:37:21 // From : ../RTL/hostController/softransmit.asf // By : FSM2VHDL ver. 5.0.0.9 ////////////////////////////////////////////////////////////////////// //// ...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int inf = 1000000000; const long long INF = 1LL * inf * inf; const long double eps = 1e-9; const long long md = 1e9 + 7; const long double EPS = 1e-5; const long long maxll = std::numeric_limits<long long>::max(); const 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...
/* ------------------------------------------------------------------------------ * (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" * ---------------------------...
#include <bits/stdc++.h> using namespace std; pair<int, int> afis[1503]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, cnt = 0, i, x = 1; cin >> n; afis[++cnt] = {0, 0}; while (x <= n + 1) { afis[++cnt] = {x, x}; afis[++cnt] = {x, x - ...
#include <bits/stdc++.h> using namespace std; long long n, a[100001], b[100001]; vector<long long> v[100001]; signed main() { cin >> n; long long i; for (i = 1; i < n + 1; i++) { cin >> a[i]; v[a[i]].push_back(i); } bool ok = 1; long long clr = 1; for (i = 0; i < 100001; ...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::pair<T, U> operator+(const std::pair<T, U>& l, const std::pair<T, U>& r) { return {l.first + r.first, l.second + r.second}; } typedef void (*callback_function)(void); const long long ZERO = 0LL; const long long INF64 ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/10/2016 11:52:43 AM // Design Name: // Module Name: Oper_Start_In // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revisio...
#include <bits/stdc++.h> using namespace std; int main() { int n, A[100005]; cin >> n; for (int i = 0; i < n; i++) cin >> A[i]; int mx = 0; long long sum = 0; for (int i = 0; i < n; i++) { sum += A[i]; if (A[i] > mx) mx = A[i]; } sum -= mx; if (sum <= mx) { cout...
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, i, j; cin >> t; while (t--) { cin >> n; if (n % 2 == 0) { cout << n / 2 << << n / 2; } else { for (i = 3, j = 0; i * i <= n; i++) { if (n % i == 0) { cout << n / i <...
#include <bits/stdc++.h> using namespace std; vector<int> e[111]; int used[111], cnt, cnt2; void dfs(int x) { used[x] = 1; cnt += e[x].size(); cnt2++; for (int i = 0; i < e[x].size(); i++) if (used[e[x][i]] == 0) dfs(e[x][i]); } int main() { int i, j, k, n, m, stop = 0; scanf( ...
#include <bits/stdc++.h> using namespace std; int main() { long long int q; cin >> q; for (long long int l = 0; l < q; l++) { long long int n; cin >> n; long long int ans = 0; while (n != 1) { long long int track = ans; while (n % 2 == 0) { n = n / 2; ...
/** * 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; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) cin >> a[i][j]; } vecto...
#include <bits/stdc++.h> using namespace std; int n, q; const int N = 2e5 + 10; const int inf = 1e9; char s[N]; struct Node { Node() { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { dp[i][j] = (i == j) ? 0 : inf; } } } int dp[5][5]; }; Node ...
#include <bits/stdc++.h> using namespace std; int n, m; string grid[105]; int check_bomb(int i, int j) { if ((i > 0 && grid[i - 1][j] == * ) || (i < n - 1 && grid[i + 1][j] == * ) || (j > 0 && grid[i][j - 1] == * ) || (j < m - 1 && grid[i][j + 1] == * ) || (i > 0 && j > 0...
#include <bits/stdc++.h> using namespace std; void Swap(int &a, int &b) { a = a ^ b; b = a ^ b; a = a ^ b; } int Max(int a, int b) { if (a > b) return a; return b; } int Scan() { int res = 0; char ch; ch = getchar(); if (ch >= 0 && ch <= 9 ) res = ch - 0 ; while (...
/* * Copyright 2012, Homer Hsing <> * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to ...
#include <bits/stdc++.h> long long int binpow(long long int a, long long int b) { if (b == 0) return 1; long long int res = binpow(a, b / 2); if (b % 2) return res * res * a; else return res * res; } using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(...