text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 4; void solve() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; float min = 4.5 * n; int mn = (int)min; if (min - mn > 0) mn++; int sum = 0; for (int i = 0; i < n; i++) sum += arr[i]; ...
#include <bits/stdc++.h> using namespace std; const int RNG = 1000003; const int RNGT = RNG * 4; const int MOD1 = 1e9 + 7; const int MOD2 = 1e9 + 87; const double pi = 2 * acos(0.0); inline int _Int() { int x; scanf( %d , &x); return x; } inline long long _LLi() { long long x; scan...
/* Copyright (c) 2016 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; int n, a, b, h[20], f[20][20][20][20], g[20][20][20][20][5]; void update(int &f1, int f2, int p[5], int i, int j, int k, int l, int w) { if (f2 < f1) { f1 = f2; p[0] = w; p[1] = i; p[2] = j; p[3] = k; p[4] = l; } } int m...
/** * 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 2015, Google 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 http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
//Componentes varios //Banco de registros de dos salidas y una entrada module regfile(input wire clk, input wire we3, //se�al de habilitaci�n de escritura input wire [3:0] ra1, ra2, wa3, //direcciones de regs leidos y reg a escribir input ...
/** * Copyright 2014 Kevin Townsend * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agree...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); long long a[100001]; long long y = 0; long long thissum = 0, maxsum = 0; int count = 1; for (int i = 0; i < n; i++) { scanf( %lld , &...
module parser( input clk, input reset, input ip_src_valid, input [130:0] ip_src, input cdp2um_data_valid, input [138:0] cdp2um_data, output um2cdp_tx_enable, output um2cdp_path, output pkt_ctl_valid, //contorl output [138:0] pkt_ctl, input [7:0] pkt_ctl_u...
/** * 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; using ll = long long; using ld = long double; using ii = pair<int, int>; using vi = vector<int>; using vb = vector<bool>; using vvi = vector<vi>; using vii = vector<ii>; using vvii = vector<vii>; const int INF = 2000000000; const ll LLINF = 90000000000...
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long n, k; cin >> n >> k; unsigned long long r = 1, l = 0, num = n, mid; for (int i = 0; i < n; i++) { r <<= 1; } mid = (l + r) >> 1; while (mid != k) { --num; if (mid > k) r = mid; e...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Ultra(TM) in wire load mode // Version : L-2016.03-SP3 // Date : Sun Nov 20 02:51:15 2016 ///////////////////////////////////////////////////////////// module LOAGDA_St_N16_M4_P4 ( in1, in2, res ); input [15:0] in1; in...
#include <bits/stdc++.h> using namespace std; int ucln(int k, int l) { int t; while (l > 0) { t = l; l = k % l; k = t; } return (k); } int main() { int x, y, m, n, a, b; cin >> n >> m >> x >> y >> a >> b; int u = ucln(a, b); a /= u; b /= u; int na, nb; ...
#include <bits/stdc++.h> using namespace std; int n, a[1005], b[1005]; int main() { bool same = 1; scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d%d , a + i, b + i); same &= a[i] == b[i]; } if (!same) { puts( rated ); return 0; } for (int i = 2; i <= n...
module autoreset_equal_extra (); always_ff @(posedge csclk) begin if( ~srst_n | !val_tx_to_csi ) begin csi.cmd <= ncbo_cmd_t'('0); // vvvvvv fifo.data.cb_req.req.cmd = '0; should not be below /*AUTORESET*/ // Beginning of autoreset for uninitialized flops csi...
#include <bits/stdc++.h> using namespace std; int main() { long long a, c; cin >> a >> c; vector<long long> aa; while (a) { aa.push_back(a % 3); a /= 3; } vector<long long> cc; while (c) { cc.push_back(c % 3); c /= 3; } long long i = 0, j = 0; vector<l...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; const int mod = 1e9 + 7; const long long inf = 1e18; const double PI = acos(-1); const double eps = 1e-8; long long qkmod(long long base, long long cnt) { long long res = 1; while (cnt) { if (cnt & 1) res = res * base % ...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; long long a[N]; long long p[N]; long long size[N]; long long n; long long root(long long v) { if (v != p[v]) { return p[v] = root(p[v]); } return v; } void fix(long long v, long long x) { if (v == n + 1) r...
#include <bits/stdc++.h> using namespace std; int main() { int x, sum1 = 0, Min = 0, sum = 0; cin >> x; int p; vector<int> v; for (int j = 0; j < x; j++) { cin >> p; sum += p; v.push_back(p); } sort(v.begin(), v.end()); int s = v.size(); sum1 = 0; for (int 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...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 30, Mod = 1e9 + 7; const long long SQ = 330; const long long LOG = 20; long long n, q, Par[LOG][N], a[N], H[N], St[N], Fn[N], Lazy[N << 2], T, Fen[N], Seg[N << 2], root = 1; vector<long long> G[N]; void DFS(long long v = 1, long...
#include <bits/stdc++.h> using namespace std; struct block { int x, y; inline bool operator<(const block &cpr) const { if (x != cpr.x) return x < cpr.x; return y < cpr.y; } inline bool operator==(const block &cpr) const { return ((x == cpr.x) && (y == cpr.y)); } }; struct n...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pli = pair<ll, int>; const int INF = 0x3f3f3f3f, N = 3e3 + 5; const ll LINF = 1e18 + 5; int n; vector<int> G[N]; int sz[N][N], f[N][N]; ll dp[N][N], maxn; void dfs(int u, int fa, int rt) { sz[...
// *************************************************************************** // *************************************************************************** // Copyright 2014(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool uin(T& a, T b) { return a > b ? (a = b, true) : false; } template <class T> inline bool uax(T& a, T b) { return a < b ? (a = b, true) : false; } int main() { ios::sync_with_stdio(false); cin.tie(0); long lon...
/** * 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) 2016-2018 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, distri...
#include <bits/stdc++.h> using namespace std; string convertTostr(int x) { stringstream ss; ss << x; string st; st = ss.str(); return st; } unsigned long long convertToint(string y) { unsigned long long num; stringstream ss(y); ss >> num; return num; } unsigned long long ...
module globalbranchpredictor(clk,pcsrcd,pcsrcd2,pcd,pcbranchd,pcbranchd2,originalpc,pcnext,clrbp); input clk; input [1:0] pcsrcd,pcsrcd2; input [63:0] originalpc; input [31:0] pcbranchd,pcbranchd2, pcd; output reg [31:0] pcnext; output reg clrbp; reg [71:0] branchtargetb...
module mutex_buffer # ( parameter integer C_BUFF_NUM = 4 ) ( input wire clk, input wire resetn, output wire wr_done, input wire w_sof, output reg [C_BUFF_NUM-1:0] w_bmp, input wire r0_sof, output reg [C_BUFF_NUM-1:0] r0_bmp, input wire ...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. //------------------------------------------------------------------------------ // SHARED CODE //------------------------------------------------------------------------------ `ifdef OVL_SHARED_CODE...
#include <bits/stdc++.h> using namespace std; int n, m, sum = 0, a = 101; int main() { cin >> n; while (n--) { cin >> m; sum += m; if (m & 1 && m < a) a = m; } if (sum & 1) cout << sum << endl; else { if (a == 101) cout << 0 << endl; else cou...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, i = 0, j = 0; cin >> a >> b >> c >> d; while (a != 0) { a = a - 1; i++; } while (b != 0) { b = b - 1; j++; } if (j >= i) cout << Second ; else cout << First ; }
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const int mod = 1000000007; const int inf = 2012345678; const long long infl = 9012345678901234567; const double pi = 3.1415926535897932384626433832795; struct rat { long long a, b; rat(long long _a = 0, long long _b = 1...
#include <bits/stdc++.h> using namespace std; int n, ans[110]; int main() { scanf( %d , &n); for (int i = n; i > 0; i--) { printf( ? ); for (int j = 1; j < n; j++) printf( 1 ); printf( %d n , i); fflush(stdout); int k; scanf( %d , &k); if (k) { ans[n] = ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 10; const long long INF = numeric_limits<long long>::max(); enum { EVEN, ODD }; int A[MAXN]; long long dp[2][MAXN]; int main() { int N; cin >> N; for (int i = 1; i <= N; ++i) cin >> A[i]; dp[ODD][1] = dp[EVEN][1] = dp[...
////////////////////////////////////////////////////////////////////// //// //// //// Copyright (C) 2014 //// //// //// //// This source file may be used and distributed witho...
#include <bits/stdc++.h> using namespace std; using ll = long long int; string s, t; int mp[28], tempMap[28]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i, j, len1, len2, can = -1; cin >> s >> t; len1 = (int)s.size(), len2 = (int)t.size(); for (i = 0; i < len1; i...
/* * The MIT License (MIT) * * Copyright (c) 2015 Stefan Wendler * * 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 us...
module crc_ccitt #(parameter INIT = 16'hffff) (input clk, input rst, input [7:0] d, input dv, output [15:0] crc); wire [15:0] next_crc; wire [15:0] crc_d = (rst ? INIT : next_crc); r #(16) crc_r(.c(clk), .rst(1'b0), .en(dv | rst), .d(crc_d), .q(crc)); assign next_crc[0] = crc[8] ^ crc[12] ^ d[0] ^ d[4]; assign next...
// $Id: c_xor_nto1.v 1534 2009-09-16 16:10:23Z dub $ /* Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of sou...
#include <bits/stdc++.h> using namespace std; long long far(long long x, long long y) { return x * x + y * y; } vector<long long> val; vector<long long> dsu; vector<long long> rang; long long pred(long long a) { if (a == dsu[a]) { return a; } else { long long to = pred(dsu[a]); if ...
// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
/** * 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 now[5 * 100010], after[5 * 100010], mx[5 * 100010]; int lft[5 * 100010], rgt[5 * 100010], vi[5 * 100010], timer = 0, comp = 0; long long Add[5 * 100010]; vector<int> g[5 * 100010]; stack<int> stk; inline void dfs(int c, int p) { vi[c] = 1; now[c] =...
#include <bits/stdc++.h> using namespace std; string s; int n; int oddb, evenb, oddr, evenr; int main() { cin >> n; cin >> s; int ans = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) { if (s[i] == b ) evenb++; else if (s[i] == r ) evenr++; } ...
#include <bits/stdc++.h> using namespace std; struct ww { long double x, y; } a[100010]; int i, j, k, n, m, xx, yy; long double LU[100010], RU[100010], LD[100010], RD[100010]; inline bool judge(long double len) { int i, j; j = 0; for (i = 1; i <= n; i++) { for (; a[j + 1].x + len < a[i...
#include <bits/stdc++.h> using namespace std; long long c[2000], d[2000]; long long u[2000], b[2000]; int main() { long long n, m, d; long long lpl = 0; cin >> n >> m >> d; for (int i = 0; i < m; i++) { cin >> c[i]; lpl += c[i]; } if (lpl == n) { cout << YES << endl; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 1) { cout << 0; return 0; } n = n / 2; if (n % 2 == 0) cout << n / 2 - 1; else cout << n / 2; 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; int main() { int tc, i, j, k, cs = 1, m, n, ans; { scanf( %d%d , &m, &n); if (n > m) swap(m, n); if (n == 1) ans = m; else if (n == 2) { ans = (m / 4) * 4; if (m % 4 == 1) ans += 2; else if (m % 4...
/** * 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> T BigMod(T b, T p, T m) { if (p == 0) return 1; if (p % 2 == 0) { T s = BigMod(b, p / 2, m); return ((s % m) * (s % m)) % m; } return ((b % m) * (BigMod(b, p - 1, m) % m)) % m; } template <typename T> T ModInv(T ...
`timescale 1 ns / 1 ns `define LATENCY_TIMEOUT 24'h1 `include "project_include.v" module fx3_bus_out_path #( parameter ADDRESS_WIDTH = 8 //256 32-bit values to align with //largest packet size )( input clk, input rst, //Control output r...
`include "../network_params.h" // A module to shift in pixels from the video stream and output a ready signal module window_ctrl ( input clock, input reset, // x/y coordinates of the buffer, will be constants to start but may // eventually change to look at different parts of the image input [`SCREEN_X_BITW...
#include <bits/stdc++.h> using namespace std; int n, m, x, len, dir, t, y; bool fin; pair<int, int> a[210000]; int loc[210000]; int binary_right(int x, int t) { int l = x, r = n, mid; while (l < r) { mid = (l + r + 1) / 2; if (a[mid].first <= t) l = mid; else r = mi...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int alpha[26], kitta = 0; for (int i = 0; i < 26; i++) alpha[i] = 0; for (int i = 0; i < s.length(); i++) { alpha[s[i] - a ]++; if (alpha[s[i] - a ] == 1) kitta++; } if (kitta > 4 || kitta < 2) {...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: eight_new2.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =========================...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d, e, f; cin >> a >> b; c = a / 2; if (b < c || (a == 1 && b != 0)) cout << -1; else if (a == 1 && b == 0) cout << 1; else if (b % c == 0) { e = b / c; if (b / c != 1) { for (int i =...
module fifo_top #( parameter DEPTH = 32, WIDTH = 32, ADDR = 5 ) ( input wire write, wreset_b, wclk, read, rreset_b, rclk, input wire [WIDTH-1:0] wdata, output wire [WIDTH-1:0] rdata, output wire rempty, wfull ); // function to convert from gray to binary function [ADDR:0] G2B_Fn; input [ADDR:0] gray; r...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 7; long long n, m, a[maxn], b[maxn]; vector<long long> vt[100]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (long long i = 1; i <= n; i++) { cin >> b[i]; long long gau = b[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...
#include <bits/stdc++.h> using namespace std; int n, dp, q, c, b; string ans = ; void update(int &x) { if (x == 0) x = 1; else x = 0; } int main() { scanf( %d , &n); int a[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) scanf( %d , &a[i][j]); } ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int s = 0; s = n * (n); s = s + (n - 1) * (n - 1); cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; bool odd(ll num) { return ((num & 1) == 1); } bool even(ll num) { return ((num & 1) == 0); } ll sum(ll n) { return ((n * (n + 1)) / 2); } ll ceil(ll a, ll b) { return ((a + (b - 1)) / b); } void I...
#include <bits/stdc++.h> using namespace std; int from[101], to[101], p; int main() { int n, m, x, y; cin >> n >> m; memset(to, -1, sizeof to); for (int i = 1; i <= n; i++) { cin >> x >> y; for (int j = x; j <= y; j++) to[j] = max(to[j], y); } int now = 0; for (; now <= m;)...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3fffffff; const long long _INF = 0x7ffffffffffffffll; const double EPS = 1e-9; const double PI = acos(-1.0); template <class T, class INT> inline T pow(T x, INT y) { T res(1); for (T tt(x); y; y /= 2) { if (y & 1) res *= tt; ...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, t; int n; int a[100005]; int b[100005]; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(a, a + n); int cnt = 0; for (i = 0; i < n; i++) { if (a[i] != b[i]) cnt++; }...
#include <bits/stdc++.h> using namespace std; int parent[300005], maxLen[300005]; int findRoot(int u) { int root = u; while (parent[root] != root) { root = parent[root]; } while (parent[u] != root) { int y = parent[u]; parent[u] = root; u = y; } return root; } v...
//`define ENABLE_ADC //`define ENABLE_AUD //`define ENABLE_CLOCK2 //`define ENABLE_CLOCK3 //`define ENABLE_CLOCK4 `define ENABLE_CLOCK //`define ENABLE_DRAM //`define ENABLE_FAN `define ENABLE_FPGA `define ENABLE_GPIO `define ENABLE_HEX //`define ENABLE_HPS //`define ENABLE_IRDA `define ENABLE_KEY `define ENABLE_LEDR ...
#include <bits/stdc++.h> using namespace std; deque<int> A, B; long long p, i, j, k, n, m, aux; long long fact(int a) { long long f = 1; int i; for (int i = (int)(1); i <= (int)(a); ++i) f *= i; return f; } int main(void) { cin >> p; cin >> n; for (int i = (int)(1); i <= (int)(n)...
module execute(clk, signe,signe2, rse,rse2, rte,rte2, rde,rde2,signimme,signimme2,mux1after,mux1after2,mux2after,mux2after2,resultw,resultw2,aluoutm,aluoutm2, alucontrole,alucontrole2,alusrce,alusrce2,multsele,multsele2,regdste,regdste2,forwardae,forwardae2,forwardbe,forwardbe2,writerege,writerege2, sol...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL << i...
#include <bits/stdc++.h> using namespace std; vector<long long int> v1, v2; vector<char> v4; string s1, s2, s3; long long int visited[2000005]; set<char> st; set<long long int>::iterator it; int main() { long long int a, b, c, d, e, f, i, j, k, cnt1 = 0, cnt2 = 0, sum1 = 0, sum2 = 0, first, ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k, x = 0; cin >> n >> m >> k; if (n + m - 2 < k) { cout << -1; return 0; } if (m > n) swap(m, n); if (k < m) x = n * (m / (k + 1)); if (k < n) x = max(x, m * (n / (k + 1))); if (k >= n) x = m / (k ...
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf( %d , &q); while (q--) { int l, r, d; scanf( %d %d %d , &l, &r, &d); if (d < l) printf( %d n , d); else if (d > r) printf( %d n , d); else { int res = r - d; res = res % ...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-8; const int N = 1e5 + 10; int n, q; int sgn(long double x) { return x < -EPS ? -1 : x > EPS; } struct Point { Point() {} long double x, y; Point(long double x, long double y) : x(x), y(y) {} void read() { cin >> x >> y...
// Simple Register file model by Ali Jahanian // Students should not used reg_bank as a descrete moule. It is recommended to use the internal part of the code inside mips_core module. // In this model, only writing to register bank is synchronized with clock and reading is not synchonized with clock. // For any proble...
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)5e3 + 10; const int MOD = (int)1e9 + 7; long long dp[1111][1111]; int num[1111], k; int mark[1111]; long long dfs(int pos, int x, int flag) { if (pos == 0) return mark[x] == k - 1 && (x != 0); if (dp[pos][x] != -1 && !flag) { ...
#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; } template <typename T> inline void gn(T &first) { char c, sg = 0; while (...
//date:2016/3/14 //engineer :ZhaiShaoMin // module function :unite all four ring_node together module whole_system(//input clk, rst ); input clk; input rst; wire en_local_req_1; // to previous...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize -O3 bool prime(long long int n) { if (n == 1) return false; if (n == 2 || n == 3) return true; long long int k = sqrt(n) + 1; for (long long int i = 2; i < k; i++) { if (n % i == 0) return false; } return true; } ...
// // GPIO controller for picorv32 // // Little endian. // Increasing numeric significance with increasing memory addresses known as "little-endian". // `include "inc/timescale.vh" module gpio ( // Bus interface input wire clk, input wire resetn, input wire enable, input wire mem_vali...
////////////////////////////////////////////////////////////////// // // // Multiplication Module for Amber 2 Core // // // // This file is part of the Amber project ...
#include <bits/stdc++.h> using namespace std; const int maxn = 101000; int fa[maxn], sz[maxn], c[maxn]; int fd(int f) { return fa[f] == f ? f : fa[f] = fd(fa[f]); } int n, m, f[maxn]; bool isok(int x) { while (x) { int d = x % 10; if (d != 4 && d != 7) return false; x /= 10; } ...
module pass_through( clk, reset, in_pkt_wrreq, in_pkt, in_pkt_usedw, in_valid_wrreq, in_valid, out_pkt_wrreq, out_pkt, out_pkt_usedw, out_valid_wrreq, out_valid ); input clk; input reset; input in_pkt_wrreq; input [138:0]in_pkt; out...
#include <bits/stdc++.h> using namespace std; int n = 10; const int ms = 100; int grid[ms][ms]; const int inf = 1e9; int f[ms]; double dp[ms]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(8); for (int i = 0; i < n; i++) { for (int ...
#include <bits/stdc++.h> using namespace std; using namespace std; long long int fast_expo(long long int base, long long int to) { long long int res = 1; while (to) { if (to & 1) { res *= base; } base *= base; to /= 2; } return res; } long long int to_bin[50]; ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // Modified for HPDMC simulation, based on Xilinx 05/23/07 revision /////////////////////////////...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, aa[8] = {-1, 0, 1, -1, 2, -1, -1, -1}, bb[8] = {-1, -1, -1, 2, -1, 1, 0, -1}; int T, n, i, j; long long l, r, m, a[N], b[N], c[N], x, y, z, mn[8], u[4], d[4]; inline bool ckk(long long p, long long q, long long r) { for (x = ...
#include <bits/stdc++.h> using namespace std; const long long int lg = 22; const long long int N = 2e5 + 5; const long long int INF = 1e18; const long long int mod = 1e9 + 7; const double PI = 3.14159265358979323846; template <typename T> T power(T x, T y, long long int m) { T ans = 1; while (y ...
// $Id: c_wf_alloc.v 1534 2009-09-16 16:10:23Z dub $ /* Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of sou...
#include <bits/stdc++.h> using namespace std; int main() { int n; int m; cin >> n >> m; int c[m], a[n]; int i, j, k; for (i = 0; i < n; i++) { a[i] = 0; } for (i = 0; i < m; i++) { cin >> c[i]; a[c[i] - 1]++; } k = a[0]; for (i = 0; i < n; i++) { i...
#include <bits/stdc++.h> using namespace std; const int BUFFER_SIZE = 1 << 20; char rb[BUFFER_SIZE], *rp = rb, *rt = rb; inline char read_char() { return rp == rt ? (rt = rb + fread(rb, 1, BUFFER_SIZE, stdin), rp = rb, *rp++) : *rp++; } inline int read_int() { int x = 0; char...
#include <bits/stdc++.h> using namespace std; long long sum(long long n) { return (n * (n - 1)) / 2; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int arr[n + 1]; for (int i = 0; i < n; i++) cin >> arr[i]; pair<int, int> b[n + 1]; for (int i = 0; ...
#include <bits/stdc++.h> using namespace std; const int maxn = (int)3 * 1e5 + 21; const double eps = (double)1e-8; const int mod = (int)1000000007; int a[maxn], b[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x; memset((a), 0, sizeof(a)); ; mem...
#include <bits/stdc++.h> using namespace std; const long long N = 101000; struct p { long long x, y; } a[N]; long long n, m; long long pro(p o, p b, p c) { return (b.x - o.x) * (c.y - o.y) - (c.x - o.x) * (b.y - o.y); } int main() { scanf( %I64d , &n); for (long long i = 1; i <= n; 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...