text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define FOR(i, n) for (signed i = 0; i < n; ++i) #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() #define VI vector<int> #define VII vector<VI> #define PII pair<int, int> #defin...
// (c) Copyright 1995-2016 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 ...
/** * 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> template <class T> std::vector<T> ReadVector(size_t size) { std::vector<T> vector(size); for (auto& element : vector) { std::cin >> element; } return vector; } int64_t divisor(int64_t x) { for (int64_t d = 2; d * d <= x; ++d) { while (x % d == 0) { ...
#include <bits/stdc++.h> using namespace std; template <class T> void chmin(T& a, const T& b) { if (a > b) a = b; } template <class T> void chmax(T& a, const T& b) { if (a < b) a = b; } tuple<long long, long long, long long> adj[400001]; long long cnt; long long nm; int main() { long l...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native ) #pragma GCC optimize( unroll-loops ) using namespace std; template <typename T, typename U> inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) { _out << _p.first ...
#include <bits/stdc++.h> using namespace std; bool f[110][110][2][60]; int main() { string str; cin >> str; int n = str.size(); int m; cin >> m; memset(f, 0, sizeof(f)); f[0][0][1][0] = 1; for (int i = 0; i < n; i++) { char ch = str[i]; for (int dist = 0; dist <= n; dis...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int n, q, k; vector<pair<int, int> > tree[N << 2]; int ask[N], ans[N]; struct que { int x, y, times, l; }; queue<que> Q; int fa[N], h[N], siz[N]; int find(int o) { if (o != fa[o]) { return find(fa[o]); } retu...
#include <bits/stdc++.h> using namespace std; int T, n, k, l, a[300010], lst; bool flag = 0; int main() { scanf( %d , &T); while (T--) { flag = 0; lst = 0; scanf( %d%d%d , &n, &k, &l); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); if (a[i] > l) flag...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define rep(i,a,b) for( i=a;i<b;++i) #define repr(i,a,b) for( i=a;i>=b;i--) #define up upper_bound #define lb lower_bound #define ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m = 1, a, t1 = 1, tong = 0; cin >> n; while (1) { tong += t1; if (tong > n) { cout << --m; return 0; } t1 += ++m; } return 0; }
#include <bits/stdc++.h> using namespace std; string a[200009]; int pre[1 << 20][22], cost[200009], n, m, dp[200009]; int compute(string suf, string pre) { for (int k = int(0); k <= int(m - 1); k++) { int j = k, i = 0; while (j < m) { if (suf[j] == pre[i]) { j++; 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...
// Icarus 0.6, snapshot 20020907 // ================================================== // -- confused by disables from within a fork -- vvp fails // // -- to run, incant // iverilog tt.v // vvp a.out module top; integer simple_fail, loop_fail, fork_fail, tlp_fail, tfk_fail; integ...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. ...
`timescale 1ns / 1ps module LowPassFilter(clk, new_sample, input_sample, output_sample); input clk; input new_sample; reg enable_systolic; wire clk_systolic; input [15:0] input_sample; output [15:0] output_sample; reg [2:0] state; localparam IDLE = 3'd0, CLK_A = 3'd1, CLK_B = 3...
// Identifies the sequence 11101 // includes a overlap bit sequence as well module jfsmMooreWithOverlap(dataout, clock, reset, datain); output reg dataout; input clock, reset, datain; reg[2:0] cs, ns; parameter a = 3'b000; parameter b = 3'b001; parameter c = 3'b010; parameter d = 3'b011; parameter...
/******************************************************************************* * 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 ...
#include<bits/stdc++.h> #define fre(x) freopen(#x .in , r ,stdin);freopen(#x .out , w ,stdout) #define ll long long using namespace std; inline int read(){ int x=0,f=1;char c=getchar(); while(c< 0 ||c> 9 ) { if(c== - ) f=-1;c=getchar(); } while(c>= 0 &&c<= 9 ) x=(x<<3)+(x<<1)+(c^ 0 ),c=getchar(); re...
#include <bits/stdc++.h> using namespace std; clock_t timeStart, timeFinish; void timeBegin() { timeStart = clock(); } void timeEnd() { timeFinish = clock(); } void timeDuration() { timeEnd(); double time_taken = double(timeFinish - timeStart) / double(CLOCKS_PER_SEC); cout << Time taken by progr...
//Legal Notice: (C)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 do...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2015.4 // Copyright (C) 2015 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1ns/1ps modul...
/** * 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 i, j, k, l, n, a, b, ans = 0; int gcd(int a, int b) { if (a < b) swap(a, b); return (b == 0) ? a : gcd(b, a % b); } struct st { int first; long double second; }; int main() { std::ios_base::sync_with_stdio(0); string s; ci...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
//Legal Notice: (C)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 do...
//*******************************************************************************************************************************************************/ // Module Name: user_interface // Module Type: User Interface and External Communications Module // Author: Shreyas Vinod // Purpose: User Interface and External...
#include <bits/stdc++.h> using namespace std; bool s[100005]; int main() { int n; cin >> n; n *= 2; int ans = 0, rst = 0; ; while (n--) { int tmp; cin >> tmp; if (s[tmp]) ans -= 1; else s[tmp] = 1, ans++; rst = max(rst, ans); } cout << ...
#include <bits/stdc++.h> using namespace std; const int N = 356438; int from[N], to[N], limL, nextp[N], headp[N], p[N], Lcnt[N], chcnt[N], num, a[N], b[N], sz, c[N]; bool taboo[N], boo[N]; long long limW, W[N], Wcnt[N], ans; inline int lowbit(int x) { return x & (-x); } inline int ask(int x) { i...
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, ways = 0; int c[100]; cin >> n; for (int i = 0; i < n; ++i) { cin >> c[i]; sum = sum + c[i]; } for (int i = 0; i < n; ++i) { if ((sum - c[i]) % 2 == 0) ways++; } cout << ways << endl; ret...
`define WIDTH_P 3 `define CASE_P 1 // XOR:1, AND:2, OR:3 /**************************** TEST RATIONALE ******************************* 1. STATE SPACE This module tests hi_to_lo and lo_to_hi simultaneously by instantiating two DUTs, DUT_hilo and DUT_lohi. Each unit is tested for entire state space of a binary nu...
/* * 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, e_min = INT_MAX, e_max = INT_MIN; list<int> l; cin >> n; for (int i = 1; i <= n; ++i) { cin >> x; if (x < e_min) e_min = x; if (x > e_max) e_max = x; l.push_back(x); } l.remove_if( [e_min, e_...
/** * 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; struct hh { int num; int c; }; bool cmp(const hh p, const hh q) { return p.c < q.c; } int main() { int n, k; scanf( %d%d , &n, &k); hh a[1010], b[1010]; int i; int p = 0, q = 0; vector<int> ss[1010]; for (i = 0; i < n; ++i) { ...
`timescale 1ns / 1ps //********************************************************************** // File: spi_master.v // Module:spi_master // by Robin zhang //********************************************************************** module spi_master( clk,rst_n, spi_miso,spi_mosi,spi_clk, spi_tx_en,spi_rx_en,spi_over,mo...
#include <bits/stdc++.h> using namespace std; using ll = long long; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <class T> T rand(T a, T b) { return uniform_int_distribution<T>(a, b)(rng); } template <class T> T rand() { return uniform_int_distribution<T>()(rng);...
#include <bits/stdc++.h> using namespace std; long long int n; string s; vector<long long int> ss; inline bool check(long long int lim) { long long int sum = 0, cnt = 0; for (long long int i = 0; i < ss.size(); i++) { if (sum + ss[i] <= lim) { sum += ss[i]; } else { cnt++; ...
#include <bits/stdc++.h> using namespace std; const int N_MAX = 1005, M_MAX = 100005; struct union_find { int rank[N_MAX], parent[N_MAX]; union_find() { for (int i = 0; i < N_MAX; i++) { rank[i] = 0; parent[i] = i; } } int find(int x) { return x == parent[x] ? x : paren...
// *************************************************************************** // *************************************************************************** // 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; int n, t, a[110]; int main() { scanf( %d%d , &n, &t); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } for (int i = 1; i <= n; i++) { t = t - 86400 + a[i]; if (t <= 0) { printf( %d , i); break; } } re...
/** * 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 inf = 0x3f3f3f3f; long long cal(long long x) { return (x + 1) * x / 2; } int main() { std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long n; cin >> n; long long l = 0, r = 1e8, ans = -1; while (l <= r) { long long...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a; int sum = 0; for (int i = 0; i < n; i++) { cin >> a; sum += a; } cout << (sum % n == 0 ? n : n - 1) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n; long long A[N]; map<long long, long long> MP; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %lld , &A[i]); MP.insert({A[1] - 1, 0}); for (int i = 2; i <= n; i++) { long long B = -1; whi...
//Integer to IEEE Floating Point Converter (Single Precision) //Copyright (C) Jonathan P Dawson 2013 //2013-12-12 module int_to_float( input_a, input_a_stb, output_z_ack, clk, rst, output_z, output_z_stb, input_a_ack); input clk; input rst; ...
// This tests SystemVerilog casting support // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2012 by Iztok Jeras. // Extended by Maciej Suminski // Copied and modified by Martin Whitaker // Copied and modified again by Lars-Peter Clausen module test(); typedef logic [7:0] pa...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int inf = (int)1e9; struct vert { int to, z, num; }; struct ans { int x, y, z; }; const int N = (int)(1e5) + 5; int n, m; vector<vert> g[N]; vector<int> d(N, inf); vector<int> dp(N, inf); vector<int> pr(N...
#include <bits/stdc++.h> using namespace std; int nx[1000514 * 2][26], spt; int fl[1000514 * 2], ll[1000514 * 2], lp[1000514 * 2]; int newnode() { memset(nx[spt], 0, sizeof(nx[spt])); fl[spt] = ll[spt] = lp[spt] = 0; return spt++; } void add(int root, int& last, char A) { int a = A - a ; ...
#include <bits/stdc++.h> using namespace std; string s; char zh[125], ch, sw; int n, m; int main() { cin >> n >> m >> s; for (int i = 97; i <= 122; i += 1) { zh[i] = i; } for (int i = 1; i <= m; i += 1) { cin >> ch >> sw; for (int j = 97; j <= 122; j += 1) { if (zh[j]...
#include <bits/stdc++.h> using namespace std; void _dbg(string) { cout << endl; } template <class H, class... T> void _dbg(string s, H h, T... t) { int l = s.find( , ); cout << s.substr(0, l) << = << h << , ; _dbg(s.substr(l + 1), t...); } template <class T, class U> ostream& operator<<(...
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; if (n == 1) cout << -1 ; else cout << n << << n + 1 << << n * n + n; return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9; const long long N = 1e5 + 1; const long long mod = 1e9 + 7; const long double eps = 1E-7; vector<int> a[N]; int n, k, x, ans; int main() { ios_base::sync_with_stdio(0); cin >> n >> k; for (int i = 1; i <= k; i++) cin >>...
module bit_reversal #(parameter dat_w=5) ( input wire [dat_w-1:0] dat_i, input wire [2:0] bitrev, output reg [dat_w-1:0] dat_o); integer i; always@* begin dat_o = dat_i; //Always keep LSB casex(bitrev) 3'b000: //Reverse 6 bits (keep LSB) for(i=1;i<7;i=i+1) d...
/* * 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() { ios::sync_with_stdio(false); cin.tie(0); long long n, i, j, k, x, MOD = 1000000007, ans, a1, a2, b1, b2, a, b; string s1, s2; cin >> n >> s1 >> s2; vector<vector<long long>> dp(n + 1, vector<long long>(4, 0)); dp[0][0] = 1; f...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); double l, x, v1, v2, k; cin >> l >> x >> v1 >> v2 >> k; double n = ceil(l / k); double t2, t1; t2 = x / (v2 * (n * ((v1 + v2) / (v2 - v1)) - (n - 1))); t1 = t2 * (v1 + v2) / (v2 - v1); ...
#include <bits/stdc++.h> using namespace std; const int i32INF = 1 << 30; const long long i64INF = 1LL << 60; const double mINF = 1e100; const double EPS = 1e-9; int nextint() { int a; scanf( %d , &a); return a; } int n; vector<int> v; int difs[23][23]; bool isGood[1 << 23]; bool sol...
/** * 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 int n; map<pair<long long int, long long int>, long long int> val; long long int get_lca(long long int x, long long int y) { vector<long long int> a, b; a.clear(); b.clear(); while (x > 0) { a.push_back(x); x >>= 1; } wh...
module FpuFpF_Add( /* verilator lint_off UNUSED */ clk, isen, doSub, srca, srcb, dst ); input clk; input isen; input doSub; input[31:0] srca; input[31:0] srcb; output[31:0] dst; reg sgna; reg sgnb; reg sgnc; reg[9:0] exa; reg[9:0] exb; reg[9:0] exc; reg[9:0] exm; reg[31:0] tFracA; reg[31:0] tFracB; ...
#include <iostream> using namespace std; int main() { int n,q, l,r; cin>>n>>q; string s; cin>>s; int arr[n]; arr[0]=s[0]- a +1; for(int i=1;i<n;i++){ arr[i]=arr[i-1]+s[i]- a +1; } while(q--){ cin>>l>>r; cout<<(arr[r-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; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, k, x, s = 0; cin >> n >> k; map<long long, long long> m; queue<long long> q; for (long long i = 0; 0 < n ? i < n : i > n; 0 < n ? i += 1 : i -= 1) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = (int)1e5 + 5; int _ = 1; int n, q; int a[N], pos[N]; int nex[N], blo; int calc(int x) { for (int i = 1; i <= blo; i++) x = a[x]; return x; } void work() { scanf( %d%d , &n, &q); blo = sqrt(n) + 1; f...
/* * 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 q; cin >> q; for (int i = 0; i < q; i++) { int n; cin >> n; int ans = 0; int ct_4 = n / 4; int rem = n % 4; if (rem == 1) { ct_4 -= 2; ans = ct_4 + 1; } else if (rem == 2) { c...
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T a) { return a * a; } int n; int a[21000]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int best = -1000000000; for (int i = 3; i <= n; i++) if (n % i == 0) { int g = n / i; ...
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { x = 0; char ch = getchar(), flag = 0; while ((ch > 9 || ch < 0 ) && ch != - ) ch = getchar(); if (ch == - ) flag = 1, ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); if (flag) ...
#include<bits/stdc++.h> using namespace std; #define INF 1234567890 #define ll long long int T; int N, K; int A[200201]; int main() { //ios::sync_with_stdio(0); cin.tie(0); scanf( %d , &T); while(T--) { scanf( %d %d , &N, &K); for(int i=1; i<=N; i++) { if (i <= K) 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 law...
#include <bits/stdc++.h> using namespace std; long long int n, k, a, b; vector<long long int> arr; long long int rec(long long int l, long long int r) { long long int i = lower_bound(arr.begin(), arr.end(), l) - arr.begin(); long long int j = upper_bound(arr.begin(), arr.end(), r) - arr.begin(); lon...
#include <bits/stdc++.h> using namespace std; int fr[200004]; struct cmp { bool operator()(int a, int b) const { return a > b; } }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; auto make = [](vector<int>& a, int pos) { swap(a[pos + 2], a[pos + 1]); ...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 5; int n; pair<int, int> a[MAX]; struct par { int a, b; par(int a, int b) : a(a), b(b) {} bool operator<(const par &p) const { return b < p.b; } }; multiset<par> s; multiset<int> sizes; int main() { scanf( %d , &n); ...
// nios_tester_audio_out_dma.v // This file was auto-generated from altera_msgdma_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 18.1 625 `timescale 1 ps / 1 ps module nios_tester_audio_out_dma ( output wire [25:0] mm_read_address, // mm_rea...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int N = 1e6 + 5; const int inf = 1 << 30; const long long llf = 9e18; long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = re...
/** * 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( O3 ) using namespace std; using ll = long long; using ld = long double; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vpi = vector<pi>; using si = set<int>; using sl = set<ll>; using qi = qu...
#include <bits/stdc++.h> using namespace std; string str; set<string> vis; int main() { int n; scanf( %d , &n); vis.clear(); for (int i = 0; i < n; ++i) { cin >> str; if (vis.find(str) != vis.end()) cout << YES << endl; else cout << NO << endl; vis.ins...
#include <bits/stdc++.h> using namespace std; int main() { int numRows, numCols; scanf( %d %d n , &numRows, &numCols); bool *rowArray = new bool[numRows]; for (int k = 0; k < numRows; k++) { rowArray[k] = 1; } bool *colArray = new bool[numCols]; for (int k = 0; k < numCols; k++) { ...
#include <bits/stdc++.h> using namespace std; int N, M; int A[50050], X[50500]; int L[50050], R[50500]; int XX[1010101]; int ma[50505]; int ret[50505]; signed long long xorxor(signed long long val) { int i; signed long long ret = ((val + 1) / 2) % 2; for (i = 0; i <= 29; i++) if ((val ...
/** * 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...
// dig /* ------------------------------------------------------------------------------- Copyright 2014 Parallax Inc. This file is part of the hardware description for the Propeller 1 Design. The Propeller 1 Design is free software: you can redistribute it and/or modify it under the terms of the GNU Genera...
#include <bits/stdc++.h> int main(void) { int n, w; int el[(4 * 100 * 1000)], be[(4 * 100 * 1000)]; int k[(4 * 100 * 1000)]; int i, j, z; scanf( %d %d , &n, &w); if (w == 1) { printf( %d n , n); return 0; } n--; for (i = 0; i <= n; i++) { if (i == 0) { sca...
/***************************************************************************** * * * Module: Altera_UP_RS232_Counters * * Description: * * ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_clk_gclk_inv_224x.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...
// (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...
// ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014 // // Z80 clocking module, also contains some wait-stating when 14MHz /* This file is part of ZX-Evo Base Configuration firmware. ZX-Evo Base Configuration firmware is free software: you can redistribute it and/or modify it under t...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops , omit-frame-pointer , inline ) #pragma GCC option( arch=native , tune=native , no-zero-upper ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) using namespace std; int n, q, fa[66666], aa[66666...
#include <bits/stdc++.h> using namespace std; const int N = 200010; vector<int> e[N]; set<int> l[N]; int n; void exitno() { printf( -1 n ); exit(0); } int exitans(int x) { while (x % 2 == 0) x /= 2; printf( %d n , x); exit(0); } void _dfs(int p, int fa) { if (fa && e[p].size(...
#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 T> i...
#include <bits/stdc++.h> using namespace std; int n, k, s = 0, a; int sg(int x) { if (x == 0 || x == 1) return x; if (k % 2 == 0) { if (x == 2) return 2; if (x % 2 == 0) return 1; else return 0; } else { if (x == 2) return 0; if (x == 3) return 1; if...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: testIm_rom.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 5; const long long linf = 1e18 + 5; const int N = 3000 + 5; int n, x, y, all, up[N], down[N], w[N]; vector<pair<int, int> > v[N]; void dfs(int root, int x, int w, int up, int down) { ::up[x] = up; ::down[x] = down; ::w[x] = w;...
#include <bits/stdc++.h> using namespace std; mt19937 rd(chrono ::steady_clock ::now().time_since_epoch().count()); long long Rand(long long l, long long h) { return l + rd() % (h - l + 1); } template <typename T> inline void read(T &x) { register char c; bool sign = 0; for (c = getchar(); !isdigi...
#include <bits/stdc++.h> using namespace std; int main() { int n, q, i; cin >> q; for (i = 0; i < q; i++) { cin >> n; if (n == 2) { cout << 2 << endl; } else if (n % 2 == 1) { cout << 1 << endl; } else if (n != 2 && n % 2 == 0) { cout << 0 << endl; ...
module arbiter( input wire clk, input wire reset, // Slave 0 input wire [17:0] s0_address, input wire s0_write, input wire s0_read, input wire [35:0] s0_writedata, output reg [35:0] s0_readdata, output reg s0_waitrequest, // Slave 1 input wire [17:0] s1_address, input wire s1_write, input wire s1_read, ...
#include <bits/stdc++.h> int n; int main() { int i; scanf( %d , &n); for (i = 20; i >= 0; i--) { if (n & (1 << i)) printf( %d , i + 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...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int MAXN = 1e3 + 10; inline long long in() { long long x = 0, flag = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) flag = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ...