text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; long long gcd(long long u, long long v) { while (v != 0) { long long r = u % v; u = v; v = r; } return u; } typedef struct State { char cnt[21]; char top[3]; } State; inline bool operator<(const State &a, const State &b) { ...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int inf = 1e9 + 9; const long long int MOD = 1e9 + 696969; const long long INF = 4LL * 1000000LL * 1000000LL * 1000000LL; template <class T> int size(T &&x) { return int(x.size()); } template <class A, class B> ostrea...
#include <bits/stdc++.h> using namespace std; struct res { double l, r, w; } T[800000]; double x[210000], s[210000], p, c, ans, w; int N, M, i, l, r; int init(int i, int l, int r, int x, double w) { if (x < l || r < x) return 0; if (l == r) { T[i].w = T[i].l = T[i].r = w; return 0; ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long int md[500]; signed main() { ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long int n; cin >> n; for (long long int i = 0; i < 500; i++) md[i] = -1; for (long long int i = 0; i <= 8; i++) { for (...
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T1, class T2> inline void gmax(T1 &a, T2 b) { if (b > a) a = b; } template <class T1, class T2> inline void gmin(T1 &a, T2 b) ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5, M = 2e3 + 5; const long long INF = 1e18 + 5; inline long long read() { long long sum = 0, fh = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) fh = -1; c = getchar(); } while (c >= 0 && c <= ...
/////////////////////////////////////////////////////////////////////////////// // Project: Aurora 64B/66B // Company: Xilinx // // // // (c) Copyright 2008 - 2009 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S....
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (lin64) Build Wed Oct 4 19:58:07 MDT 2017 // Date : Tue Oct 17 19:49:25 2017 // Host : TacitMonolith running 64-bit Ubuntu 16.04.3...
/* * 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 int MAXN = 1000010; unordered_map<int, vector<pair<int, int> > > rows; unordered_map<int, vector<pair<int, int> > > cols; int n, m; int cnum; map<pair<int, int>, int> id; map<pair<int, int>, vector<pair<int, int> > > adj1; unordered_map<int, vector<i...
#include <bits/stdc++.h> using namespace std; int n, k, q, a[int(2e5)], sz; set<pair<int, int> > st; int main() { cin >> n >> k >> q; for (int i = 0; i < n; ++i) { cin >> a[i]; } for (int i = 0; i < q; ++i) { int x, y; cin >> x >> y; if (x == 1) { st.insert(make_p...
/* * 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 (c) 2002 Steven Wilson () // // 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; template <typename flow_t = int, typename cost_t = int> struct mcSFlow { struct Edge { cost_t c; flow_t f; int to, rev; Edge(int _to, cost_t _c, flow_t _f, int _rev) : c(_c), f(_f), to(_to), rev(_rev) {} }; const cost_t IN...
module fakeapr( input wire clk, input wire reset, // keys input wire key_start, input wire key_read_in, input wire key_mem_cont, input wire key_inst_cont, input wire key_mem_stop, input wire key_inst_stop, input wire key_exec, input wire key_io_reset, input wire key_dep, input wire key_dep_nxt, input wir...
`timescale 1ns / 1ps module AXI_SRAM( // Common input CLK, // system clock input RST, // active high system reset // AXI-4 SLAVE Interface input axi_awvalid, output axi_awready, input [32-1: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; struct DSU { long long int parent[500001], connected[500001]; void intialize(int x) { for (long long int i = 1; i <= x; i++) { parent[i] = i; connected[i] = 1; } } long long int getparent(long long int k) { while (k != p...
#include <bits/stdc++.h> int main() { int k, a, b; scanf( %d , &k); for (int i = k / 2000 + (k % 2000 > 0);; ++i) { b = i * 2000 - k; a = i - b; if (b <= 1e6 && a < 0 && a >= -1e6) break; } puts( 2000 ); for (int i = 1; i <= 1998; ++i) printf( 0 ); printf( %d %d n , a, b...
#include <bits/stdc++.h> using namespace std; int k, i, j, n; double ans, x[100010], xp, yp, xk; double C(int z) { return hypot(x[z] - xp, yp); } double A(int l, int r) { return x[r] - x[l] + min(C(l), C(r)); } double B(int l, int r) { return x[r] - x[l] + min(abs(xk - x[l]) + C(r), abs(xk - x[r]) + C(l...
#include <bits/stdc++.h> int main() { int i, j, n, max = -1, count, a; char c1, c2; scanf( %d , &n); char s[n]; scanf( %s , s); for (i = 0; i < n - 1; i++) { count = 0; for (j = i + 1; j < n - 1; j++) { if (s[j] == s[i]) { if (s[j + 1] == s[i + 1]) count++; ...
#include <bits/stdc++.h> int main() { const int N = 3 * 3; bool buttons[N] = {0}; int k(0); while (k < N) { char temp; scanf( %c , &temp); if (temp == X ) { buttons[k++] = 1; } else if (temp == . ) { buttons[k++] = 0; } } bool symmetric(1); f...
`timescale 1ns / 1ps /* tf528_ram_top.v Copyright (C) 2016-2017, Stephen J. Leary All rights reserved. This file is part of TF328 (Terrible Fire CD32 RAM + IDE BOARD) TF328 is free: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free S...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 04/07/2015 01:43:34 PM // Design Name: // Module Name: AnalogXADC // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; int i, n, m, j, y, pos, fed = 0; int mice[100001], cheese[100001], taken[100001]; int main() { scanf( %d %d %d %d , &n, &m, &y, &y); for (i = 0; i < n; i++) scanf( %d , &mice[i]); for (i = 0; i < m; i++) scanf( %d , &cheese[i]); for (i = 0; i < m; i+...
#include <bits/stdc++.h> using namespace std; const int N = 1007; int c[N], t[N]; bool cmp(int i, int j) { return c[i] > c[j]; } int main() { int n, k; cin >> n >> k; vector<int> v[3]; for (int i = 0; i < n; ++i) { cin >> c[i] >> t[i]; v[t[i]].push_back(i); } sort((v[1]).be...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } int main() { int x, y; long long int a, b; cin >> x >> y >> a >> b; int lcm = (x * y) / (gcd(x, y)); int ans = (b / lcm) - ((a - 1) / lcm); cout << an...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int x1, y1; cin >> x1 >> y1; int x2, y2; cin >> x2 >> y2; int ans = 0x3f3f3f3f; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i == 0 && j == 0) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 4e5 + 4; const int oo = 1e8 + 7; int n, a[maxn], cc, p; long long s[maxn]; int main() { cin >> n; a[1] = 1; a[2] = 2 * n; a[n + 1] = 2; a[n + 2] = 2 * n - 1; int cc = 3; for (int i = 3; i <= (n); ++i) { if (i % ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100010, maxm = maxn * 2; int h[maxn], ne[maxm], e[maxm], cnt; int d[maxn], dp[maxn][3], w[maxn], root; int a[maxn]; int vis[maxn]; void solve() { int T; scanf( %d , &T); while (T--) { int n; scanf( %d , &n); for (...
#include <bits/stdc++.h> const int INF = 0x3f3f3f3f; const long long int INFLL = 0x3f3f3f3f3f3f3f3fll; long long int getint() { long long int ret = 0; bool f = 0; char c; while ((c = getchar()) < 0 || c > 9 ) if (c == - ) f ^= 1; while (c >= 0 && c <= 9 ) { ret = ret * 10 + ...
#include <bits/stdc++.h> using namespace std; int n; vector<int> a, b, g, ar; vector<vector<int> > edg, nxt; vector<long long> d; long long f(int v) { long long res = 0; for (int w : edg[v]) { long long tmp = f(w) + a[w]; if (tmp > 0) { res += tmp; nxt[w].push_back(v); ...
/** * 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 ToInt(string& s, int len) { int r = 0; for (int i = 0, max_ = (len); i < max_; ++i) { r *= 10; r += s[i] - 0 ; } return r; } int GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; } int LCM(int a, int b) { return a * (b / GCD(a...
#include <bits/stdc++.h> using namespace std; const int N = 100004; int v[N]; int main(void) { priority_queue<int> q; int x, n; cin >> n; int res = 0; set<pair<int, int> > S; for (int i = 0; i < n; ++i) { int x; cin >> x; S.insert(make_pair(x, i + 1)); } int k =...
/****************************************************************************** * File Name : jhash_core.v * Version : 0.1 * Date : 2008 08 29 * Description: jash core module * Dependencies: * * * Company: Beijing Soul * * BUG: * *********************************************...
// (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...
//bug906 import gmcupkg::*; module gminstdecode ( output instClassType instClass /*blah blah blah*/); always_comb begin /*AUTORESET*/ // Beginning of autoreset for uninitialized flops instClass.iFunc = '0; instClass.isBool = '0; instClass.sub.bool ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const double PI = acos(-1.); const double eps = 1e-9; char s[1000005]; char t[1000005]; int fs[11]; int ft[11]; int fx[11]; char y[1000005]; int main() { int i, j, k, _T; while (~scanf( %s%s , s, t)) { if...
#include <bits/stdc++.h> int main() { int n, i, x, k, j = 0; scanf( %d%d , &n, &k); for (i = 0; i < n; i++) { for (x = 0; x < n; x++) { if (i == j && x == j) { printf( %d , k); } else printf( 0 ); } j++; printf( n ); } }
//----------------------------------------------------------------------------- //-- Banco de prueba para setbit //-- (c) BQ August 2015 //-- Written by Juan Gonzalez (obijuan) //-- mods by D. Cuartielles for Arduino, 2015 December, GPLv3 //----------------------------------------------------------------------------- /...
/* * 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...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: California State University San Bernardino // Engineer: Bogdan Kravtsov // Tyler Clayton // // Create Date: 14:30:00 10/31/2016 // Module Name: D_MEM_tb // Project Name: MIPS ...
#include <bits/stdc++.h> using namespace std; void add_self(int &a, int b) { a += b; if (a >= (int)1e9 + 7) a -= (int)1e9 + 7; } int n, l; void f(vector<int> &a) { int x = a[0]; for (int i = 0; i < n - 1; i++) { a[i] = a[i + 1] - a[i]; } a[n - 1] = l - a[n - 1] + x; } void f1...
#include <bits/stdc++.h> using namespace std; int v[100005], b[100005]; int k, n, m, maxim; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { int nr; cin >> nr; b[nr]++; v[b[nr]]++; if (v[b[nr]] == n) cout << 1; else cout << 0; } }
//================================================================================================== // Filename : ceespu_writeback.v // Created On : 2018-07-21 21:14:45 // Last Modified : 2018-09-29 08:25:06 // Revision : // Author : Cees Wolfs // // Description : The writeback selector, ...
/* * 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 minn(int, int, int); int main() { int x1, x2, x3; cin >> x1 >> x2 >> x3; int d1 = abs(x2 - x1) + abs(x3 - x1); int d2 = abs(x1 - x2) + abs(x3 - x2); int d3 = abs(x3 - x1) + abs(x3 - x2); cout << minn(d1, d2, d3) << endl; return 0; } ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 08:33:56 03/10/2016 // Design Name: Top // Module Name: C:/Users/Ranolazine/Desktop/Lab/lab6/test_isim_top.v // Project Name: lab6 // Target Device: // ...
#include <bits/stdc++.h> using namespace std; long long F[401000], Mod = 998244353, InvF[401000]; long long Pow(long long a, long long b) { long long r = 1; while (b) { if (b & 1) r = r * a % Mod; a = a * a % Mod; b >>= 1; } return r; } int A[201000], n, K; long long S[2010...
#include <bits/stdc++.h> using namespace std; char s1[100005], s2[100005]; int main() { int l1, l2, i; char tmp; while (~scanf( %s , s1)) { l1 = strlen(s1); for (i = l1 - 1, l2 = 0, tmp = 0; i >= 0; i--) { if (s1[i] >= tmp) { tmp = s1[i]; s2[l2++] = s1[i]; ...
//Legal Notice: (C)2018 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...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: fpu_div_exp_dp.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 an...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int counts[n + 1]; memset(counts, 0, sizeof(counts)); ...
#include <bits/stdc++.h> int edge[110][110]; int main() { memset(edge, 0, sizeof(edge)); int n, u, v, w; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , &w); edge[i % n][(i + 1) % n] = edge[(i + 1) % n][i % n] = w; } scanf( %d%d , &u, &v); for (int i = 0; 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 (c) 2000-2009 Bluespec, Inc. // 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, pub...
/* * Programing Notes: 1, there are four SPRs in uartlite, access using mtspr/mfspr instructions 2, the four register are: control register ctrl[0]: tx_start ctrl[1]: rx_disenable ctrl[2]: tx_interrupt_ebable - currently not in use ctrl[3]: rx_interrupt_ena...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int main() { string s; cin >> s; int n = s.length(); vector<int> dist(n); for (int i = 0; i < n; i++) if (s[i] == 0 ) dist[i] = (i ? dist[i - 1] : 0) + 1; vector<int> dp(n + 2), nxt(n + 2, n); auto get = [...
/** * 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 long long maxi = 1e18; long long prime[] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29}; long long dp[15][1005], mi[15][1005], ans; int n; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); for (int i = 1; i <= 10; i++) { mi[i][0] =...
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; for (int i = 0; i < int(a.size() - 2); ++i) { char x = a[i], y = a[i + 1], z = a[i + 2]; if (x != . && y != . && z != . ) if (x != y && x != z && y != z) { cout << Yes << endl; 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...
#include <bits/stdc++.h> using namespace std; int main() { long long xa, ya, xb, yb, xc, yc, a, A; cin >> xa >> ya >> xb >> yb >> xc >> yc; if ((xa == xb) && (ya == yb)) cout << YES ; else if ((xb == ya) && (yb == -xa)) cout << YES ; else if ((xb == -xa) && (yb == -ya)) cout ...
/** * 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 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; long long solve() { long long n; cin >> n; vector<long long> arr(n); map<long long, long long> counts; map<long long, long long> checks; for (auto &x : arr) { cin >> x; counts[x]++; } for (auto x : counts) { checks[x.sec...
#include <bits/stdc++.h> const int MN = 2e2 + 10; template <typename T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <typename T> bool ckmax(T& a, const T& b) { return b > a ? a = b, 1 : 0; } template <typename F, int MN, int MM> struct MaxFlow { public: int hd...
#include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } void clock_out() { cerr << nTime Elapsed : << 1.0 * clock() / CLOCKS_PER_SEC << s n ; } void fileio() { freopen( /home/dwai/Desktop/cp/input.txt , r , stdin); freopen( /home/dwai/Desktop/cp/output.txt , w , st...
#include <bits/stdc++.h> using namespace std; int main() { int smallest, largest, n, count = 0, a; cin >> n; for (int i = 0; i < n; i++) { cin >> a; if (i == 0) { smallest = a; largest = a; } else { if (a > largest) { count += 1; largest = a;...
#include <bits/stdc++.h> using namespace std; struct S { long long prime; int q, h, ji; }; S xxx[300000]; priority_queue<S> sum[4]; bool biao[300000]; bool operator<(const S &a, const S &b) { return a.prime > b.prime; } int main() { int x, y; cin >> x; for (int a = 0; a < x; 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...
/* * 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 conmutacion ( input [3:0] centenas, input [3:0] decenas, input [3:0] unidades, input C, input De, input U, input CLKOUTseg, output reg [1:0] mostrar, output reg [3:0] digito ); reg logic0; reg [1:0] titileo; initial begin titileo = 0; end always@(posed...
module sampler(iClock, iReset, iStartSignal, oAddress, oFinished); parameter IDLE = 2'b00, SAMPLING = 2'b01, INCREMENTING_ADDR = 2'b10, FINISHED_SAMPLING = 2'b11; input iClock; input iReset; input iStartSignal; output reg [15:0] oAddress; output oFinished; reg [1:0] state = IDLE; wire [1:0] next_state...
module Platform ( clk_clk, dds_left_strobe_export, dds_right_strobe_export, hex0_2_export, hex3_5_export, hps_io_hps_io_emac1_inst_TX_CLK, hps_io_hps_io_emac1_inst_TXD0, hps_io_hps_io_emac1_inst_TXD1, hps_io_hps_io_emac1_inst_TXD2, hps_io_hps_io_emac1_inst_TXD3, hps_io_hps_io_emac1_inst_RXD0, hps_io_hps_io...
#include <bits/stdc++.h> int x[100001] = {0}; int main() { int i, n; scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &x[i]); } int sum = 0; int cn = 0; for (i = 0; i < n; i++) { sum = sum + x[i] - x[i + 1]; if (sum < 0) { do { cn++; ...
module testbench ( CLOCK_50, // 50 MHz //////////////////// LCD Module 16X2 //////////////// LCD_ON, // LCD Power ON/OFF LCD_BLON, // LCD Back Light ON/OFF LCD_RW, // LCD Read/Write Select, 0 = Write, 1 = Read LCD_EN, // LCD Enable LCD_RS, // LCD Command/Data Select, ...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( O3 ) const long long inf = 1e17; void bfs(int a, vector<vector<int> > &g, vector<int> &da) { int n = g.size(); queue<int> q; q.push(a); vector<bool> u(n, fal...
#include <bits/stdc++.h> using namespace std; void USACO(string s) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((s + .in ).c_str(), r , stdin); freopen((s + .out ).c_str(), w , stdout); } const long long MAXN = 5010; void solve() { long long n; string s; cin >> n; ci...
#include <bits/stdc++.h> using namespace std; const int dx[9] = {0, 1, -1, 0, 0, -1, -1, 1, 1}; const int dy[9] = {0, 0, 0, -1, 1, -1, 1, -1, 1}; const double pi = acos(-1.0); const int N = 1e5 + 100; long long pre[N], a[N], temp[200], ans = 0; int n, k, ma = 0; map<long long, long long> dic; int main...
/** * 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; void upd(long long& x) { x = -x - 1; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; vector<long long> a(n); for (int j = 0; j < n; j++) { cin >> a[j]; if (a[j] >= 0) upd(a[j]); ...
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed ...
#include <bits/stdc++.h> using namespace std; const int INF = 999999999; const double EPSILON = 0.00000001; const long long MOD = 1000000007; bool used[200005]; struct interval { int first, second; int idx; }; bool operator<(const interval &self, const interval &other) { return self.first < ...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma GCC optimize( unroll-loops ) using namespace std; const int arr = 2e5 + 10; const int ar = 2e3 + 10; const long double pi = acos(-1); const long double eps = 1e-10; ...
#include <bits/stdc++.h> using namespace std; int n; long double ans1[1000000]; long double ans2[1000000]; long double sa[1000000]; long double sb[1000000]; long double x1[1000000]; long double x[1000000]; long double sqr(long double x) { return x * x; } long double sqrtt(long double x) { if (x ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int long long n, c = 0; cin >> n; for (int long long i = 1; i < n; i++) { if (n % i == 0) { c++; } } cout << (c); return 0; }
#include <bits/stdc++.h> using namespace std; int N, a[100005], b[100005]; char s1[100005], s2[100005]; long long x11, x01, x10, x00, ans; int main() { scanf( %d , &N); cin >> s1; cin >> s2; for (int i = 1; i <= N; ++i) a[i] = s1[i - 1] - 0 , b[i] = s2[i - 1] - 0 ; for (int i = 1; i <= N...
module core_top( input clk, rst, run_n, input [3:0] reg_addr_d, output [15:0] reg_out ); //wire clk; wire reg_we, sram_we_n, ram_wren; wire [2:0] alu_operator; wire [3:0] reg_addr_a, reg_addr_b, reg_addr_c; wire [15:0] ram_addr, ram_data, reg_data_a, reg_data_b, reg_data_c, reg_data_d, alu_op_a,al...
#include <bits/stdc++.h> using namespace std; long long Pow(long long a, long long b) { long long ans = 1LL, base = a % 1000000007; while (b != 0) { if (b & 1LL != 0) ans = ans * base % 1000000007; base = base * base % 1000000007; b >>= 1LL; } return ans; } long long A, B, n, x...
/* Copyright (c) 2014-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...
/** * 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 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Thu Sep 14 09:48:07 2017 // Host : PC4719 running 64-bit Service Pack 1 (...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable 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...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...