text
stringlengths
59
71.4k
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; const int M = 23; const int inf = 1e9 + 7; const long long base = 1e18; const double pi = acos(-1); const double ep = 1e-9; map<int, int> st; int pre[1 << M]; int cur[1 << M]; int n; int a[N]; int main() { cin >> n; f...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2014/12/04 10:19:43 // Design Name: // Module Name: onetswitch_top // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // /...
////////////////////////////////////////////////////////////////////// //// //// //// eth_txcounters.v //// //// //// //// This file is part of the E...
// Avalon_Test_Streaming.v // Generated using ACDS version 16.1 196 `timescale 1 ps / 1 ps module Avalon_Test_Streaming ( ); wire [0:0] st_source_bfm_src_valid; // st_source_bfm:src_valid -> st_sink_bfm:sink_valid wire [31:0] st_source_bfm_src_data; // st_source_bfm:src_data -> st_sink_bfm:sink_data...
/* * Copyright (c) 2000 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) * ...
#include <bits/stdc++.h> const int S = 1 << 21; char ibuf[S], *iS, *iT, obuf[S], *oS = obuf, *oT = oS + S - 1; struct Flusher_ { ~Flusher_() { (fwrite(obuf, 1, oS - obuf, stdout), oS = obuf, void()); } } flusher_; template <class T> inline void read(T &x) { x = 0; register char c = (iS == iT ? (...
#include <bits/stdc++.h> using namespace std; const int maxn = 25; const int maxm = 3000; char maze[maxn][maxn]; int g[maxn * maxn][maxn * maxn]; int n, m, N, M; int src, sink; long long ans; struct Node { int r, c, t; Node() {} Node(int r, int c, int t) : r(r), c(c), t(t) {} }; vector...
#include <bits/stdc++.h> using namespace std; int a[1500004]; int main() { int t, c; string s; cin >> t; for (int l = 0; l < t; l++) { cin >> s; c = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == o && s[i + 1] == n && s[i + 2] == e || s[i - 1] == t...
#include <bits/stdc++.h> using namespace std; const int N = 35, M = 100005; int n, m, f, ans, e; char a[N][M]; int len[N], z[M], b[N][M], p[N][M]; vector<int> v[M]; void dfs(int pos) { if (f) return; z[pos] = 2; for (auto &i : v[pos]) if (!z[i]) dfs(i); else if (z[i] == 2) ...
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; s += arr[i]; } int count = 0, k = 0; for (int i = 0; i < n - 1; i++) { k += arr[i]; if (k == (s - k)) count++; } cou...
`timescale 1ns/100ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit must be 1 10 or 100 * -base is the time base for each unit, ranging from seconds * to femtoseconds, and must be...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////////////// // Company: Digilent Inc. // Engineer: Andrew Skreen // // Create Date: 07/11/2012 // Module Name: digit_select // Project Name: PmodGYRO_Demo // Target Devices: Nexys3 // Tool versions: ISE 14.1 //...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int MAX = 1e9 + 5; int i, j, w1, w2, k, n, m, a[N], b[N], calca[N], calcb[N], temp; vector<pair<int, int> > ans, adasd; bool ctr(int s) { int set = 0; int p1 = 0; int p2 = 0; int last1 = 0; int last2 = 0; int ...
/** * 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...
module latch_mem_wb ( input clock , input reset , input [ 5:0] stall , input mem_register_write_enable , output reg wb_register_write_enable , input [ 4:0] mem_register_wri...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.3 (win64) Build Mon Sep 28 20:06:43 MDT 2015 // Date : Wed Mar 30 14:50:00 2016 // Host : DESKTOP-5FTSDRT running 64-bit major releas...
#include <bits/stdc++.h> using namespace std; long long int arr[3000000], a[3000000]; vector<long long int> v; int main() { long long int n, ans = 0; cin >> n; for (long long int i = 0; i < n; i++) cin >> arr[i]; a[0] = 1; for (long long int i = 0; i < n; i++) { v.clear(); for (l...
/* * 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 cost(long long int h[], long long int n, long long int a, long long int r, long long int m, long long int x) { long long int plus = 0, minus = 0; for (int i = 0; i < n; i++) { if (h[i] > x) { minus += h[i] - x; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // 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...
#include <bits/stdc++.h> using namespace std; vector<long long> v[3001]; long long visited[3001][3001]; long long poss[3001]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, m, k; cin >> n >> m >> k; pair<long long, long long> parent[n + 1][n + 1]; for (l...
/** * 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> inline void Read(T &x) { x = 0; char c; while (!isdigit(c = getchar())) ; do { x = x * 10 + c - 0 ; } while (isdigit(c = getchar())); } long long read() { long long tmp; cin >> tmp; return tmp; }...
module conway #( parameter WIDTH = 32, parameter HEIGHT = 32 )( in_states, out_states ); input [WIDTH*HEIGHT-1:0] in_states; output [WIDTH*HEIGHT-1:0] out_states; genvar r, c; generate for (c = 0; c < WIDTH; c=c+1) begin assign out_states[c] = 0; assign ...
/* * 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...
/* Teak synthesiser for the Balsa language Copyright (C) 2007-2010 The University of Manchester 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 opti...
#include <bits/stdc++.h> using namespace std; char buf[(1 << 22)], *p1 = buf, *p2 = buf; inline int read() { char c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 22, stdin), p1 == p2) ? EOF : *p1++); int x = 0, f = 1; while (c< 0 | c> 9 ) { if (c == - ...
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m; cin >> n >> m; long long start = 0, end = 6 * (n + m); while (start <= end) { long long mid = (start + end) / 2; long long val1 = (mid / 2) - (mid / 6); long long val2 = (mid / 3) - (mid / 6); if ((m...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, l, r[200005], cnt = 0; bool valid[200005]; pair<int, int> p; pair<int, pair<int, int> > u; vector<int> v; vector<pair<int, pair<int, int> > > event; priority_queue<pair<int, int> > pq; scanf( %d %d , &n, &k); fo...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; set<int> s; for (int i = 0; i < n; i++) { int t; cin >> t; s.insert(t); } int a, b; cin >> a >> b; int res = 0; while (a > b) { int mx = 1; set<int> toerase; for (set<i...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (2 * c < d || 2 * d < c || d >= b) cout << -1 ; else { cout << 2 * a << endl << 2 * b << endl; if (c > d) cout << c; else cout << d; } return 0; }...
#include <bits/stdc++.h> using namespace std; long long i, n, r, a, q; void solve() { cin >> n; if (n == 4 || n == 1 || n == 2) { cout << -1 n ; return; } a = n / 3; r = n % 3; if (r == 1) { cout << n / 3 - 2 << 0 << 1 n ; return; } if (r ==...
#include <bits/stdc++.h> using namespace std; int main() { long long int a; cin >> a; while (1) { long long int t = a; long long int su = 0; while (t > 0) { su += t % 10; t /= 10; } if (su % 4 == 0) { cout << a; return 0; } 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; int n, m; const int MAXN = 1000005; char a[MAXN], b[MAXN]; int mi[MAXN], ma[MAXN]; long long ans = 0; int trs(char a, char b) { int s = 0; if (a == R ) s += 6; else if (a == B ) s += 3; if (b == R ) s += 2; else if (b =...
/** * 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) 2012-2013 * * * * 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...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int i, a, v, max, min, min1; cin >> a; max = min = a; for (i = 1; i < n; i++) { cin >> v; if (v > max) max = v; if (v < min) min = v; } cin >> a; min1 = a; for (i = 1; i < m;...
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, t, l, r, n, m, p, a, b, c, d, flag; cin >> t; while (t--) { cin >> n; for (i = 0; i < n; i++) { cout << (i + 1) << ; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_str...
/** * 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...
//Legal Notice: (C)2015 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; const int N_MAX = 1e5, V = (1 << 20); int n, x[N_MAX], t[N_MAX]; struct edge { int l, v; }; vector<edge> G[N_MAX]; long long cnt_tree[V + 1], total_tree[V + 1]; void add(int i, long long a, long long tree[]) { while (i <= V) { tree[i] += a; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a; map<int, int> mp; for (int i = 0; i < n; i++) { int val; cin >> val; if (mp.find(val) == mp.end()) { mp[val]++; a.push_back(val); } } sort(a.begin(),...
/* * 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 long long inf = 1000000007; const int maxn = 300010; int vis[maxn], cnt[maxn]; long long sum[maxn]; int mod(int x, int u) { int ret = 0; for (int i = 2; i <= u; ++i) if (vis[i]) { ret += x % i; } return ret; } long long ...
#include <bits/stdc++.h> int a[100005]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); int flag = -1; int sum = 0; int sum1 = 0; int ans = 1; for (int i = 1; i < n; i++) { if (a[i] == a[i - 1]) ans++; else { if (flag =...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.1 (lin64) Build 881834 Fri Apr 4 14:00:25 MDT 2014 // Date : Mon May 26 11:13:41 2014 // Host : macbook running 64-bit Arch Linux // ...
#include <bits/stdc++.h> using namespace std; const int SIZE = 1000; long long a, b, p, x; long long qpow(long long x, long long y, long long MOD) { long long res = 1; while (y) { if (y & 1) res = (res * x) % MOD; x = (x * x) % MOD; y = y >> 1; } return res; } int main() { ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, ans = 0; cin >> n; vector<int> a(n + 5), b(n + 5), c(n + 5); map<long long, long long> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i ...
//Legal Notice: (C)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 //simulation files), and any associate...
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 11; int use[N], a[N], b[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; use[a[i]] = 1; } for (int j = 1; j <= n; j++)...
#include <bits/stdc++.h> using namespace std; const int inf = 100010; const int N = 100010; struct e { int v; e *nxt; } es[N << 1], *fir[N]; map<pair<int, int>, int> mp; struct node { int ls, rs; int l, r; int sum; int mid() { return (l + r) >> 1; } } nodes[N << 2]; int n, en, ...
#include <bits/stdc++.h> using namespace std; long long a[100010]; int main() { long long n, pos; while (cin >> n >> pos) { for (long long i = 0; i < n; i++) scanf( %I64d , &a[i]); sort(a, a + n); long long res1 = 0, res2, res; if (pos < a[0]) res1 = a[n - 2] - pos; e...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long t; cin >> t; while (t--) { long long n, x, m, i, flag = 0, a, b, l, r, sum = 2, ones = 0, zero = 0, output = 0, j; vector<pair<long ...
#include <bits/stdc++.h> struct book { int t, w; bool operator<(const book &b) const { return w < b.w; } } ones[102], twos[102]; int main() { int n; scanf( %d , &n); int nOnes = 0; int tWidthOnes = 0; int nTwos = 0; int tWidthTwos = 0; for (int i = 0; i < n; i++) { int t,...
#include <bits/stdc++.h> using namespace std; const int N = 1003; const int mod = 1e9 + 7; int a[N][N]; int c[N]; int n; int sum; int main() { int i, j; scanf( %d , &n); for (i = 0; i < n; i++) for (j = 0; j < n; j++) scanf( %d , &a[i][j]); for (i = 0; i < n; i++) sum += a[i][i] * ...
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)(1e5 + 1e1); const double PI = acos(-1.0); long long a, m, t; int main() { cin >> m >> a; if (a == 0 && m > 1) { cout << No solution ; return 0; } cout << a; for (int i = 1; i < m; i++) cout << 0; return 0...
////////////////////////////////////////////////////////////////// //// //// //// CRCAHB CORE BLOCK //// //// //// //// This file is part of the APB to I2C project //// //// http://www.opencores.org/cores/apbi2c/ //// //// //// //// Description //// //// Implementation of APB IP core according to //// ...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> moves = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}}; bool isValid(int a, int b, int x, int y) { return (a >= 0 && a < x) && (b >= 0 && b < y); } bool isPath(int n, int m, vector<string>& mat) { bool isPossible = false; int cnt = 0; for (...
/* Register ======== This is the basic state element Parameters ---------- | Parameter | Default | Explanation | |-----------|:-------:|------------:| | `WIDTH` | 32 | Bitwidth of the register | | `INITIAL_VALUE` | 32'b0 | Value the register is initialized to, if applicable | | `RESET_VALUE` | 32'b0 | Value the registe...
#include<bits/stdc++.h> #define rep(i,st,en) for(int i=st;i<=en;i++) using namespace std; typedef long long ll; int t,x,y,i,n; int main() { scanf( %d ,&t); while(t--) { scanf( %d ,&n); rep(i,1,n)scanf( %d ,&x); printf( %d n ,3*n); rep(i,1,n/2) { x=2*i-1; y=2*i; ...
/* RC4 PRGA module implementation Copyright Groundworks Technologies 2012-2013 Author: Alfredo Ortega This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the Lic...
/** * 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...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
/////////////////////////////////////////////////////////////////////////////// // $Id: small_fifo.v 4761 2008-12-27 01:11:00Z jnaous $ // // Module: small_fifo.v // Project: UNET // Description: small fifo with no fallthrough i.e. data valid after rd is high // // Change history: // 7/20/07 -- Set nearly full to 2^M...
module RAM ( input wire rst, input wire clk, input wire[31:0] addrIn, input wire[15:0] write, input wire we, output wire[15:0] read, input wire re, input wire[1:0] inMask, input wire[1:0] outMask, output wire ready, output wire[10:0] lcdPins, output wire[15:0] page, ...
#include <bits/stdc++.h> using namespace std; int n, i, a, b, aux1, aux2, cs, cd, mij, rsp; char s[200005]; int u[200005], r[200005], l[200005], d[200005]; int main() { ios::sync_with_stdio(false); cin >> n; cin >> s; cin >> a >> b; if (abs(a) + abs(b) > n) { cout << -1; return...
#include <bits/stdc++.h> using namespace std; long long a[200010]; long long vis[200010]; long long cnt[200010]; long long n; long long max_n = 0; void solve(long long pos) { vis[pos]++; long long temp1 = pos; long long temp2 = pos; long long step1 = 0; long long step2 = 0; while (...
#include <bits/stdc++.h> using namespace std; void SieveOfErat() { bool prime[1000001]; memset(prime, true, sizeof(prime)); for (long long p = 2; p * p <= 1000000; p++) { if (prime[p] == true) { for (long long i = p * 2; i <= 1000000; i += p) prime[i] = false; } } } long long...
#include <bits/stdc++.h> using namespace std; long long n, m, ans, w[300000], d[300000], a, b; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n; i++) { w[i] = i; d[i] = 1; } ans = 1; for (int i = 1; i <= m; i++) { cin >> a >> b; while...
/** * 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; vector<pair<int, int> > v; long long dp[2][5001][51][51]; const long long oo = 1e16; int main() { cin >> n; v.resize(n); for (auto &x : v) cin >> x.first; int total = 0; for (auto &x : v) { cin >> x.second; total += x.secon...
/* * 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...
//input control module; //by jzc 20101022; `timescale 1ns/1ns module input_ctrl( clk, reset, crc_check_wrreq,//data fifo; crc_check_data, crc_usedw, crc_result_wrreq,//crc check fifo; crc_result, um2cdp_tx_enable,//to user module; cdp2um_data_valid, cdp2um_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 la...
//***************************************************************************** // (c) Copyright 2009 - 2010 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 /...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } inline void gn(long long &first) { int sg = 1; char c; while (((c = ge...
#include <bits/stdc++.h> using namespace std; int n, k, a[200], b[200], i, j, DP[3 * 10000]; int main() { cin >> n >> k; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 1; i <= n; i++) cin >> b[i], b[i] *= k; for (j = 10000; j >= -10000; j--) DP[j + 10000] = -(10000 * 10000); DP[10000] = 0; ...
/* * Copyright (c) 2001 Peter Bain * * 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) * any la...
#include <bits/stdc++.h> #pragma gcc optimize( Ofast ) using namespace std; inline void input(int &_x) { _x = 0; int _tmp = 1; char _tc = getchar(); while ((_tc < 0 || _tc > 9 ) && _tc != - ) _tc = getchar(); if (_tc == - ) _tc = getchar(), _tmp = -1; while (_tc >= 0 && _tc <= 9 ) ...
#include <bits/stdc++.h> using namespace std; typedef long long arr64[200020]; int n, tn, tS, qS = 1; pair<int, long long> pr[200020]; arr64 pX, pY, K, B; int main() { long long s; scanf( %d%I64d , &n, &s); for (int i = 1; i <= n; i++) scanf( %d%d , &pr[i].first, &pr[i].second); sort(pr + 1,...
#include <bits/stdc++.h> using namespace std; void Emsawy() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } const double PI = acos(-1.0); const double eps = 1e-10; const long long mod = 1e9 + 7, oo = 1e9; int dx[]{1, -1, 0, 0, 1, -1, 1, -1}; int dy[]{0, 0, 1, -1, 1, -1, -1, 1}; v...
//***************************************************************************** // (c) Copyright 2009 - 2010 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 /...
#include <bits/stdc++.h> using namespace std; int n, m, K; char maze[2010][2010]; int up[2010][2010], down[2010][2010]; struct Segtree { int key[2010 * 4], ans[2010 * 4]; void add(deque<pair<int, int> > &que, int pos, int val) { while (!que.empty() && val < que.back().second) que.pop_back(); ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a[51], n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int res = INT_MAX; for (int i = 1; i < n; i++) { res = min(res, a[i] - a[i - 1]); }...
/* * Miller Encoder * * By our algorithm, Miller Encoder can operate in the lowest frequency * to save the power dissipation * * This algorithm is also applied to FMo Encoder * * If enable Miller Encoder, disable FM0 Encoder and vice versa */ `timescale 1us / 1ns module miller_enc ( output ...
#include <bits/stdc++.h> const int mxn = 100000 + 10; using namespace std; string s; string soln; int main() { cin >> s; int n = s.size(); for (int i = 0; i < n; i++) if (s[i] == . ) printf( 0 ); else { if (s[i + 1] == - ) printf( 2 ); else ...
module tester; reg rrst ; reg [63:0] rdata ; reg [31:0] rparameter_Block ; reg [63:0] rparameter_Block2 ; reg [7:0] rbmRequestType ; reg [7:0] rbRequest ; reg [15:0] rwValue ; reg [15:0] rwIndex ; reg [15:0] rwLength ; reg renable ; wire wbusy ; wire [31:0] wdata_out; wire [63:0] wdata_out2;...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: drom32.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =================================...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); template <class T> T sqr(T x) { return x * x; } template <class T> T alex(T x) { return (x > 0) ? x : -x; } template <class T> void read(T& x) { x = 0; T f = 1; char ch = getchar(); while ((ch < 48 || c...
// Note: case_expr_{,non_}const.v should be modified in tandem to ensure both // the constant and non-constant case evaluation logic is covered module case_expr_non_const_top( // expected to output all 1s output reg a, b, c, d, e, f, g, h ); reg x_1b0 = 1'b0; reg x_1b1 = 1'b1; reg signed x_1sb0 = 1'sb0...
module testbench; localparam wide_width_lp = 16; localparam narrow_width_lp = 4; localparam els_lp = wide_width_lp / narrow_width_lp; logic clk; bsg_nonsynth_clock_gen #(.cycle_time_p(1000)) clock_gen (.o(clk)); logic reset; bsg_nonsynth_reset_gen #(.num_clocks_p(1) ,.reset_cycles_lo...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int P[] = {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4...
// zhiyang ong // andrew mattheisen `timescale 1ns/10ps `include "control.h" module controltb; reg [0:31] instr; reg clk; wire [0:4] aluop, rrdaddra, rrdaddrb, rwraddrd; wire [0:2] ppp, regop, memop; wire [0:1] ww; wire [0:20] maddr; wire reginmuxop, aluinmuxop; wire [0:15] wbytee...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, N = 100007; int n; long long ts, tf, t, a[N], ans = (long long)1e18, id; int main() { cin >> ts >> tf >> t; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; while (a[n] > tf - t) n--; a[++n] = tf - t + 1; long lo...