text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int res; cin >> res; if (res % 2 == 0) { cout << Mahmoud ; } else { cout << Ehab ; } 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 law...
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> t, a, b; vector<pair<int, int>> p; void push(int v) { if (t[v] != -1) { t[v * 2] = t[v * 2 + 1] = t[v]; t[v] = -1; } } void update(int v, int l, int r, int vl, int vr, int color) { if (vl > vr) return; if (l ==...
#include <bits/stdc++.h> using namespace std; const int N = 10000010; int p[N], num, last[N]; bool flag[N]; int cnt[N], n, m; void make_prime() { for (int i = 2; i < N; ++i) if (!flag[i]) { p[num++] = i; last[i] = i; for (int j = i + i; j < N; j += i) flag[j] = true, last[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 law...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2009 Xilinx, Inc. // This design is confidential and proprietary of Xilinx, All Rights Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ /...
/* * 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; template <typename T> ostream& operator<<(ostream& s, vector<T>& v) { s << { ; for (int i = 0; i < int(v.size()); i++) s << (i ? , : ) << v[i]; return s << } ; } template <typename S, typename T> ostream& operator<<(ostream& s, pair<S, T> const...
/* * 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 = 1010; int C[N][N], dp[N][N]; int main() { int m, x[110], y[110], sum[110]; sum[0] = 0; scanf( %d , &m); for (int i = 1; i <= m; i++) { scanf( %d , x + i); sum[i] = sum[i - 1] + x[i]; } for (int i = 1; i <= m; i++) { ...
`include "hi_read_tx.v" /* pck0 - input main 24Mhz clock (PLL / 4) [7:0] adc_d - input data from A/D converter shallow_modulation - modulation type pwr_lo - output to coil drivers (ssp_clk / 8) adc_clk - output A/D clock signal ssp_frame - output SSS frame indicator (goes high while the 8 bits ...
#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> #pragma GCC optimize( O3 ) using namespace std; const int N = 1e2 + 5, M = 1e5 + 5; int lim = (1 << 10) - 1; bool vis[M]; vector<int> primes; int idx[M]; void pre() { for (int i = 2; primes.size() < 110; ++i) { if (vis[i]) continue; primes.emplace_back(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...
/* * Copyright 2015, Stephen A. Rodgers. 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 Foundation; either version 2 of the License, or * (at your option) any later version...
#include <bits/stdc++.h> using namespace std; const long long INF = 999999999; const long long INFL = 99999999999999999LL; const double EPSILON = 0.00000001; const long long MOD = 1000000007; long long a[100005]; int32_t main() { long long n, t; scanf( %I64d , &n); ; scanf( %I64d , &t); ...
#include <bits/stdc++.h> using namespace std; int Res[2][7010], N[2][7010], Loss[2][7010]; int n, m, k, OpN[2]; queue<pair<int, int> > Q; int main() { srand((unsigned)time(0)); ios::sync_with_stdio(false); cin.tie(0); cin >> n; cin.get(); for (int i = 0; i < 2; i++) { cin >> m; ...
#include <bits/stdc++.h> using namespace std; const int MX = 1e6 + 42; int k; int f[6]; long long dp[MX]; long long eval(int val) { long long ret = 0; for (int dig = 0; dig < 6; dig++) { int d = val % 10; if (d % 3 == 0) ret = ret + 1LL * d / 3 * f[dig]; val = val / 10; } r...
#include <bits/stdc++.h> using namespace std; long long C[2333][2333]; int d, MOD, p = 0; long long co[23333]; vector<int> operator-(vector<int> a, vector<int> b) { vector<int> s; int u = max(a.size(), b.size()); a.resize(u); b.resize(u); for (int i = 0; i < u; ++i) s.push_back((a[i] - b[i...
#include <bits/stdc++.h> using namespace std; int main() { map<pair<long long, long long>, long long> m; vector<long long> p1, p2; long long n, s, i, j, k, a, u, v, w, l, k1, k2; cin >> n; while (n--) { cin >> a; if (a == 1) { cin >> u >> v >> w; j = u; k1 = 0...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: whoosh_new.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { long long x, d, k = 1; cin >> x >> d; vector<long long> ans; while (x) { long long rem = 0; for (int i = 31; i >= 0; --i) { if (x >> i & 1) { long long tmp = i; if (i == 0) ...
#include <bits/stdc++.h> using namespace std; int printx(int x, int a, int b, int c) { if (x == 0) return a; else if (x == 1) return b; else return c; } int main() { long long n; int x; cin >> n >> x; n %= 6; switch (n) { case 0: x = printx(x, 0, 1...
/* * 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 ts = 1, cs = 1; cin >> ts; while (ts--) { int n, m; cin >> n >> m; pair<int, int> vec[m + 2]; for (int i = 1; i <= m; i++) { cin >> vec[i].first; vec[i].second = i; } sort(vec + 1, vec + m ...
///////////////////////////////////////////////////////////////////// //// //// //// AES Key Expand Block (for 128 bit keys) //// //// //// //// ...
module first_nns_comb_td # ( parameter W = 15, parameter N = 32 ) ( g_input, e_input, o ); function integer log2; input [31:0] value; reg [31:0] temp; begin temp = value; for (log2=0; temp>0; log2=log2+1) temp = temp>>1; end endfunction localparam LOGW = log2(W); input [2*W-1:0] g_input; inpu...
/* * 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; template <class T> T gi() { T x = 0; bool f = 0; 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...
/* HW4, Problem 16 */ module ct4(output reg [3:0] count, output reg carry_out, input enable_l, clk_l, reset, load, input [3:0] data); always @(negedge clk_l) if (reset) count <= 0; else if (load) count <= data; else if (!enable_l) count <= count + 1; always @(count) if (count == 'b1111) carry_out <= 1; e...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e6 + 7; const int mod = 1e9 + 7; int a[N]; int l[N]; int c[N]; int f[N]; int binpow(int a, int b) { int ret = 1; while (b) { if (b & 1) { ret = (ret * 1LL * a) % mod; --b; } a =...
#include <bits/stdc++.h> #pragma GCC optimize -O3 using namespace std; const int MAXN = 2100; int n, m; long long a[MAXN]; long long aa[MAXN]; long long b[MAXN]; long long bb[MAXN]; long long x; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m; for ...
#include <bits/stdc++.h> long long n, m, a, d, t[100007], old, ans, aind, firstA, stepD; int main() { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cin >> n >> m >> a >> d; for (int i = 0; i < m; ++i) std::cin >> t[i]; aind = d / a * a + a; for (int i = 0; i < m; ...
`timescale 1ns / 1ps /* -- Module Name: DES Core -- Description: Nucleo de encriptacion DES. El bloque trabaja con un bloque de datos a encriptar de 64 bits denominado 'plaintext' y una llave de encriptacion de 64 bits llamada 'key'. El proceso de encriptacion tiene una duracion de 16 ciclos de ...
#include <bits/stdc++.h> using namespace std; const int N = 255; int parent[N]; int ra[N]; void make_set(int v) { parent[v] = v; ra[v] = 0; } int find_set(int v) { if (v == parent[v]) return v; return parent[v] = find_set(parent[v]); } void union_sets(int a, int b) { a = find_set(a...
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define For(i,x,y) for(ll i = (x);i <= (y);++i) #define FOr(i,x,y) for(ll i = (x);i >= (y);--i) #define fi first #define se second #define pa pair<ll,ll> #define mk make_pair #define pb push_back #define clr(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...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // // 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 // //...
#include <bits/stdc++.h> using namespace std; int read() { int xx = 0, ff = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) ff = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { xx = xx * 10 + ch - 0 ; ch = getchar(); } return xx * ff;...
module basic_FuncLED( //Avalon System control signal. input rsi_MRST_reset, // reset_n from MCU GPIO input csi_MCLK_clk, //Avalon-MM LED 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, o...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2012, Ameer M. Abdelhadi; . All rights reserved. // // // // Redistribution and use in source and binary forms, with or with...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:20000000 ) string problem_name = a ; void init() { freopen((problem_name + .in ).c_str(), rt , stdin); } long long res = 0; int ms[300100]; int len; void mul(int val) { int p = 0; for (int i = 0; i < 300000; i++) { ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { int num; cin >> num; v.push_back(num); } vector<pair<int, int> > vp; int x, y; for (int i =...
//Legal Notice: (C)2011 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; const int N = 20; const int V = (1 << 20) + 10; const int P = 1000000007; int Pow(int x, int y) { int ret = 1; while (y) { if (y & 1) ret = (long long)ret * x % P; x = (long long)x * x % P; y /= 2; } return ret; } void utf(int...
`timescale 1 ns / 1 ns ////////////////////////////////////////////////////////////////////////////////// // Company: Rehkopf // Engineer: Rehkopf // // Create Date: 01:13:46 05/09/2009 // Design Name: // Module Name: address // Project Name: // Target Devices: // Tool versions: // Description: Address logic w/ S...
// $Id: vcr_comb_alloc_mac.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: Redistribution...
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b); long long int gcd(long long int a, long long int b); int prime(int n); long long int lcm(long long int a, long long int b) { return (a * b) / gcd(a, b); } int main() { ios_base::sync_wit...
#include <bits/stdc++.h> int main() { int num; int count = 0, i; int digitos[10]; scanf( %d , &num); int aux = num; for (i = 0; i < 10; i++) digitos[i] = 0; while (aux != 0) { digitos[aux % 10] = 1; aux = aux / 10; } if (num == 1) { printf( 1 n ); return 0; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 6; int n, m; int a[200]; bool check() { if (*max_element(a, a + n) != 0) { return false; } return true; } void solve() { int k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } if (k...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> A(n + 10, 0); for (int i = 0; i < n; i++) cin >> A[i]; unordered_map<long long, int> fir, sec; fir[A[0]] = 1; for (int i = 1; i < n; i++) sec[A[i]]++; long long S = 0; for (int i = 0; i < n; 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...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2010 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : 11....
/** * created: 25/03/2021, 15:47:17 * pause: 16:11 - 16:18 **/ #include <bits/stdc++.h> using namespace std; const int max_n = 200222, inf = 1000111222; const int max_x = 2 * max_n; vector<long long> all; struct node { int cnt; long long sum, sum_l, sum_r; frien...
// -*- Mode: Verilog -*- // Filename : test_00.v // Description : Simple ADXL362 Test Case to bring environment to life // Author : Philip Tracton // Created On : Thu Jun 23 11:36:12 2016 // Last Modified By: Philip Tracton // Last Modified On: Thu Jun 23 11:36:12 2...
#include <bits/stdc++.h> using namespace std; const int N = 1e6; int n; int m; int t[4 * N]; void upd(int l, int r, int v = 1, int tl = 1, int tr = N) { if (l > r) return; if (l <= tl && tr <= r) { t[v]++; return; } int tm = (tl + tr) / 2; upd(l, min(tm, r), v * 2, tl, tm); ...
/* * 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; int n, m1, q; int m[102][102]; struct query { int t; int a; int b; int c; }; void rote(int type, int val) { if (type == 1) { int aux = m[val][m1]; for (int i = m1 - 1; i >= 1; i--) m[val][i + 1] = m[val][i]; m[val][1] = aux;...
/** * 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...
`ifdef __ICARUS__ `define SUPPORT_CONST_OUT_OF_RANGE_IN_IVTEST `endif module top; reg pass; reg [2:-1] vec; integer idx; initial begin pass = 1'b1; idx = 'bx; vec = 4'bxxxx; `ifdef SUPPORT_CONST_OUT_OF_RANGE_IN_IVTEST vec[1'bx] <= 1'b1; `endif #1 if (vec !== 4'bxxx) begin $displa...
module ram0( // Write port input wrclk, input [7:0] di, input wren, input [5:0] wraddr, // Read port input rdclk, input rden, input [5:0] rdaddr, output reg [7:0] do); (* syn_ramstyle = "block_ram" *) reg [7:0] ram[0:63]; initial begin ram[0] = 8'b00000001; ...
#include <bits/stdc++.h> using namespace std; struct node { int num; int num_num; } num[105]; int main() { int N, M; scanf( %d%d , &N, &M); num[0].num = 0; num[0].num_num = 0; for (int i = 1; i <= N; i++) { int flag; scanf( %d , &flag); num[i].num = num[i - 1].num +...
#include <bits/stdc++.h> using namespace std; int true_mod(int A, int N) { A %= N; if (A < 0) A += N; return A; } const long long MOD = 1000LL * 1000LL * 1000LL + 7LL; const int MX = 109; struct matrix { long long A[MX][MX]; }; int x; void output(const matrix& A) { for (int i = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<string> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; for (int j = 0; j < m; ++j) { vector<int> indx; for (int i = 0; i < n; ++i) { if (a[i][j] == # ) indx.push_back(i); } ...
#include <bits/stdc++.h> using namespace std; using namespace chrono; const int infinity = (int)1e9 + 42; const int64_t llInfinity = (int64_t)1e18 + 256; const int module = (int)1e9 + 7; const long double eps = 1e-8; mt19937_64 randGen(system_clock().now().time_since_epoch().count()); inline void raiseE...
// // Copyright 2011 Ettus Research LLC // // 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, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2005 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 `ifdef VERILATOR `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); string s; cin >> s; s = 0 + s; vector<int> v(int(s.size()), 0); for (int i = int(s.size()) - 1; i >= 0; i--) { if (s[i] == 1 ) { v[i] = -1; while (s[i] != 0 ) i--; v[i] =...
#include <bits/stdc++.h> const int maxn = 60; int mtx[maxn][maxn]; int n, m; bool col_ok(int a, int b) { for (int i = 0; i < n; i++) { if (mtx[i][a] != mtx[i][b]) return 0; } return 1; } int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) for (int j = 0; j < m; j+...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; string w; for (int i = 0; i <= 2 * n - 2; i = i + 2) { w = w + s[i]; } cout << w << endl; } }
/** * 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 (c) 2014, University of British Columbia (UBC); All rights reserved. // // // // Redistribution and use in source and binary forms, w...
/** * 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 (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...
/*module MUX8_1(Sel,S0,S1,S2,S3,S4,S5,S6,S7,out); input [2:0] Sel; input [7:0] S0,S1,S2,S3,S4,S5,S6,S7; output [7:0]out; assign out = (Sel[2])? (Sel[1]?(Sel[0]?S7:S6) : (Sel[0]?S5:S4)) : (Sel[1]?(Sel[0]?S3:S2) : (Sel[0]?S1:S0)); endmodule module MUX4_1(Sel,S0,S1,S2,S3,out); input [1:0] Sel; input [7:0] S0,S1,S2,...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TESTS = 1; while (TESTS--) { long long n, q; cin >> n >> q; while (q--) { long long x; cin >> x; long long c = 1; for (long ...
#include <bits/stdc++.h> using namespace std; int main() { int kocka[25] = {}; for (int i = 1; i <= 24; i++) cin >> kocka[i]; if (kocka[1] == kocka[2] && kocka[2] == kocka[3] && kocka[3] == kocka[4] && kocka[17] == kocka[18] && kocka[18] == kocka[7] && kocka[7] == kocka[8] && kocka[21] =...
#include <bits/stdc++.h> using namespace std; long long tests, t, qq, q, i, j, bb[200000], s1, ans[2100][2100]; long long a, b; long solve(long long a, long long b) { if (a < b) swap(a, b); if (a == 0 || b == 0) return 0; if (solve(a % b, b) == 0) return 1; t = a / b; if (b % 2 == 1) return ...
/* * 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; template <typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2>& p) { in >> p.first >> p.second; return in; } template <typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { out << { << p.first << , << p...
#include <bits/stdc++.h> using namespace std; int l1, r1, l2, r2, ans; int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int check(int a) { if (a > ans) ans = a; return a; } int solve(int l1, int r1, int l2, int r2, int k) { if (l1 == l2 && r1 == r...
#include <bits/stdc++.h> using namespace std; char s[5010]; int main() { scanf( %s , s); int n = (int)strlen(s); int res = 0; for (int i = 0; i < n; i++) { int mn = 0, mx = 0; for (int j = i; j < n; j++) { if (s[j] == ( ) { mn++, mx++; } else if (s[j] == ) )...
/* * 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 ...
/** * 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...
/* 2013-08-11 10:03:33.914034 */#include<iostream> #include<cstdio> #include<cstdlib> #include<ctime> #include<cmath> #include<cctype> #include<cstring> #include<algorithm> #include<map> #include<set> #include<vector> #include<string> #include<queue> using namespace std; char s[1011...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 5]; for (int i = 1; i <= n; i++) cin >> a[i]; int m = 1; for (int i = 2; i < n; i++) { if (abs(a[i] - a[i + 1]) < abs(a[m] - a[m + 1])) m = i; } if (abs(a[n] - a[1]) < abs(a[m] - a[m + 1])) { ...
// (C) 2001-2013 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; struct P { int x, y; bool operator<(const P &p) { if (x != p.x) return x < p.x; else return y < p.y; } }; int main() { int T; cin >> T; for (int t = 0; t < T; ++t) { int n; cin >> n; int bsz = n /...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int t; cin >> t; while (t--) { int n; cin >> n; for (long long int i = (long long int)0; i < (long long int)n; i++) cout << i + 1 << ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 500010; bool f[MAXN]; int main() { int n, d; scanf( %d %d , &n, &d); f[0] = 1; for (int i = 0; i < n; i++) { int x; scanf( %d , &x); for (int j = MAXN - 1 - x; j >= 0; --j) f[j + x] |= f[j]; } int r = 1, sum...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13.12.2015 18:04:09 // Design Name: // Module Name: product_sat // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // R...
#include <bits/stdc++.h> using namespace std; template <class T> inline void smn(T &a, const T &b) { if (b < a) a = b; } template <class T> inline void smx(T &a, const T &b) { if (b > a) a = b; } template <class T> inline T rev(const T &a) { T _ = a; reverse(_.begin(), _.end()); re...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, j, i, l, r, ans = 0, x, y, minimum; scanf( %d , &n); scanf( %d , &k); int count_a[n], count_b[n]; char str[n + 1], ch; scanf( %s , str); for (i = 0; i < n; i++) { count_a[i] = 0; count_b[i] = 0; } fo...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; int i, k, cnt = 0; for (i = 0; i < s.length(); i++) if (s[i] != 0 ) break; k = i; for (i; i < s.length(); i++) if (s[i] == 0 ) cnt++; ...
#include<bits/stdc++.h> using namespace std; #define l1 long long void solve() { int n; cin>>n; vector<int> v(n); for(auto &i:v) cin>>i; l1 sum = 0; l1 need = 0; for(int i=0;i<n;i++) { sum+=v[i]; need+=i; if(sum<need) {cout<< NO <<endl; return;} ...
/*+-------------------------------------------------------------------------- Copyright (c) 2015, Microsoft Corporation 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 ...
#include <bits/stdc++.h> using namespace std; int flag[3000500]; int dp[200050]; int maxx[200050]; int ans[200050]; stack<int> st; int main() { string s; cin >> s; int n = s.size(); for (int i = 0; i < n; i++) { ans[i] = 0; if (s[i] == 1 ) st.push(i); if (s[i - 1] == 1 ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13.07.2017 13:29:14 // Design Name: // Module Name: t_mem // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revisio...
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e6; const int inf = (int)2e9; const double eps = 1e-9; const int mod = (int)1e9 + 7; int n, l, x, y, a[maxn], ok1, ok2; map<int, int> was; bool check(int v) { if (v >= 0 && v <= l && (was.count(v - x) || was.count(v + x) || ok1) &&...
module spi_slave( input clk, input rst, input ss, input mosi, output miso, input sck, output done, input [7:0] din, input din_update, output [7:0] dout ); reg mosi_d, mosi_q; reg ss_d, ss_q; reg sck_d, sck_q; reg sck_old_d, sck_old_q; reg [7:0] data_d, data_q; reg done_d, do...