text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> h(n); for (int i = 0; i < n; i++) cin >> h[i]; vector<pair<int, int> > v(n); for (int i = 0; i < n; i++) { v[i] = make_pair(h[i], i); } sort(v.begin(), v.end()); sort(h.begin(), h.end())...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAXN = 1e6 + 10; int fac[MAXN], infac[MAXN]; long long pow_mod(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int ar[n]; for (int i = 0; i < n; i++) cin >> ar[i]; for (int i = n - 1; i >= 0;...
#include <bits/stdc++.h> int main() { int a, b, i, d, c = 0, m = 0, j; scanf( %d %d , &a, &b); d = b; while (d != 0) { c++; d = d / 10; } for (j = 1, i = 1; j < c; j++) { i = i * 10; } while (b != 0) { m = m + (b % 10) * i; b = b / 10; i = i / 10; ...
#include <bits/stdc++.h> using namespace std; const int N = 25; const int M = 505; int n, m, a, b; int i, j, k, u, v, con; int deg[N]; bool c[N][N]; double p[N], q[N][N]; double f[M][M]; int g(int i, int j) { return i * n - n + j; } int main() { scanf( %d%d%d%d , &n, &m, &a, &b); for (i = ...
#include <bits/stdc++.h> using namespace std; int n, q; int arr[123456]; int prW[123556]; int leNM[123456]; int main() { cin >> n >> q; n--; int a, b; cin >> a; for (int i = 1; i <= (n); ++i) { cin >> b; arr[i] = abs(a - b); a = b; } vector<pair<int, int> > stac...
#include <bits/stdc++.h> using namespace std; long long n, a[200002], v1, v2, ans[200002], mx, subtr[200002]; vector<long long> g[200002]; void dfs(int v, int d, int p) { ans[1] += a[v] * d; for (int to : g[v]) { if (to == p) continue; dfs(to, d + 1, v); } } void dfs2(int v, int p) {...
#include <bits/stdc++.h> using namespace std; int n, m, q; char s2[10000006]; char s[205][205]; int vis[205][205]; int dp[205 * 205][20]; int dx[10]; int dy[10]; vector<int> Q; int id(int x, int y) { return x * m + y; } void dfs(int x, int y) { vis[x][y] = 1; int t = (s[x][y] - 0 ), p = i...
#include <bits/stdc++.h> using namespace std; int t[111]; int main() { int n, k, m; cin >> n >> k >> m; int sum = 0; for (int i = 0; i < k; i++) { cin >> t[i]; sum += t[i]; } sort(t, t + k); int ans = 0; for (int i = 0; i <= n; i++) { int time = m - sum * 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 law...
#include <bits/stdc++.h> using namespace std; int main() { int r, b; cin >> r >> b; cout << max(r, b) - 1 << << min(r, b) << n ; return 0; }
module FF_scan8( rclk, rSE, rSD, rD, Q8 ); wire [7:0] wQ ; wire [7:0] OutInv ; output reg Q8; input wire rD; input wire rSE; input wire rclk; input wire rSD; always @(posedge rclk) begin Q8 = wQ[7] ; end FF_scan FF_scan_intance0( .clk(rclk), .SE(rSE), .SD(rSD), .D(rD),...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: ps2_cache.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // =============================================...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. //------------------------------------------------------------------------------ // SHARED CODE //------------------------------------------------------------------------------ // No shared code 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...
#include <bits/stdc++.h> using namespace std; template <typename... T> void show(T&&... args) { ((cerr << args << ), ...); } template <typename F, typename S> ostream& operator<<(ostream& os, const pair<F, S>& p) { return os << ( << p.first << , << p.second << ) ; } template <typename T...
#include <bits/stdc++.h> using namespace std; string int_to_string(int a) { stringstream ss; ss << a; return ss.str(); } string double_to_string(double a) { stringstream ss; ss << a; return ss.str(); } string float_to_string(float a) { stringstream ss; ss << a; return ss....
#include <bits/stdc++.h> using namespace std; set<int> s[40]; set<int>::iterator it, q; int n, m, k, sol, v[40]; int main() { int i, j; scanf( %d %d , &n, &m); for (i = 1; i <= n; i++) { scanf( %d , &v[i]); v[i] %= m; } if (n == 1) { printf( %d , v[1]); return 0; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, M = 1e9 + 7; const unsigned long long base = 13331; const double Pi = acos(-1.0); const long long C = 299792458; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f =...
module top(...); parameter LUT_WIDTH = 4; // Multiples of 2 only input [LUT_WIDTH-1:0] a; output o1_1 = {(LUT_WIDTH/2){2'b10}} <= a; output o1_2 = {(LUT_WIDTH/2){2'b10}} < a; output o1_3 = {(LUT_WIDTH/2){2'b10}} >= a; output o1_4 = {(LUT_WIDTH/2){2'b10}} > a; output o1_5 = {(LUT_WIDTH/2){2'b10}} == a; output...
// (C) 2001-2017 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 ...
/* * 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...
//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...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: dram3_ddr3_rptr.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 a...
// Check that VAMS `abs()` functions works if its argument is a function call module main; function reg signed [7:0] fv(input reg signed [7:0] x); fv = x; endfunction function real fr(input real x); fr = x; endfunction reg signed [7:0] a; wire signed [7:0] vala = abs(fv(a)); reg ...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const long long INF = 1e12; const int MOD = 1e9 + 7; const unsigned long long BIT_FLAG_0 = (1 << 0); const unsigned long long BIT_FLAG_1 = (1 << 1); const unsigned long long BIT_FLAG_2 = (1 << 2); const unsigned long long BIT_FLAG_...
////////////////////////////////////////////////////////////////////// //// //// //// Generic Single-Port Synchronous RAM //// //// //// //// This file is part of memory li...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { long long int n, cnt = 0; cin >> n; string s[n]; long long int h1[10] = {}, h2[10] = {}; for (int...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, All Rights Reserved // // This program 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...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200000; bool active[MAXN + 10]; int v[MAXN + 10]; vector<int> factors[MAXN + 10]; int cantidad[5000001]; int main() { int n, q; scanf( %d %d , &n, &q); for (int i = 0; i < n; i++) { scanf( %d , &v[i]); int aux = v[i]; ...
#include <bits/stdc++.h> using namespace std; int main() { int r, n, d; int kol = 0; cin >> n >> d; int *a = new int[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j && abs(a[i] - a[j]) <= d) { kol++; ...
#include <bits/stdc++.h> using namespace std; int main() { int t, i, j; char c = W ; cin >> t; for (i = 0; i < t; i++) { for (j = 0; j < t; j++) { cout << c; if (c == B ) c = W ; else c = B ; } if (t % 2 == 0) { if (c == B ) ...
/* * duty_cycle_check_tb.v: Test bench for duty_cycle_check.v * author: Till Mahlburg * year: 2020 * organization: Universität Leipzig * license: ISC * */ `timescale 1 ns / 1 ps `ifndef WAIT_INTERVAL `define WAIT_INTERVAL 1000 `endif `ifndef DESIRED_DUTY_CYCLE `define DESIRED_DUTY_CYCLE 0.5 `endif `ifndef ...
#include <bits/stdc++.h> using namespace std; long long int d[200060], cost[200060]; long long int m, tank; vector<pair<int, int>> temp; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int src; cin >> src >> tank >> m; d[0] = 0; cost[0] = 0; d[m + 1] = src; cost[m + ...
module abc9_test001(input a, output o); assign o = a; endmodule module abc9_test002(input [1:0] a, output o); assign o = a[1]; endmodule module abc9_test003(input [1:0] a, output [1:0] o); assign o = a; endmodule module abc9_test004(input [1:0] a, output o); assign o = ^a; endmodule module abc9_test005(input [1:0] ...
/* * 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> using namespace std; inline char get(void) { static char buf[100000], *S = buf, *T = buf; if (S == T) { T = (S = buf) + fread(buf, 1, 100000, stdin); if (T == S) return EOF; } return *S++; } inline void read(int& x) { static char c; x = 0; for (c ...
/** * 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: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:33:57 03/02/2016 // Design Name: alu // Module Name: G:/ceshi/lab3.3/test_for_alu.v // Project Name: lab3.3 // Target Device: // Tool versions: //...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a1, a2; cin >> a1 >> a2; int res = 0; while (a1 && a2 && (a1 > 1 || a2 > 1)) { if (a1 > a2) swap(a1, a2); ++a1; a2 -= 2; ++res; } cout << res << 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 "bsg_defines.v" module bsg_fsb_to_htif_connector import bsg_fsb_pkg::RingPacketType; #(parameter htif_width_p ,parameter fsb_width_p=$size(RingPacketType) ,parameter `BSG_INV_PARAM(destid_p) ) (input clk_i ,input reset_i ,input fsb_v_i ,input [fsb_width_p-1:0] fsb_data_...
/* * 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; set<int> b[127]; set<int>::iterator it, itt; int n, m, l, r, c[200005]; char s, ch[2], a[200005]; void upd(int v, int d) { while (v <= n) { c[v] += d; v += v & -v; } } int find(int x) { int cur = 0, ans = 0; for (int i = 20; i >= ...
#include <bits/stdc++.h> using namespace std; int main() { int a[3]; for (int i = 0; i < 3; i++) cin >> a[i]; sort(a, a + 3); cout << a[2] - a[0]; return 0; }
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// (c) Copyright 1995-2017 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; void printPath(vector<pair<int, int>> &path) { for (auto it : path) cout << (it.first + 1) << << (it.second + 1) << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; long long arr[n][n]; ...
#include <bits/stdc++.h> using namespace std; int n, k, m, ax, ay, cx, cy; int d[100][100], s[100][100]; void take(int ax, int ay, int m) { for (int y = ay; y < ay + m; ++y) { for (int i = y; i <= k; ++i) ++s[ax][i]; } } int main() { while (scanf( %d%d , &n, &k) != EOF) { cx = cy = (...
#include <bits/stdc++.h> using namespace std; int i, j; int main() { int n, s, d, flag, last; cin >> n; cin >> s >> d; flag = s; n--; while (n--) { cin >> s >> d; while (flag >= s) s += d; flag = s; } cout << flag; }
/** * 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; bool bo[1005][1005]; double ans[1005][1005]; double f(int n, int m) { if (m == 0) return 1; if (bo[n][m]) return ans[n][m]; if (n == 0) { return 1.0 / (m + 1); } double a = 1.0, b = 1 - f(m, n - 1); double c = 1.0 * m / (m + 1) * (1 - f...
/*************************************************************************************************** ** fpga_nes/hw/src/vram.v * * Copyright (c) 2012, Brian Bennett * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following...
`timescale 1ns/10ps module LedBankSim; reg clock; reg reset; reg [11:0] inst; reg inst_en; wire [7:0] leds; initial begin #0 $dumpfile(`VCDFILE); #0 $dumpvars; #1000 $finish; end initial begin #0 clock = 1; forever #2 clock = ~clock; ...
`timescale 1ns/1ns module udp_inbound_chain_writer (input clk_100, input [7:0] outbox_txd, input outbox_txdv, input outbox_txe, // end of TX burst to outbox. send the message. // below here happens at 50 MHz, on the ethernet clock domain input clk_50, input [7:0] rxd, input ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f; int main() { int T; cin >> T; while (T--) { int n, k; cin >> n >> k; int mn = INF, mx = -1; for (int i = 1; i <= n; ++i) { int x; scanf( %d , &x); m...
#include <bits/stdc++.h> int main() { int n, k, i; scanf( %d%d , &n, &k); while (n > k) { for (i = 1; i <= k; i++) { if (n % 10 > 0) n--; else n = n / 10; } printf( %d , n); n = 0; } }
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long a, b; cin >> a >> b; long long c = 1, i = 0; while (1) { if (i % 2 == 0 && a >= c) a -= c; else if (i & 1 && b >= c) ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:45:22 07/05/2015 // Design Name: // Module Name: Cache_Control // Project Name: // Target Devices: // Tool versions: // Description: // // D...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int SIZE = 1e6 + 10; char A[SIZE]; long long d[SIZE]; int len; vector<long long> D; long long dp[2][4000][2][2]; void ADD(long long &x, long long v) { x = (x + v) % MOD; } long long CC(long long x) { return x * (x - 1) / 2 ...
/* verilator lint_off STMTDLY */ module dv_driver #( parameter N = 1, // "N" packets wide parameter AW = 32, // address width parameter PW = 104, // packet width (derived) parameter IDW = 12, // id width parameter NAME = "none", // north, south etc paramet...
module basic_ShieldCtrl( //Avalon System control signal. input rsi_MRST_reset, // reset_n from MCU GPIO input csi_MCLK_clk, //Avalon-MM Control. input [31:0] avs_ctrl_writedata, output [31:0] avs_ctrl_readdata, input [3:0] avs_ctrl_byteenable, input avs_ctrl_write, input avs_ctrl_read, output avs...
#include <bits/stdc++.h> const int N = 110; using namespace std; inline int read() { int x = 0, f = 1; int ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) { f = -1; } ch = getchar(); } while (ch <= 9 && ch >= 0 ) { x = (x << 1) + (x << 3) + ch -...
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; int main() { long long int i, t, a = 0, k, b = 0, j = 0, l = 0, n, m, r = 0, c = 0, ct = 0, pos = 0, neg = 0, flag = 0, x, y, space, maxi, ans = 999999, ans2 = -100, avg, sum = 0; double d;...
/* * Copyright (c) 2013, Quan Nguyen * 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 code must retain the above copyright notice, this * list of condit...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Case Western Reserve University // Engineer: Matt McConnell // // Create Date: 18:47:00 09/02/2017 // Project Name: EECS301 Digital Design // Design Name: Lab #4 Project // Module Name: ...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `ifdef OVL_ASSERT_ON wire xzcheck_enable; `ifdef OVL_XCHECK_OFF assign xzcheck_enable = 1'b0; `else `ifdef OVL_IMPLICIT_XCHECK_OFF assign xzcheck_enable = 1'b0; `else assign xzcheck...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 5; const int inf = 0x3f3f3f3f; int n; char y[maxn * 2], a[maxn * 2]; int main() { cin >> n; scanf( %s , y); scanf( %s , a); int ycnt = 0; for (int i = 0; i < n * 2; i++) { if (y[i] == 1 ) ycnt++; } in...
/** * 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, q; vector<int> w[400001]; int check[400001]; int ans; void input() { scanf( %d %d %d , &n, &m, &q); int x, y; for (int i = (0); i < (q); i++) { scanf( %d %d , &y, &x); x--; y--; x += n; w[x].push_back(y); ...
#include <bits/stdc++.h> int main() { int n, i; char ch; char str[2010]; scanf( %d , &n); scanf( %c , &ch); if (n % 2 == 1) { scanf( %c , &str[n / 2]); for (i = 1; i <= n / 2; i++) { scanf( %c , &str[n / 2 - i]); scanf( %c , &str[n / 2 + i]); } } else { ...
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * This program 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, version 3 of the License. * * This program is distributed ...
/* -- ============================================================================ -- FILE NAME : rom.v -- DESCRIPTION : Read Only Memory -- ---------------------------------------------------------------------------- -- Revision Date Coding_by Comment -- 1.0.0 2011/06/27 suito ÐÂҎ×÷³É -- ============...
#include <bits/stdc++.h> using namespace std; const long long MOD = 100000000; const long long MAXN = 2e6 + 20; struct edge { long long from, to, cost; }; int main() { long long i, j, k, t1, t2, t3, n, m, t; std::ios::sync_with_stdio(0); cin >> n >> k; cout << (k + n - 1) / n << n ; ...
#include <bits/stdc++.h> using namespace std; int read() { int f = 1, x = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -f; c = getchar(); } while (c >= 0 && c <= 9 ) x = x * 10 + c - 0 , c = getchar(); return f * x; } inline int lowbit(int x) { re...
// (C) 2001-2016 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 doc...
#include <bits/stdc++.h> using namespace std; int getChar(char c) { if (c == + ) return 1; return 0; } string s; stack<int> mystack; int main() { cin >> s; int n = s.size(); int temp; for (int i = 0; i < n; i++) { temp = getChar(s[i]); if (mystack.empty()) mystac...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; double dp[maxn], p[maxn]; int main() { int n; scanf( %d , &n); double ans = 0, d; for (int i = 1; i <= n; i++) { scanf( %lf , &p[i]); ans += p[i]; } for (int i = 2; i <= n; i++) { dp[i] = (dp[i - 1]...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; long long __gcd(long long a, long long b) { while (a != 0) { long long __t = b % a; b = a; a = __t; } return b; } bool isSimple(unsigned x) { for (unsigned i = 2; i < x; i++) if (x % i == 0) r...
#include <iostream> #include <vector> #define int long long const int DEN = 100000; const int INF = 100000000000000000; int ceild(int x) { if(x%DEN != 0) { x += DEN-x%DEN; } return x/DEN; } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int ...
module SPIFSM ( input Reset_n_i, input Clk_i, input In0_i, input In1_i, input In2_i, input In3_i, input In4_i, input In5_i, input In6_i, input In7_i, output Out0_o, output Out1_o, output Out2_o, output Out3_o, output Out4_o, output Out5_o, output Out6_o, output Out7_o, output Out8_...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; const int maxn = 1e5 + 7; int n, m; long long h[maxn], p[maxn]; bool ok(long long x) { long long cnt = 0; for (int i = 0; i < n; i++) { if (p[cnt] >= h[i]) { for (int j = cnt; j < m; j...
#include <bits/stdc++.h> using namespace std; int a[202020], f[202020]; int s[202020]; bool br[202020]; int n, doe, ans; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]), ++f[a[i]]; doe = 1; while (f[doe] != 0) ++doe; for (int i = 1; i <= n; ++i) { if (...
#include <bits/stdc++.h> using namespace std; int A[1000005], B[1000005]; int ans = 0; int C[35]; int main() { int n, m, i, j, k, l; scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) { scanf( %d , &A[i]); long long t = 1; for (j = 0; j < 33; j++) { C[j] += ((A[i] & t) != 0)...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) const long long mod = 1e9 + 7; inline long long add(long long a, long long b) { return (a % mod + b % mod) % mod; } inline long long sub(long long a, long ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int main() { cin.tie(0), cout.tie(0); ios::sync_with_stdio(false); int t; cin >> t; while (t--) { int u = 0, l = 0, d = 0; string s; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] >=...
#include <bits/stdc++.h> using namespace std; template <class T> int chkmax(T& a, T b) { if (b > a) { a = b; return 1; } return 0; } template <class T> int chkmin(T& a, T b) { if (b < a) { a = b; return 1; } return 0; } template <class iterator> void out...
#include <bits/stdc++.h> using namespace std; int cc[100002]; pair<int, int> in[100002]; vector<pair<int, int> > adj[100002]; int pos = 1; int l[100002], r[100002], label[100002]; long long d[100002]; void dfs(int node, int par, long long depth = 0) { l[node] = pos; d[node] = depth; int ch, ...
#include <bits/stdc++.h> using namespace std; int n, a[12345]; int calc(int x, int y) { int ret = 0; vector<int> v; for (int i = 0; i < 2 * n; ++i) { if (i != x && i != y) v.push_back(a[i]); } for (int i = 0; i < v.size(); i += 2) ret += abs(v[i] - v[i + 1]); return ret; } int ma...
#include <bits/stdc++.h> using namespace std; const int NV = 105; const int LNV = 11; const int NE = 5015; const int NQ = 1000005; const int intmax = 0x7fffffff; int f[2005]; int a[2005]; int n, m; struct Edge { int ne, y, v; }; struct Edge2 { int x, y, v; }; bool cmp(Edge2 a, Edge2 ...
// 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 : Tue Feb 14 01:38:42 2017 // Host : TheMosass-PC running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; template <class T, class U> void Max(T &a, U b) { if (a < b) a = b; } template <class T, class U> void Min(T &a, U b) { if (a > b) a = b; } template <class T, class U> void add(T &a, U b) { a += b; if (a >= 1000000007) a -= 1000000007; } ...
#include <bits/stdc++.h> using namespace std; char arr[500001]; char inv(char temp) { if (temp == 0 ) return 1 ; return 0 ; } string invert(string temp) { int n = temp.length(); if (n % 2 == 1) { for (int i = 1; i < n; i += 2) temp[i] = inv(temp[i]); } else { for (int i = 1;...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; long long int a[n], b[n]; long long int sum = 0, suma = 0; for (int i = 0; i < n; i++) { cin >> a...