text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int x[102], pile[102]; int MN(int a, int b) { return (a < b) ? a : b; } int main() { int n, i, sz, j, flag; while (scanf( %d , &n) != EOF) { for (i = 1; i <= n; i++) { scanf( %d , &x[i]); } sort(x + 1, x + n + 1); sz = 1; ...
#include <bits/stdc++.h> using namespace std; int a[500100]; int n; vector<int> g[200100]; int d[200100]; int cnt = 1; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { int ind = lower_bound(d...
#include <bits/stdc++.h> using namespace std; char a[25][25]; int dp[40][1 << 20], n; bool vis[40][1 << 20]; int f(int xx, int st) { if (vis[xx][st]) return dp[xx][st]; int &res = dp[xx][st]; vis[xx][st] = true; if (xx == n * 2 - 2) { res = 0; } else { if (xx & 1) res =...
#include <bits/stdc++.h> using namespace std; int D, m, x, y; vector<vector<long double>> e; const long double oo = 1e13; vector<long double> mns(vector<long double> a, vector<long double> b) { vector<long double> ret; ret.resize(D); for (int i = 0; i < D; i++) ret[i] = a[i] - b[i]; return ret...
/* * 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; inline int readint() { int a; cin >> a; return a; } int toInt(string &s) { const static int Mod = 998244353; const static long long bas = 29; int res = 0; for (int i = 0, n = s.length(); i < n; ++i) res = (res * bas + s[i] - a + 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 la...
#include <bits/stdc++.h> using namespace std; long long counter; long long n, r, l, x; vector<long long> a; long long sum, rr; bool cheake(long long mask) { long long nmax = -1; long long nmin = 10000000000; long long i = 0; rr = 0; sum = 0; while ((mask >> i) != 0) { if ((mask...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-11; int countbit(int n) { return (n == 0) ? 0 : 1 + countbit(n & (n - 1)); } int lowbit(int n) { return n & (n ^ (n - 1)); } string toString(long long v) { ostringstream sout; sout << v; return sout...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: Conversion_ROM.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =====================...
#include <bits/stdc++.h> using namespace std; const int INF = 1e8; const int MX = 2e5 + 5; vector<int> vorder; int dup[MX], lc[MX], rc[MX], good[MX], seek[MX]; string labels, corder; void ino(int curr) { if (curr == -1) return; ino(lc[curr]); vorder.push_back(curr); corder += labels[curr];...
#include <bits/stdc++.h> using namespace std; stack<char> s; char c; int now = 1; int main() { while (cin >> c) { if (s.empty()) { s.push(c); } else { if (s.top() == c) { s.pop(); now = 3 - now; } else { s.push(c); } } } ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int n, a[200001], mp[200001], x, y; vector<int> to[200001], t2[200001]; int fa[200001], d[200001], sz[200001], son[200001]; int top[200001], dfn[200001], cnt; int f[200001], v[200001], p[200001], g[200001]; int st[200001], tp, s, sum...
/*************************************************************************************************** ** 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/1ps module memcpy_engine #( parameter ADDR_WIDTH = 64, parameter DATA_WIDTH = 512 ) ( input clk , input ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5; const long long M = 1e9 + 9; int n, x, y; pair<int, int> pos[N]; map<pair<int, int>, int> mp; set<int> q; long long ans; int children(int x, int y) { int ret = 0; for (int dx = -1; dx <= 1; dx++) { map<pair<int, int>, int>:...
#include <bits/stdc++.h> using namespace std; int main() { long n; cin >> n; long long int ans = 0, ans1, k, a1, a2, x, y, m, s = 0; vector<pair<long, pair<long, long>>> r; for (int i = 0; i < n; ++i) { cin >> k; s += k; cin >> a1 >> x >> y >> m; ans1 = 0; r.push_ba...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const long long N = 2e5 + 10, alp = 26; const long double pi = 3.14159265358979; void solve() { long long n, m; cin >> n >> m; vector<vector<long long> > g1(n), rg1(n), g2(n), rg2(n); for (long long i = 0; i < m; ++i) ...
module t_lint_pragma_protected_err; // This part should see some failures `pragma protect begin_protected `pragma protect version="xx" // should fail because value should be quoted `pragma protect encrypt_agent=123 // should fail because no value given at all `pragma protect encrypt_agent_info `pragma protect data_me...
#include <bits/stdc++.h> using namespace std; const int N = 500005; const int mod = 998244353; const long long int inf = 10e17; const long double pi = 3.14159265359; mt19937_64 rang( chrono::high_resolution_clock::now().time_since_epoch().count()); int rng(int lim) { uniform_int_distribution<int...
// Synchronous FIFO. 1024 x 32 bit words. // module fifo ( clk, rstp, din, writep, readp, dout, emptyp, fullp); input clk; input rstp; input [31:0] din; input readp; input writep; output [31:0] dout; output emptyp; outp...
//------------------------------------------------------------------------------------------------- // ng_MON.v - Monitor module // // In the original Pultorak desing, this Module was used to contain all the front panel switches // and Display indicator LED's. In this FPGA experiment, most of that is not needed since ...
#include <bits/stdc++.h> using namespace std; int main() { string s[10] = { O-|-OOOO , O-|O-OOO , O-|OO-OO , O-|OOO-O , O-|OOOO- , -O|-OOOO , -O|O-OOO , -O|OO-OO , -O|OOO-O , -O|OOOO- }; string num; while (cin >> num) { int i = num.size(); while (i--) cout << s[n...
#include <bits/stdc++.h> using namespace std; string str; int main() { long long int i, j, t, n; cin >> t; while (t--) { cin >> str; int ar[4]; for (i = 0; i < 4; i++) { ar[i] = 0; } int l = str.length(); int count = 0; int mn = l + 1; for (i = 0...
// (C) 1992-2014 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 simulati...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: Adam LLC // Engineer: Adam Michael // // Create Date: 18:38:26 09/18/2015 // Design Name: KeyEncoderAJM // Module Name: C:/Users/adam/Documents/GitHub/Digital Systems/Lab2-ManualKeypadScannerAndEnco...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:40:11 11/29/2014 // Design Name: // Module Name: FuncionActivacion // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenci...
/** * 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> #define inf 2000000000 #define eb emplace_back #define pb push_back #define fi first #define se second #define fastio ios::sync_with_stdio(false);cin.tie(NULL) #define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) using namespace std; typedef long l...
#include <bits/stdc++.h> using namespace std; int n, bear, ans, a, aux, votes[128]; priority_queue<int> q; int Solution() { int ans = 0; while (bear <= q.top()) { aux = q.top(); if (bear <= aux) { bear++; aux--; q.pop(); q.push(aux); ans++; } ...
#include <bits/stdc++.h> using namespace std; int n, x[101000], y[101000], fa[101000], sz[101000], tot[101000], u, v; map<int, vector<int> > xx, yy; map<int, vector<int> >::iterator it; long long ans = 1, er[202000]; int GF(int x) { return fa[x] == x ? x : fa[x] = GF(fa[x]); } void doit(vector<int> &the) ...
/////////////////////////////////////////////////////////////////////////////// // // Copyright 2010-2012 by Michael A. Morris, dba M. A. Morris & Associates // // All rights reserved. The source code contained herein is publicly released // under the terms and conditions of the GNU Lesser Public License. No part of...
module top ( output wire MOSI, output wire CSB, output wire DRCK1, input MISO ); wire CAPTURE; wire UPDATE; wire TDI; wire TDO1; reg [47:0] header; reg [15:0] len; reg have_header = 0; assign MOSI = TDI ; wire SEL1; wire SHIFT; wire...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 06/11/2015 05:46:30 PM // Design Name: // Module Name: timer // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revi...
#include <bits/stdc++.h> using namespace std; void func() { long long n; cin >> n; std::vector<pair<long long, long long> > v(n); for (long long i = 0; i < n; ++i) { cin >> v[i].first; } for (long long i = 0; i < n; ++i) { cin >> v[i].second; } sort(v.begin(), v.end()); ...
/* * Copyright (C) 2007 Onno Kortmann <> * Klaus Rudolph <> * * 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) a...
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, k; cin >> n >> k; string s; cin >> s; if (k == 0) { cout << s; return; } if (n == 1) cout << 0 ; else { if (s[0] > 1 ) { s[0] = 1 ; k--; } for (long lo...
// ============================================================== // 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...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const long double PI = acos((long double)-1); long long cnt[32][2]; class Node { public: Node* child[2]; long long cnt; Node() { child[0] = child[1] = NULL; cnt = 0; } }; class Trie { private: Node...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int n; int res = 0; int r[10]; int v[10]; int main() { int t; cin >> t; while (t--) { long long x = 1; int n; cin >> n; for (int i = 3; i <= n * 2; i++) { x = x * i % mod; } cout ...
// Answers are divided by 2. module multiply_complex #( parameter WIDTH = 32 ) ( input wire clk, input wire rst_n, input wire signed [WIDTH-1:0] x, input wire signed [WIDTH-1:0] y, output wire signed [WIDTH-1:0] z ); wire signed [WIDTH/...
module foo; // syntaxify the unique keyword correctly please... always_comb (*) begin case (f) 1 : 2; endcase // case (f) unique case(vlcnum) 0 : unique case(in.value1) 0 : out = 1; 1 : out = 3; 2 : out = 3; 3 : out = 4; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int x, y, z; cin >> x >> y >> z; if (x != y && y != z && z != x) cout << NO << n ; else { int a = min(min(x, y), z); int c = max(max(...
#include <bits/stdc++.h> const int N = 1005; int size[N], to[N << 1], edge, Next[N << 1], last[N], G, siz, cnt, w[N << 1], n, x, y, tag[N]; void add(int x, int y) { to[++edge] = y; Next[edge] = last[x]; last[x] = edge; } void dfs(int x, int fa) { size[x] = 1; int mx = 0; for (int...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n = 0; cin >> n; int a[n], res[n]; for (int i = 0; i < n; i++) { cin >> a[i]; res[i] = 0; } for (int i = 0; i < n - 1; i++) { if (i) res[i] = res[i -...
#include <bits/stdc++.h> using namespace std; struct node { long long l; long long r; long long s; node* ln; node* rn; void change(long long n, long long k) { if (l == r) s += k; else { if (n <= (l + r) / 2) { if (ln == 0) { ln = new node; ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 100010; int n, m, k, u, v, x, y, t, a, b, ans; string A[5]; string s; int ma...
#include <bits/stdc++.h> using namespace std; const int MX = (int)1e5 + 5; int test; vector<int> con[MX]; int dp[MX], sz[MX], prv[MX]; void dfs(int u) { sz[u] = 1; for (int v : con[u]) { dp[v] = dp[u] + 1; dfs(v); sz[u] += sz[v]; } } int fst[MX], st[MX], en[MX], pn; void ...
#include <bits/stdc++.h> using namespace std; template <class T> using vc = vector<T>; template <class T> using vvc = vc<vc<T>>; template <class T> void mkuni(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); } long long rand_int(long long l, long long r) ...
module sim_camera ( input i_cam_in_clk, input i_cam_rst, input i_flash, output o_pix_clk, output reg o_flash_strobe = 0, output reg o_vsync = 0, output reg o_hsync = 0, output reg [7:0] o_pix_data = 0 ); //Local Parameters localpar...
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; void add(int &a, int b) { a += b; if (a >= M) a -= M; } int mypow(int x, int t) { int ans = 1, res = x; while (t) { if (t & 1) ans = (long long)ans * res % M; res = (long long)res * res % M, t >>= 1; } ret...
#include <bits/stdc++.h> using namespace std; inline int inp() { return 0; } inline int inp(bool& A) { if (cin >> A) return 1; return -1; } inline int inp(char& A) { return scanf( %c , &A); } inline int inp(int& A) { return scanf( %d , &A); } inline int inp(float& A) { if (cin >> A) return 1;...
#include <bits/stdc++.h> using namespace std; const char nl = n ; const int MAX_N = 100011; const long long INF = (1 << 29) + 123; const long long MOD = 998244353; const long double PI = 4 * atan((long double)1); template <typename T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }...
`include "assert.vh" `include "cpu.vh" module cpu_tb(); reg clk = 0; // // ROM // localparam MEM_ADDR = 5; localparam MEM_EXTRA = 4; reg [ MEM_ADDR :0] mem_addr; reg [ MEM_EXTRA-1:0] mem_extra; reg [ MEM_ADDR :0] rom_lower_bound = 0; reg [ MEM_ADDR :0] rom_upper_bo...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty. // module some_module ( input wrclk ); logic [ 1 : 0 ] some_state; logic [1:0] some_other_state; always @(posedge wrclk) begin case (some_state) ...
// megafunction wizard: %LPM_MULT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: lpm_mult // ============================================================ // File Name: MULT.v // Megafunction Name(s): // lpm_mult // // Simulation Library Files(s): // lpm // ================================================...
#include <bits/stdc++.h> using namespace std; template <typename T> T id(T b) { return b; }; template <class It> bool all(It f, It l) { return std::all_of(f, l, id<bool>); } template <class It> bool any(It f, It l) { return std::any_of(f, l, id<bool>); } const int MAX_N = 2000, MAX_A =...
#include <bits/stdc++.h> using namespace std; long long sum(long long a[], long long n, long long s) { for (long long i = 0; i < n; i++) s += a[i]; return s; } long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { ...
/* A simplistic test for OBUFTDS. Two of them are instanciated and their outpus are connected to LEDs. Data and tri-state inputs are controlled by switches. Truth tables: SW9 SW8 | LED3 LED2 0 0 | 1 0 0 1 | 0 1 1 0 | 0 0 1 1 | 0 0 SW11 SW10 | LED8 LED7 0 0 | 0 1 0...
#include <bits/stdc++.h> using namespace std; int l_f, l_h; long long int dp[101][101][11][11]; int getans(int f, int h, int k1, int k2) { int x = 0, y = 0; if ((f + h) == 0) return 1; if (dp[f][h][k1][k2] != -1) return dp[f][h][k1][k2]; if (f > 0 && k1 > 0) x = getans(f - 1, h, k1 - 1, l_h); ...
#include <bits/stdc++.h> using namespace std; char s1[1000], s2[1000], v[1000], s[1000]; int d[200][200][200]; int p[200][200][200][3]; int pp[1000]; int main() { int i, j, k, l1, l2, l, tmp, ans, bk, ti, tj, tk, m; scanf( %s%s%s , s1, s2, v); l1 = strlen(s1); l2 = strlen(s2); l = strlen...
// nios_nios2_gen2_0.v // This file was auto-generated from altera_nios2_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module nios_nios2_gen2_0 ( input wire clk, // clk....
#include <bits/stdc++.h> using namespace std; int main() { int n, h; cin >> n >> h; vector<pair<int, int>> zeros; int a, b; for (int i = 0; i < n; i++) { cin >> a >> b; zeros.push_back(make_pair(a, b)); } int sol = 0; int pa, pb, ib, c1; pa = zeros[0].first; pb = ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n; int seq[N]; vector<int> zli[N]; int res[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , seq + i); seq[i] = n - seq[i]; zli[seq[i]].push_back(i); } int rodzaj = 0; ...
`timescale 1ns / 1ps `include "Defintions.v" module MiniAlu ( input wire Clock, input wire Reset, output wire [7:0] oLed output wire VGA_HSYNC, output wire VGA_VSYNC, output wire VGA_RED, output wire VGA_GREEN, output wire VGA_BLUE ); wire [15:0] wIP,wIP_temp,wIP_return; reg rWriteEnab...
#include <bits/stdc++.h> using namespace std; int a[100000], k, i, n, j; char c; int main() { string s; cin >> k; i = 0; int p = 0; getline(cin, s); getline(cin, s); for (j = 0; j < s.length(); j++) { c = s[j]; p++; if (c == ? || c == . || c == ! ) { if...
/* * Simple 8-bit wide GPIO module * * First byte is the GPIO I/O reg * Second is the direction register * * Set direction bit to '1' to output corresponding data bit. * * Register mapping: * * adr 0: gpio data 7:0 * adr 1: gpio dir 7:0 */ module gpio ( input wb_clk, input wb_rst, input wb...
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/verunilibs/data/unisims/IBUFGDS.v,v 1.8 2007/07/26 23:22:55 fphillip Exp $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // All Right Reserved. ///////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; int t, n, ans, lcp[5009][5009], dp[5009]; char a[5009]; int main() { scanf( %d , &t); while (t--) { scanf( %d , &n); scanf( %s , a + 1); ans = 0; for (int i = n; i >= 1; i--) for (int j = n; j >= 1; j--) lcp[i][j] = ...
#include <bits/stdc++.h> using namespace std; long long n, l, r, k, i, ans; int main() { scanf( %I64d%I64d%I64d%I64d , &n, &l, &r, &k); r = (r + n - l + 1) % n; if (k < r) { printf( -1 ); return 0; } if (2 * r >= k) { ans = min(k + n - r * 2 + 1, n); if (ans >= k - r) {...
#include <bits/stdc++.h> using namespace std; int k; string s; vector<string> ans; bool all[26]; int main() { ios_base::sync_with_stdio(0); cin >> k >> s; string build = ; for (int i = 0; i < s.size(); ++i) if (!all[s[i] - a ]) { if (!build.empty()) ans.push_back(build); ...
// *************************************************************************** // *************************************************************************** // Copyright 2013(c) Analog Devices, Inc. // Author: Lars-Peter Clausen <> // // All rights reserved. // // Redistribution and use in source and binary forms, ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int sigma = maxn; const int HASH_CNT = 2; int n; char s[maxn]; unsigned long long Prime_Pool[] = {1998585857ul, 23333333333ul}; unsigned long long Seed_Pool[] = {146527, 19260817}; unsigned long long Mod_Pool[] = {1000000009...
// Copyright (c) 2001 Stephen Williams () // // This source code is free software; you can redistribute it // and/or modify it in source code form under the terms of the GNU // General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) // ...
/** * 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, p, q; pair<int, int> pro[100010]; long long cross(int x1, int y1, int x2, int y2) { return x1 * (long long)y2 - x2 * (long long)y1; } double cross2(double x1, double y1, double x2, double y2) { return x1 * y2 - x2 * y1; } bool check(pair<int, ...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void __print(int x) { cout << x; } void __print(long x) { cout << x; } void __print...
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_rd_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi...
// Copyright (C) 1991-2013 Altera Corporation // 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 from any of the foregoing // (including device programming or simulation files), and any // associated d...
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7; int qpow(long long a, long long b) { long long c = 1; while (b) { if (b & 1) c = c * a % Mod; if (b >>= 1) a = a * a % Mod; } return c; } int n; long long a; int p, q; int main() { scanf( %d , &n); ...
#include <bits/stdc++.h> int input[1001]; int ans[1001][2]; int main() { int n, i, answer; scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d , &input[i]); ans[0][0] = 1; for (i = 1; i < n; i++) { if (input[i] >= input[i - 1]) ans[i][0] = 1 + ans[i - 1][0]; else ans...
#include <bits/stdc++.h> using namespace std; int main() { pair<int, int> k[3]; char cell[9][9]; int n; cin >> n; char c; int z = 0; while (n) { for (int i = 1; i < 9; i++) { for (int j = 1; j < 9; j++) { cin >> c; if (c == K ) { k[z].first ...
#include <bits/stdc++.h> using namespace std; const int maxN = 105; int n, s, c[maxN], sum1, sum2; vector<int> d; bool cmp(int A, int B) { return A > B; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> s; for (in...
// -------------------------------------------------------------------------------- //| Avalon Streaming Channel Adapter // -------------------------------------------------------------------------------- `timescale 1ns / 100ps module soc_system_hps_only_master_b2p_adapter ( // Interface: clk input ...
// This tests assigning value lists to packed arrays // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2012 by Iztok Jeras. module test (); // parameters for array sizes localparam WA = 4; localparam WB = 4; // 2D packed arrays logic [WA-1:0] [WB-1:0] abg0, abg1,...
#include <bits/stdc++.h> #define st first #define nd second #define pb push_back #define BOOST ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); #define PI 3.14159265359 using namespace std; typedef long long ll; constexpr ll MOD = 1000000007, sup = 29; constexpr ll MOD_1 = 1234567891...
#include <bits/stdc++.h> using namespace std; int ans[2020], cnt = 0, k; int main() { cin >> k; k++; ans[++cnt] = -1; while (k >= 1e6 - 1) { k -= 1e6 - 1; ans[++cnt] = 1e6 - 1 + 1; } ans[++cnt] = k + 1; cout << cnt << endl; for (int i = 1; i <= cnt; i++) cout << ans[i] ...
// megafunction wizard: %LPM_BUSTRI% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: lpm_bustri // ============================================================ // File Name: bustri.v // Megafunction Name(s): // lpm_bustri // ============================================================ // *********************...
#include <bits/stdc++.h> const int N = 1e5 + 1, B = 128; int i, j, n, m, r, a[N], f[N][B]; int main() { for (scanf( %d , &n); ++i <= n; scanf( %d , a + i)) ; for (j = 1; j < B; ++j) for (i = n; i; --i) f[i][j] = i + j + a[i] > n ? 1 : f[i + j + a[i]][j] + 1; for (scanf( %d , &m); m--;) { ...
#include <bits/stdc++.h> using namespace std; string solve1(string n) { string res(n.length(), 9 ); for (char c = 8 ; c >= 0 ; c--) { string t(n.length(), c); if (t >= n) res = t; } return res; } string solve2(string n) { string res = solve1(n); for (char a = 0 ; a <= 9 ...
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; int n = s1.length(), p = 0, a = 0, p2 = 0; for (int i = 0; i < n; i++) if (s1[i] == + ) p++; int m = n - p; for (int i = 0; i < n; i++) { if (s2[i] == ? ) a++; else if (s2[i...
//************************************************************************** // hp_bytequad.v - wrapper for 4 FIFOs in the host to parasite direction. // // COPYRIGHT 2010 Richard Evans, Ed Spittles // // This file is part of tube - an Acorn Tube ULA compatible system. // // tube is free software: yo...
/** * 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> #pragma GCC optimize( Ofast ) using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; int temp; long long sol = 0; cin >> s; if ((s[0] - 0 ) % 4 == 0) { sol++; } for (int a = s.length() - 1; a > 0; a--) {...
#include <bits/stdc++.h> #pragma GCC optimize Ofast,omit-frame-pointer,inline using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int mx = -INT_MAX; multiset<int> vs; for (int i = 0; i < n; i++) { int x; cin >> x; mx ...
#include <bits/stdc++.h> using namespace std; const int N = 40; const int M = 20; long long incident_mask[N]; vector<int> g[N]; int n, m, used[N]; long long ans = 0; long long cntmask[1 << M]; template <typename T> inline void chkmax(T &x, T y) { x = max(x, y); } template <typename T> inli...
/** * 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...