text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; struct data1 { long long sum, index, position; }; bool comp(data1 a, data1 b) { return a.sum < b.sum; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); long long k; cin >> k; vector<data1> arr; long lo...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int ans = 15; for (int i = 0; i < n; i++) { if (s[i] == 0 ) ans &= 8; if (s[i] == 1 || s[i] == 2 || s[i] == 3 ) ans &= 7; if (s[i] == 1 || s[i] == 4 || s[i] == 7 ) ans &= 13; ...
/* * 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> const int maxn = 5205; using namespace std; int n, a[maxn][maxn], m; int cnt, sum[maxn][maxn], x[maxn]; bool check(int x) { int now; for (int i = x; i <= n; i += x) { for (int j = x; j <= n; j += x) { now = sum[i][j] - sum[i - x][j] - sum[i][j - x] + sum[i - x][j...
#include <bits/stdc++.h> int main() { double y1, y2, yw, xb, yb, r, A, B, C; scanf( %lf%lf%lf%lf%lf%lf , &y1, &y2, &yw, &xb, &yb, &r); yw -= r; y1 += r; yb = 2 * yw - yb; A = y1 - yb; B = xb; C = -B * y1 + B * y2; if ((C / sqrt(A * A + B * B)) <= r) { printf( -1 ); retu...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 51, MOD = 1e9 + 7; struct Matrix { int num[6][6]; Matrix() { memset(num, 0, sizeof(num)); } inline int* operator[](const int& x) { return num[x]; } inline const int* operator[](const int& x) const { return num[x]; } }; Matrix...
/* * 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...
module main_pll # (parameter SPEED_MHZ = 25) (inclk0, c0); input inclk0; output c0; wire [4:0] sub_wire0; wire [0:0] sub_wire4 = 1'h0; wire [0:0] sub_wire1 = sub_wire0[0:0]; wire c0 = sub_wire1; wire sub_wire2 = inclk0; wire [1:0] sub_wire3 = {sub_wire4, sub_wire2}; altpll altpll_component ( .incl...
#include <bits/stdc++.h> int dp[51 * 10001]; int main(void) { int n, d, a, sum, i, j; while (scanf( %d%d , &n, &d) != EOF) { sum = 0; memset(dp, 0, sizeof(dp)); dp[0] = 1; for (i = 0; i < n; i++) { scanf( %d , &a); sum += a; for (j = sum; j >= a; j--) { ...
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; int a[n], sum = n - 1; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } cout << sum / n << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long t, a, b, cnt, p; long long ak[101], tot; int main() { cin >> t >> a >> b; if (t == a && a == b) { if (t == 1) cout << inf ; else cout << 2 ; } else if (a == b) cout << 1 ; else { if (a == 1) { ...
/* * Copyright (c) 1998-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> using namespace std; int n, m, ans; int l[255 * 2], r[255 * 2], str[255 * 2], po[27]; char s[255][255]; int solve(int bas, int son) { int tot = 0; l[bas - 1] = bas; r[bas - 1] = bas - 1; for (int i = bas; i <= son; i++) { if (r[i - 1] < i) { l[i] = r[i] =...
#include <bits/stdc++.h> using namespace std; using ll = long long; namespace io { const int SIZE = (1 << 21) + 1; char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1; inline char getc() { return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS ...
#include <bits/stdc++.h> using namespace std; long long n, k, M, D, N, sol, x, mid, f, l, T; long long up(long long a, long long b) { long long tmp = a / b; if (a % b != 0) tmp = tmp + 1ll; return tmp; } long long rep(long long a) { long long tmp = n / a; tmp = up(tmp, k); return tmp; ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int dp[502][502][2], n, m; char str[502][502]; int dis; int check(int x, int y) { if (x < 0 or x >= n and y < 0 or y >= m) return 0; else return 1; } int call(int x, int y, int a, int idx) { int ham = x ...
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; using LL = long long; using PII = pair<int, int>; using PLL = pair<LL, LL>; using VI = vector<int>; using VVI = vector<VI>; const int INF = 1e9; const int MXN = 55; const int MXM = 2e4 + 5; int n, m, k; VVI init(MXN, VI(MXM, 0...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/** * 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 piles[105]; int main() { int n; cin >> n; vector<int> A(n); for (int i = 0; i < n; ++i) cin >> A[i]; sort(A.begin(), A.end()); for (int i = 0; i < n; ++i) { bool flag = false; for (int j = 0; j <= A[i]; ++j) if (piles[j]...
//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 documentatio...
#include <bits/stdc++.h> using namespace std; const int maxn = 2000005; const int inf = 0x3f3f3f3f; long long a[maxn]; int q[maxn]; int main() { int n; cin >> n; long long p = 0; long long pans = 0; for (int i = (1); i < (n + 1); i++) { cin >> a[i]; pans += abs(a[i] - i); ...
#include<bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int,int>; #define ff first #define se second #define pb push_back #define all(x) (x).begin(),(x).end() const int mod = 1e9+7; const int inf = 1e9; const int mx = 1e6+5; #define exitYes {cout<< Yes n ; retu...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chkmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } inline long long Max(long long x, long long y) { return x > y ? x : y; } inline long...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2015.1 // Copyright (C) 2015 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1ns/1ps modul...
#include <bits/stdc++.h> using namespace std; const int N = 1505; int n, k; map<tuple<int, int, int>, bool> memo; bool query(int a, int b, int c) { if (b == a || b == c) return 1; if (a > c) swap(a, c); auto s = make_tuple(a, b, c); if (memo.count(s)) return memo[s]; cout << ? << a + 1 ...
#include <bits/stdc++.h> using namespace std; const int MAX = 100 * 1000 + 5; const int INF = 1000 * 1000 * 1000 + 7; const long long LINF = 1LL * INF * INF; const int MOD = INF; const double PI = acos(-1.); int main() { ios_base::sync_with_stdio(0); int n, p; cin >> n >> p; int ans = INF;...
`timescale 1ns/1ps //Reads from accumulate buffer and writes directly to indexed location in DRAM module dram_read #( parameter DDR_BASE=31'h00000000, parameter ADDRESS_WIDTH=31, parameter TOTAL_DATA=8 ) ( clk, reset, //External writes to dram dram_fifo_readdata, dram_fifo_read, dram_fifo_empty, //Write...
`include "defines.v" `include "HRbridge16.v" `timescale 1ns/1ps /*module connectRouter_nobuffer #(parameter addr = 4'b0000) //No. 0 connect router, port 0 ( input `control_w port_l0_i, output `control_w port_l0_o, input `control_w FIFO_l0_i, output `control_w FIFO_l0_o, input bful...
#include <bits/stdc++.h> using namespace std; const int N = 100100; int main() { string s, ans; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == . ) ans += 0 ; if (s[i] == - ) { i++; if (s[i] == . ) ans += 1 ; else ans += 2 ; ...
#include <bits/stdc++.h> using namespace std; const int N = 4e4 + 5; int pr[N], ps = 0; bool np[N]; bool check(int n) { if (n == 1 || n == 0) return false; for (int i = 0; pr[i] * pr[i] <= n; ++i) if (n % pr[i] == 0) return false; return true; } int main() { for (int i = 2; i < N; ++...
//sf_camera_controller.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 th...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 10; const long long MN = 5e2 + 10; long long n, m, a[MN], b[MN]; vector<pair<long long, char> > ans; long long lz = 0; bool fl = false; void fail() { cout << NO n ; exit(0); } long long get(long long l, long long r) {...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, a[maxn], b[maxn], v[maxn]; unordered_map<int, int> mp; void dfs(int x, int l, int r) { if (v[x] <= r && v[x] >= l) mp[v[x]] = 1; if (a[x] != -1) { if (l < v[x]) dfs(a[x], l, min(v[x] - 1, r)); } if (b[x] != -1)...
//device_rom_table.v /* Distributed under the MIT licesnse. 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 ...
/************************************************************************** UART Transmitter Module -Clock Rate x4 -parameter BAUDRATE_COUNTER Uart Baudrate Parameter (Clock / Baudrate)/4-1 BAUDRATE_COUNTER is must be greater than 4. (BAUDRATE_COUNTER >= 20'h4) Example : Clock : 50MHz 9600bps : 13'd1301 11...
// -- (c) Copyright 2010 - 2011 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...
#include <bits/stdc++.h> using namespace std; const int maxn = 300000 + 100; int p[maxn << 2]; void pushdown(int L, int R, int u) { if (L != R) { if (p[u] != -1) { p[u << 1] = p[u]; p[u << 1 | 1] = p[u]; p[u] = -1; } } } void update(int cL, int cR, int val, int L,...
#include <bits/stdc++.h> using namespace std; const int maxn = 20 + 5; const long long INF = 3e9; const char *cc = 0123456789abcdef ; int c[maxn][maxn], used[maxn]; long long dp[maxn][maxn]; char s[maxn]; long long solve(int t, int m, bool flag) { memset(dp[0], 0, sizeof(dp[0])); if (flag) { ...
#include <bits/stdc++.h> using namespace std; bool vis[30010][210][2][2][2]; int pd[30010][210][2][2][2]; int v[30010]; int n, K; int solve(int ind, int cut, int s1, int s2, int tem) { if (cut == K) return 0LL; if (ind == n) return -0x3f3f3f3f; int &ans = pd[ind][cut][s1][s2][tem]; if (vis[i...
#include <bits/stdc++.h> using namespace std; int main() { int A[2], B[2], C[2]; scanf( %d %d %d %d %d %d , &A[0], &A[1], &B[0], &B[1], &C[0], &C[1]); int r1 = A[0]; int r2 = B[0]; int r3 = C[0]; int c1 = A[1]; int c2 = B[1]; int c3 = C[1]; bool check = false; int row1, row2,...
#include <bits/stdc++.h> using namespace std; int n, k; int v[100000 + 1]; int mx, rez; pair<int, int> rz[100000 + 1]; int stkLen; int stkLen2; int stk[100000 + 1]; int stk2[100000 + 1]; int s, s2; void readFile() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(); cin >> n >> k...
//`include "elink_regmap.v" module dut(/*AUTOARG*/ // Outputs dut_active, clkout, wait_out, access_out, packet_out, // Inputs clk1, clk2, nreset, vdd, vss, access_in, packet_in, wait_in ); //########################################################################## //# INTERFACE //############...
#include <bits/stdc++.h> using namespace std; int n, a[200010]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); int p = 2e9 + 7, ans = 0; for (int i = 1; i < n; i++) p = min(p, a[i + 1] - a[i]); for (int i = 1; i < n; i++) ans += (a[i ...
module CoProcessor0RF(clk, din, wEn, regNum, sel, dout, npc_out, expiaddr, ins, cop_addr, cop_data); input clk; input [1:0] wEn; input [4:0] regNum; input [2:0] sel; input [31:0] din; input [31:0] ins; input [31:0] npc_out; output [31:0] dout; output reg [31:0] expiaddr; input [4:0] cop_addr;...
/** \file "inverters-syntax-err.v" Chain a bunch of inverters between VPI/VCS and prsim, shoelacing. $Id: inverters.v,v 1.3 2010/04/06 00:08:35 fang Exp $ Thanks to Ilya Ganusov for contributing this test. */ `timescale 1ns/1ps `include "clkgen.v" module timeunit; initial $timeformat(-9,1," ns",9); endmodule ...
/** * 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)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...
#include <bits/stdc++.h> using namespace std; int N, A, ni, ai; string si; vector<int> hero; vector<string> moves; vector<int> player; bool used[22][(int)(1 << 20)]; int dp[22][(int)(1 << 20)]; int BAD = 99999999; int memo(int a, int b) { if (used[a][b]) return dp[a][b]; if (a == A) return 0...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) { return os << ( << p.first << , << p.second << ) ; } template <typename T> inline std::ostream& operator<<(std::ostream& os, const std::v...
#include <bits/stdc++.h> const double eps = 1e-7, PI = 3.1415926; const int N = 2e5 + 10; using namespace std; long long n, q, m, k, x, y, a[N], mx = -1, mem[N][3], vis[N][3], mn = 1e9, sum, t; char c[N]; string s, s1, s2; map<int, int> mp; vector<int> vec; long lon...
#include <bits/stdc++.h> using namespace std; int digit(char c) { char digits[] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }; for (int i = 0; i < 10; i++) { if (c == digits[i]) return 0; } return 1; } int main() { int t = 0; scanf( %d , &t); while (t--) { string s...
/* * 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 n = 0; long long k = 0; long long wynik = 0; long long wynik2 = 0; long long wynik3 = 0; cin >> n >> k; if (k == 1) { cout << 1 ; return 0; } if (k == 2) { wynik = n * (n - 1) / 2 + 1; c...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2015 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc = 0; reg [63:0] crc; ...
/* * Copyright (c) 2003 The ASIC Group (www.asicgroup.com) * * 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 y...
#include <bits/stdc++.h> using namespace std; int n, m, k; long long num[200005], rig[200005], lef[200005]; int main() { scanf( %d%d%d , &n, &m, &k); long long tmp = 0; for (int i = 1; i <= n; ++i) { scanf( %d , &num[i]); } int t = 1; while (m--) t *= k; for (int i = 1; i <= n;...
/** * 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...
/** * 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 <class T> inline void dmin(T& x, T y) { y < x ? x = y : 0; } template <class T> inline void dmax(T& x, T y) { y > x ? x = y : 0; } template <class T> inline void dmin(T& x, vector<T> y) { for (auto t : y) t < x ? x = t : 0; } templ...
#include <bits/stdc++.h> using namespace std; int a[1005], b[1005], c[1005], d[1005], posa[1005], posb[1005]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int q = 1; q <= n; q++) { int x; cin >> x; a[x] = q; } for (int q = 1; q <= n; q++) { ...
//Legal Notice: (C)2006 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...
#include <bits/stdc++.h> using namespace std; int main() { int t, i, j, n, x, y; cin >> x >> y; bool c = 0; char a; for (i = 0; i < x; i++) { for (j = 0; j < y; j++) { cin >> a; if (a != W && a != B && a != G ) c = 1; } } if (c) puts( #Color ); ...
//Legal Notice: (C)2017 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; int main() { int n; int sum = 0; cin >> n; int **p; p = new int *[n]; for (int i = 0; i < n; i++) { p[i] = new int[n]; for (int j = 0; j < n; j++) { cin >> p[i][j]; } } for (int i = 0; i < n; i++) { for (in...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int sum = 0; sort(a, a + n); for (int i = 0; i < n; i++) { sum = sum + (a[n - 1] - a[i]); } cout << sum; }
#include <bits/stdc++.h> using namespace std; bool Primality(long long n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; for (long long i = 3; i * i <= n; i = i + 2) if (n % i == 0) return false; return true; } int main() { long long n; cin >>...
#include <bits/stdc++.h> using namespace std; const int maxn = 105; int n, m, a[maxn][maxn]; int sumr[maxn], sumc[maxn]; bool ar[maxn], ac[maxn]; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; for (int i...
// megafunction wizard: %RAM: 2-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: dpram_256x32.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ===============...
#include <bits/stdc++.h> using namespace std; const int N = 100005; const int K = 65; const int inf = 1000 * 1000 * 1000; const int mod = 1000 * 1000 * 1000 + 7; int n, a[N], q; int t[4 * N][K]; void build(int v, int s, int e) { if (s == e) { for (int i = 0; i < 60; i++) { if (i % a[s]...
#include <bits/stdc++.h> using namespace std; struct str { long long num; long long id; } st[666666]; long long arr[666666]; bool cmp(str a, str b) { return a.num < b.num; } signed main() { long long n; cin >> n; for (long long i = 1; i <= n; i++) { cin >> arr[i]; } long lo...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; unordered_map<char, int> v; int cnt = 0; int j = 0; for (int i1 = 1; i1 <= n; ++i1) { char ch; string second; cin >> ch >> second; if (...
#include <bits/stdc++.h> using namespace std; #pragma GCC diagnostic ignored -Wmissing-declarations inline int safe_mul(const int x, const int y) __attribute__((warn_unused_result)); int const mod = 998244353; inline int safe_mul(const int x, const int y) { return x * static_cast<long long>(y) % m...
`timescale 1ns / 1ps module control( input [5:0] opcode, input branch_eq, // result of comparison for conditional branch output reg [1:0] if_pc_source, output id_rt_is_source, // rt is source output ex_imm_comma...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\velocityControlHdl\velocityControlHdl_Double_Range.v // Created: 2014-08-25 21:11:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ------------------------------------------------------...
#include <bits/stdc++.h> using namespace std; struct Node { vector<Node*> edges; bool term; vector<int> last; Node() { edges.resize(5); fill(edges.begin(), edges.end(), nullptr); term = false; } }; void add_string(Node* root, string s) { for (char c : s) { c -= 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...
// file: TemperatureMonitor_tb.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 // laws. // // DISCLAIMER // This disclaimer i...
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; struct Cup { uint cap; uint ix; uint cur; }; int main() { uint n; uint total; cin >> n >> total; vector<Cup> cups(n); for (uint i = 0, wi; i < n; ++i) { cin >> wi; cups[i] = {wi, i, 0}; } ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, r; cin >> n >> r; long long int sum = 0; if (n == 1) { sum = 1; } else if (n <= r) { sum = ((n - 1) * (n)) / 2 + 1; } else { sum = (r * (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 la...
#include <bits/stdc++.h> using namespace std; const int N = 5001; long long a[N], mem[N][2], b[N]; int n, m; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b, b + n); m = unique(b, b + n) - b; for (int i = n - 1; i >= 0; i--) mem...
#include <bits/stdc++.h> const int INF = 1000000009; using namespace std; int main() { int n, i, l = 0, r = 0; string s; cin >> n >> s; s = . + s; for (i = 1; i < s.size(); i++) if (s[i] == L ) l = 1; else if (s[i] == R ) r = 1; if (r && l) cout << s.f...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> c(n); for (int i = 0; i < n; ++i) { scanf( %d , &c[i]); } vector<int> ans(n + 1, 0); for (int i = 0; i < n; ++i) { vector<int> mx(n + 1, 0); int p = 0; for (int k = i; k < n; +...
#include <bits/stdc++.h> long long vx[200010], vy[200010]; std::map<long long, long long> mp, gg; int main() { int n; long long a, b; scanf( %d%lld%lld , &n, &a, &b); long long ans = 0; for (int k = 1; k <= n; k++) { long long t; scanf( %lld%lld%lld , &t, &vx[k], &vy[k]); lon...
module module1(clk_, rst_, bar0, bar1, foo0, foo1); input clk_; input rst_; input [1:0] bar0; input [1:0] bar1; output [1:0] foo0; output [1:0] foo1; parameter poser_tied = 1'b1; parameter poser_width_in = 0+1-0+1+1-0+1; parameter poser_width_out = 0+1-0+1+1-0+1; parameter poser_grid_width = 2; pa...
module multiplexer(q, data, select); output q; input [31:0] data; input [5:0] select; wire q; wire [31:0] data; wire [5:0] select; assign q = (select == 5'h00) ? data[0] : (select == 5'h01) ? data[1] : (select == 5'h02) ? data[2] : (select == 5'h03) ? data[3] : (select == 5'h04) ? data[4] : (select ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long dp[200100][2]; long long ans[200100]; int main(int argc, char const *argv[]) { int T, k; cin >> T >> k; dp[k][1] = 1; dp[1][0] = 1; for (int i = 2; i <= 100000; i++) { if (i - k <= 0) { ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64000000 ) using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); int main() { int n, s; cin >> n >> s; int res = -1; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; if (y == 0) { if ...
#include <bits/stdc++.h> using namespace std; using namespace std; typedef long long int ll; typedef unsigned long long int ull; inline void smax(int &x, int y) { x = max(x, y); } inline void smin(int &x, int y) { x = min(x, y); } ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a % b)); } const doubl...
#include <bits/stdc++.h> using namespace std; vector<int> adj[100005]; struct Tree { vector<vector<int> > anc; vector<vector<int> > cost; vector<int> T, X; vector<int> depth; vector<bool> vis; int n; int root; Tree(int N = 1e5, int r = 1) { n = N + 5; root = r; an...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n, i, j, tmp, tmp2; cin >> n >> tmp; for (i = 1; i < n; i++) { cin >> tmp2; if (tmp == tmp2) { for (i = i + 1; i < ...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, All Rights Reserved // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software...
`timescale 1ns/1ns module menc_sincos (input c, input [13:0] menc, input [10:0] offset, input [7:0] poles, output [31:0] sin, output [31:0] cos); wire toggle; r toggle_r(.c(c), .en(1'b1), .rst(1'b0), .d(~toggle), .q(toggle)); wire [10:0] sin_addr, cos_addr; d1 #(11) sin_addr_r(.c(c), .d(menc + offset), .q(sin_ad...
/* * 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 inv_euclid(long long a, long long m = 998244353) { long long m0 = m; long long y = 0, x = 1; if (m == 1) return 0; while (a > 1) { long long q = a / m; long long t = m; m = a % m, a = t; t = y; y = x - q * y; ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e3 + 100, inf = 1e15; long long dis[N][N][6], clr[6][6], ans = inf; queue<pair<int, int> > q[3]; char a[N][N]; bool mark[N][N][6]; pair<int, int> k; int ki, kj, n, m, x, y; int xx[] = {0, 1, 0, -1}, yy[] = {1, 0, -1, 0}; bool is_vall...
/** * 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, m; int table[1000][1000]; int main() { int k = 0; scanf( %d %d %d , &n, &m, &k); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { scanf( %d , &table[i][j]); } } while (k) { char command; int x, y;...