text
stringlengths
59
71.4k
`timescale 1ns / 10ps // I have made changes in this file (Ilia). Fixed zero_flag for synthesis. ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12:07:56 02/12/2015 // Design Name: // Module Name: top // Project Name: // Target ...
/** * 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02/23/2016 12:29:09 PM // Design Name: // Module Name: Week8Lab // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // R...
/* * 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...
// Converts the 256-bit DMA master to the 64-bit PCIe slave // Doesn't handle any special cases - the GUI validates that the parameters are consistant with our assumptions module dma_pcie_bridge ( clk, reset, // DMA interface (slave) dma_address, dma_read, dma_readdata, dma_readdatavalid, dma_w...
// ============================================================== // 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...
`default_nettype none module nkmd_ddr3_mig_if( input wire clk, input wire rst, // MIG interface output wire mig_cmd_clk, output wire mig_cmd_en, output wire [2:0] mig_cmd_instr, output wire [5:0] mig_cmd_bl, output wire [29:0] mig_cmd_byte_addr, input wire mig_cmd_empty, input w...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long powm(long long a, long long n) { long long base = 1; a %= MOD; while (n) { if (n & 1) base = base * a % MOD; a = a * a % MOD; n >>= 1; } return base; } int main() { long long a, b, ...
/**************************************************************************** Register File - Has two read ports (a and b) and one write port (c) - sel chooses the register to be read/written ****************************************************************************/ module reg_file(clk,resetn,...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/05/30 21:00:17 // Design Name: // Module Name: lab5_2_4_tb // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // R...
// cog_ram /* ------------------------------------------------------------------------------- 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 Ge...
/** * 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 INF = 1000000000 + 7; const double esp = 1e-13; const double pi = 3.141592653589; int n, m, f[100 + 10][100 + 10]; char a[100 + 10][100 + 10]; int main() { ios ::sync_with_stdio(false); cin >> n >> m; for (int i = (1), _b = (n); i <...
#include <bits/stdc++.h> int m(int a) { int ret = 0, i = 1; while (a > 0) { if (a % 10 == 4 || a % 10 == 7) { ret += (i * (a % 10)), i *= 10; } a /= 10; } return ret; } int main() { int a, b; while (scanf( %d%d , &a, &b) != EOF) { while (1) { a++; ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_clk_cl_jbusl_jbus.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...
// chris_slave.v // This file was auto-generated as a prototype implementation of a module // created in component editor. It ties off all outputs to ground and // ignores all inputs. It needs to be edited to make it do something // useful. // // This file will not be automatically regenerated. You should check it...
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); } template <class T> int cntbit(T s...
// (C) 2001-2016 Intel Corporation. All rights reserved. // Your use of Intel Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated docum...
#include <bits/stdc++.h> using namespace std; long long num[300010]; long long sum[300010]; int n; bool cmp(int a, int b) { return a > b; } int main() { while (~scanf( %d , &n)) { for (int i = 0; i < n; i++) cin >> num[i]; sort(num, num + n, cmp); sum[0] = num[0]; for (int i = 1;...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2011 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 // //...
//wb_gpio.v /* Distributed under the MIT license. Copyright (c) 2011 Dave McCoy () 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 ...
// Chuck Benz, Hollis, NH Copyright (c)2002 // // The information and description contained herein is the // property of Chuck Benz. // // Permission is granted for any reuse of this information // and description as long as this copyright notice is // preserved. Modifications may be made as long as this // notice 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...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-8; const int mxn = 100033; const int mod = 1e9 + 7; inline int read() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) f = c == - ? -1 : 1, c = getchar(); while (isdigit(c)) x = x *...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:25:35 10/11/2015 // Design Name: // Module Name: UART_tx // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > vec; int grid1[2050], grid2[2050]; int main() { int n; cin >> n; int r = 0, c = 0; long long ans = 0; for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; ans += grid1[x + y]; grid1[x + y]++; ...
#include <bits/stdc++.h> using namespace std; int n, x1, x2; struct server { int c, ind; bool b1, b2; int r1, r2; } * *srv; void qs(server** a, int l, int r) { int i = l, j = r; int p = a[(l + r) >> 1]->c; do { while (i < r && a[i]->c < p) i++; while (j > l && a[j]->c > p) ...
#include <bits/stdc++.h> using namespace std; template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> P) { return os << ( << P.first << , << P.second << ) ; } template <class T> ostream& operator<<(ostream& os, vector<T> V) { os << [ ; for (auto v : V) os << v << ; ...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } int main() { long long a[300005], p[300005]; long long n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >...
#include <bits/stdc++.h> using namespace std; const int N = 55; int n, siz[N]; vector<int> e[N]; double f[N][N], sav[N], C[N][N], fac[N]; void dfs(int x, int fa) { siz[x] = 0, f[x][0] = 1; for (const int &v : e[x]) if (v != fa) { dfs(v, x), ++siz[v]; double sum = 0, o; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long n; cin >> n; string s = ROYGBIV ; long long x = n - 7; string st = GBIV ; long long i = 0; while (i < x) { s += st[(i % 4)]; ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int MAX = 2 * 1000 * 100 + 47; struct Item { int a, t, ind; bool operator<(const Item& a) const { return t < a.t; } }; Item A[MAX...
#include <bits/stdc++.h> using namespace std; int bef[100050]; int main() { string s, s1; cin >> s; int len = s.size(); int last_a = -1; int now = 0; for (int i = 0; i < len; i++) { if (s[i] != a ) { s1 += s[i]; bef[now] = i; now++; } else { las...
#include <bits/stdc++.h> using namespace std; pair<long long, long long> a[300001]; long long n, k, s, m; bool b[300001]; inline long long read() { long long sum = 0, x = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) x = -1; ch = getchar(); } while (ch >...
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; for (int test = 0; test < q; test++) { int a, b, c, d, k; cin >> a >> b >> c >> d >> k; int pen = (a - 1) / c + 1, pencil = (b - 1) / d + 1; if (pen + pencil > k) { cout << -1 << n ; } els...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 2010; int n, m; long long f[N][N], g[N][N], h[N][N], o[N][N], p[N][N], ans; int main() { cin >> n >> m; memset(f, 0, sizeof(f)); memset(g, 0, sizeof(g)); memset(h, 0, sizeof(h)); memset(o, 0, sizeo...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,unroll-loops ) #pragma GCC target( avx,avx2,fma ) using namespace std; template <typename T> using vc = vector<T>; template <typename T> using uset = unordered_set<T>; template <typename A, typename B> using umap = unordered_map<A, B>; template <t...
#include <bits/stdc++.h> using namespace std; const int N = 50 + 5; int n, dp[N][N][N][N]; char g[N][N]; int dfs(int x, int y, int h, int w) { if (dp[x][y][h][w] != -1) return dp[x][y][h][w]; if (h == 1 && w == 1) return dp[x][y][h][w] = g[x][y] == # ; if (h == 0 || w == 0) return dp[x][y][h][w] ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; vector<int> *dist = new vector<int>[n]; int len = 0; for (int i = 0; i < n; i++) { int d; cin >> d; dist[d].push_back(i); len = max(len, d); } ...
//------------------------------------------------------------------------------ // (c) Copyright 2013-2015 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 propert...
`default_nettype none module multiple_blocking_gate (clk, ctrl, din, sel, dout); input wire clk; input wire [4:0] ctrl; input wire [1:0] din; input wire [0:0] sel; output reg [31:0] dout; reg [5:0] a; reg [0:0] b; reg [2:0] c; always @(posedge clk) begin a = (ct...
#include <bits/stdc++.h> using namespace std; long long int ar[500009], br[500009]; int main() { long long int a, b, c, i, j = 0, k = 9999999999999; string s; cin >> a; getchar(); cin >> s; for (i = 0; i < a; i++) { cin >> ar[i]; } for (i = 0; i < a - 1; i++) { if (s[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...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int x; cin >> x; vector<int> first(x); vector<int> second(x); int sum_f = 0; for (int i = 0; i < x; i++) { cin >> first[i]; sum_f += first[i]; } int sum_s = 0; for (int i = 0;...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: spu_mald.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it and/or /...
#include <bits/stdc++.h> using namespace std; typedef long double LD; typedef long long ll; #define int ll #define ff(i,a,b) for (int i = a; i < b; i++) #define bf(i,a,b) for (int i = a; i >= b; i--) #define all(v) v.begin(),v.end() #define show(a) for(auto xyz:a)cout<<xyz<< ;cout<<endl; #defi...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int a[1005][1005]; int main() { int h, w; cin >> h >> w; vector<int> r(h), c(w); for (int i = 0; i < h; i++) { cin >> r[i]; } for (int i = 0; i < w; i++) { cin >> c[i]; } memset(a, -1, sizeof(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...
#include <bits/stdc++.h> using namespace std; list<pair<int, long long> > l; long long get(int x) { long long ans = 0; for (list<pair<int, long long> >::iterator it = l.begin(), e = l.end(); it != e; ++it) { ans = max(ans, it->second); if (x <= it->first) { break; } ...
/** * 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 main() { long long n, g; cin >> n >> g; g %= 4 * n; long long xx, yy; cin >> xx >> yy; long long x[n], y[n]; for (int(i) = int(0); i < int(n); ++i) cin >> x[i] >> y[i]; for (int(i) = int(1); i < int(g + 1); ++i) { long long dx =...
`timescale 1ns/1ps module test(); reg clock, reset; sopc sopc( .clock(clock), .reset(reset) ); always #1 clock = ~clock; initial begin $dumpfile("dump.vcd"); $dumpvars; $dumpvars(0, sopc.cpu.register.storage[1]); $dumpvars(0, sopc.cpu.register.sto...
/** * 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 main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); long long n, m, l; cin >> n >> m >> l; vector<long long> a(n); vector<pair<long long, long long>> lr(n); long long ans = 0, old = -1000; long long flag = 0; for (long...
#include <bits/stdc++.h> using namespace std; int n, a, b; int ans, nn; char x[100010]; int change(int t) { int rtn = 0, bit = 1; while (t) { rtn += (t % 10) * bit; bit *= ans; t /= 10; } return rtn; } int main() { scanf( %d%d , &a, &b); int aa = a, bb = b; wh...
//------------------------------------------------------------------- // // COPYRIGHT (C) 2011, VIPcore Group, Fudan University // // THIS FILE MAY NOT BE MODIFIED OR REDISTRIBUTED WI...
//deps: fifo.v `timescale 1ns/1ps module fifo_tb; parameter FIFO_WIDTH = 8; /*AUTOWIRE*/ // Beginning of automatic wires (for undeclared instantiated-module outputs) wire empty; // From fifo of fifo.v wire full; // From fifo of fifo.v wire [FIFO_W...
/* This file is part of JT12. JT12 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. JT12 program is distributed...
#include <bits/stdc++.h> using namespace std; int question, r, speed, st, en, len, did; double lft, rht, middle, dist, p; inline double euclid_dist(double a, double b) { return sqrt(a * a + b * b); } inline bool check(double dis) { p = 1.0 * dis / r; return r * euclid_dist(1 - cos(p), sin(p)) >= len -...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000009; vector<long long> vec; long long powmod(long long a, long long m) { long long ret = 1 % MOD; for (; m; m >>= 1) { if (m & 1) { ret *= a; if (ret >= MOD) ret %= MOD; } a *= a; if (a >= ...
/* Copyright (c) 2019 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, distribute,...
#include <bits/stdc++.h> using namespace std; bool vv[2000][2000]; int main() { int n; string s; cin >> s; long long left[2000], right[2000]; for (int i = 0; i < s.length(); i++) { vv[i][i] = true; } int sm = 1, cp = s.length() - 1; for (; sm < s.length(); sm++) { for (...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; char E[1005][1005]; int N, M; struct Node { int step[3]; } s[1005][1005]; struct use { int x, y; }; void bfs(int x) { queue<use> que; use u, v; for (int i = 0; i < N; i++) { ...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of ent_ac // // Generated // by: wig // on: Mon Oct 24 15:17:36 2005 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl -nodelta ../../verilog.xls // // !!! Do not edit this file! Autogenerated by MIX !!! /...
//================================================================================================== // Filename : RKOA_OPCHANGE.v // Created On : 2016-10-26 23:25:59 // Last Modified : 2016-10-27 19:57:00 // Revision : // Author : Jorge Esteban Sequeira Rojas // Company : Instituto Tec...
#include <bits/stdc++.h> using namespace std; int n, q; int A[600006]; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } map<pair<int, int>, int> M; int L[600006], R[600006], lst[600006], cn; struct que { int l, r, idx; } Q[600006]; vector<int> bc[600006]; int T[600006]; void ad(int x, ...
/* * University of Illinois/NCSA * Open Source License * * Copyright (c) 2007-2014,The Board of Trustees of the University of * Illinois. All rights reserved. * * Copyright (c) 2014 Matthew Hicks * * Developed by: * * Matthew Hicks in the Department of Computer Science * The University of Illinois at...
/** * 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 MX = 100009; int arr[MX]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) scanf( %d , arr + i); int add = 0; for (int i = 0; i < m; ++i) { int cmd; scanf( %d , &cmd); if (cmd == 1) { i...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int maxlog = 24; int par[maxn][maxlog], h[maxn]; int siz[maxn]; bool mark[maxn]; int n; vector<int> adj[maxn]; void dfs(int x) { mark[x] = 1; for (int i = 0; i < adj[x].size(); i++) { int child = adj[x][i]; ...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, p; cin >> t; for (; t > 0; t--) { cin >> n >> p; int br = 0; for (int r = 1; r <= n; r++) { for (int i = 1; i <= n; i++) { cout << i << << (i + r - 1) % n + 1 << endl; br++; i...
module pcierc_test_eval_top ( // Clock and Reset input wire refclkp, // 100MHz from board input wire refclkn, // 100MHz from board output wire sys_clk_125, // 125MHz output clock from core input wire rst_n, // ASIC side p...
#include <bits/stdc++.h> using namespace std; int main() { long long n, mod = 1, cnt = 0, i, min; cin >> n; vector<int> v{1, 5, 10, 20, 100}; while (n) { min = INT_MAX; for (i = 0; i < 5; ++i) { if (n / v[i] >= 1) { if (min > n / v[i]) { min = n / v[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...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; const int MOD = 1e4 + 7; int n, m, q; int main() { scanf( %d , &q); while (q--) { int a, b; scanf( %d%d , &a, &b); int delt = abs(a - b); int ans = delt / 10 + (delt % 10 != 0); printf( %d n , ans); ...
`define WIDTH_P 3 `define ELS_P 4 `define SEED_P 1000 /**************************** TEST RATIONALE ******************************* 1. STATE SPACE All the elements in the memory are written once and the first ELS_P/4 elements are re-written with w_v_i kept LOW to check if those elements are overwritten. 2. ...
#include <bits/stdc++.h> using namespace std; int main() { stringstream ss; string s; cin >> s; for (int i = 0; i < s.length(); i++) { switch (s[i]) { case > : ss << 1000; break; case < : ss << 1001; break; case + : s...
// Problem: A. Meximization // Contest: Codeforces - Codeforces Round #708 (Div. 2) // URL: https://codeforces.com/contest/1497/problem/A // Memory Limit: 256 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org) #include <bits/stdc++.h> using INT=int; //#define int long long...
#include <bits/stdc++.h> #pragma GCC optimize trapv using namespace std; void solveEachTest(long long int T35TC453N = 1) { unsigned long long int a, b; cin >> a >> b; bool ok = true; bitset<64> xandy((a - b) / 2); bitset<64> xxory(b); unsigned long long int x = (a - b) / 2; unsigned ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Copied from: http://www.fpga4fun.com/Debouncer2.html // Create Date: 07:35:15 10/30/2014 // Module Name: PushButton_Debouncer ///////////////////////////////////////////////////////////////////////////////...
//------------------------------------------------------------------ //-- User test program for the Icezum Alhambra v1.1 board //-- (c) Juan Gonzalez-Gomez (Obijuan). Nov-2016 //------------------------------------------------------------------ //-- Released under the GPL license //-------------------------------------...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int sum = 0; for (int i = 0; i < n - 1; i++) sum += (a[n - 1] - a[i]); cout << sum; }
(** * Rel: Properties of Relations *) (* $Date: 2013-04-01 09:15:45 -0400 (Mon, 01 Apr 2013) $ *) Require Export SfLib. (** A (binary) _relation_ is just a parameterized proposition. As you know from your undergraduate discrete math course, there are a lot of ways of discussing and describing relations _in g...
#include <bits/stdc++.h> using namespace std; int main() { int kase, ks = 0; int i, j, k; int n; int arr[1000]; string s; cin >> n; for (i = 1; i < n + 1; i++) cin >> arr[i]; int q; cin >> q; int x, y; while (q--) { cin >> x >> y; if (x > 1) arr[x - 1] += (y -...
/* * 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() { long long int p, d; cin >> p >> d; long long int temp = 1; long long int po[19]; for (int i = 0; i <= 18; ++i) { po[i] = temp; temp *= 10; } int i = 1; temp = p; while (1) { long long int t = temp % po[i...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 5e5 + 10; int a[N]; int dp[2][N]; int minv[N]; int sum[N]; int n, k, p; class BIT { int a[110]; public: void init() { memset((a), (0x1f), sizeof(a)); } inline int lowbit(int x) { return x & -x;...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007ll; const double EPS = 1e-11; int n; char s[1252525]; int cntright[1252525]; int cntleft[1252525]; int revright[1252525]; int revleft[1252525]; long long sumright[1252525]; long long sumleft[1252525]; int main() { ...
#include <bits/stdc++.h> void print_row(int s, int *l, int size) { int i = s + 1; printf( %d , l[s]); while (i < size) printf( %d , l[i++]); i = 0; while (i < s) printf( %d , l[i++]); printf( n ); } int main() { int n, k; scanf( %d %d , &n, &k); int l[n]; l[0] = k; f...
`timescale 1ns/1ps module search_engine( clk, reset, key_in_valid, key_in, bv_out_valid, bv_out, localbus_cs_n, localbus_rd_wr, localbus_data, localbus_ale, localbus_ack_n, localbus_data_out ); input clk; input reset; input key_in_valid; input [71:0] ...
#include <bits/stdc++.h> using namespace std; const long long maxn = 5e5 + 10; long long N, arr[maxn], use[maxn]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; for (register long long i = 1; i <= N; ++i) { cin >> arr[i]; } sort(arr + 1, arr + 1 + N); long l...
#include <bits/stdc++.h> using namespace std; const int M = 110000; long long a[M], b[M], c[M], be[M]; long long n, d, x; long long getNextX() { x = (x * 37 + 10007) % 1000000007; return x; } void initAB() { long long i; for (i = 0; i < n; i = i + 1) { a[i] = i + 1; } for (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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); parameter PAR = 3; m1 #(PAR) m1(); m3 #(PAR) m3(); mnooverride #(10) mno(); input clk; integ...
`include "defines.vh" module divrem_tb; reg clk = 0; wire rst; reg go = 0; reg [15:0] num = 0; reg [15:0] den = 0; wire m1_ready; wire m1_error; wire [15:0] m1_quot; wire [15:0] m1_rem; reg [15:0] quot; reg [15:0] rem; por por_inst( .clk(clk), .rst(rst)); divrem dm1( .clk(clk), .go(go), .rst(rst), .n...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long a[50]; long long inv[50]; long long Finv[50]; long long n, s; void init() { inv[1] = 1; for (int i = 2; i <= 50; i++) { inv[i] = (mod - mod / i) * inv[mod % i] % mod; } Finv[0] = 1; for (int i = 1; i...
//wb_gpio.v /* Distributed under the MIT license. Copyright (c) 2011 Dave McCoy () 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 u...
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; char s[maxn][maxn]; int main() { int a, b; for (int i = 0; i < 11; i++) gets(s[i]); scanf( %d%d , &a, &b); int r = (a - 1) % 3, c = (b - 1) % 3; int flag = 0; for (int i = r * 3 + r; i < (r + 1) * 3 + r; i++) { ...
// ================================================================== // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< // ------------------------------------------------------------------ // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // --------...