text stringlengths 59 71.4k |
|---|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Projekt : FGLT TU Darmstadt
// Dateiname : spmc_dcf77.v
// Autor : Stefan Klir
// Modul : spmc_dcf77
//
// Beschreibung : DCF77 ist ein Hardwaremodul welches das DCF77 Funksignal
// decodiert und an die softw... |
#include <bits/stdc++.h> using namespace std; template <class T> T min(T a, T b, T c) { return min(a, min(b, c)); } template <class T> T min(T a, T b, T c, T d) { return min(a, min(b, min(c, d))); } template <class T> T max(T a, T b, T c) { return max(a, max(b, c)); } template <class T... |
#include <bits/stdc++.h> using namespace std; const long long N = 110; long long dp[N][2], n, val[N], ans; char s[N]; signed main() { scanf( %s , s + 1); n = strlen(s + 1); for (long long i = 1; i <= n; ++i) val[i] = (s[i] == A ); dp[1][val[1]] = 1; dp[0][0] = 1; for (long long i = 2;... |
/*
* 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 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... |
/*
* 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; int a[(int)(2 * 1e5 + 10)]; long long pa[(int)(2 * 1e5 + 10)]; long long sa[(int)(2 * 1e5 + 10)]; int main() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; pa[i] = 1ll * a[i] + pa[i - 1]; } for (int i = n; i >= 1; --i)... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: Xilinx, Inc
// Engineer: Parimal Patel
// Create Date: 06/24/2016 09:26:14 AM
// Module Name: audio_direct
// Project Name: PYNQ
///////////////////////////////////////////////////////////////////////////... |
//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... |
#include <bits/stdc++.h> using namespace std; const int MX = 2000 + 1; const int M = 1e9 + 7; vector<pair<int, int>> adj[MX]; int dp[MX][MX]; int add(int a, int b) { return (a += b) < M ? a : a - M; } int mul(int a, int b) { return 1LL * a * b % M; } int floor_div(int a, int b) { return a / b - ((a ^ b)... |
// DESCRIPTION: Verilator: SystemVerilog interface test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2020 by Thierry Tambe.
// SPDX-License-Identifier: CC0-1.0
module t (
input logic clk,
output logic HRESETn
);
int primsig[3];
ahb_slave_int... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 10000005, p = 1e9 + 7; int n, k, cnt, phi[Maxn], prim[Maxn], sum[Maxn], ct[Maxn]; long long ans; bool vis[Maxn]; void init(void) { phi[1] = 1; for (int i = 2; i <= n; i++) { if (!vis[i]) prim[++cnt] = i, phi[i] = i - 1; 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 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 main() { int i = 0, a = 0, b = 0, c = 0; string s; cin >> s; for (; i < s.length(); i++) { if (s[i] == a ) a++; else break; } for (; i < s.length(); i++) { if (s[i] == b ) b++; else br... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const double EPS = 1e-9; const int INF = 1 << 29; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int x, y; cin >> x >> y; int dx = abs(x1 - x2), dy = abs(y1 - y2); if (dx % x || dy % y) { puts( ... |
#include <bits/stdc++.h> using namespace std; template <typename S, typename T> ostream& operator<<(ostream& out, const pair<S, T> p) { out << ( << p.first << , << p.second << ) ; return out; } template <typename T> ostream& operator<<(ostream& out, const vector<T>& v) { for (auto a : v) ou... |
#include <bits/stdc++.h> using namespace std; int main() { char name[5][10] = { Sheldon , Leonard , Penny , Rajesh , Howard }; int n, c = 5; scanf( %d , &n); while (n > c) { n -= c; c *= 2; } printf( %s n , name[(n - 1) / (c / 5)]); return 0; } |
#include <bits/stdc++.h> using namespace std; const int RLEN = 1 << 18 | 1; inline char nc() { static char ibuf[RLEN], *ib, *ob; (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin)); return (ib == ob) ? -1 : *ib++; } inline int rd() { char ch = nc(); int i = 0, f = 1; while (... |
#include <bits/stdc++.h> using namespace std; int main() { int n, d, m, s; cin >> n >> d; vector<pair<int, int> > v; vector<int> money; for (int i = 0; i < n; i++) { cin >> m >> s; pair<int, int> p = make_pair(m, s); v.push_back(p); money.push_back(m); } sort(v.be... |
#include <bits/stdc++.h> using namespace std; int pi[200015]; void PreKMP(char *P, int n) { int q, k = 0; pi[1] = 0; for (q = 2; q <= n; pi[q++] = k) { while (k && (P[k] != P[q - 1])) k = pi[k]; if (P[k] == P[q - 1]) k++; } } int KMP(char *T, int n, char *P, int m) { int i, q =... |
/**
* 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 SIZE = 2100; struct kstr { int C[30]; bool mask[110]; } A[SIZE]; int CC[30]; int main() { int K, N, len; char S[110]; cin >> K >> S >> N; len = strlen(S); for (int i = 0; i != len; i++) CC[S[i] - a ]++; for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int mod = 1e9 + 7; long long power(int a, long long b) { if (b == 0LL) return 1LL; long long tmp = power(a, b / 2); if (b & 1LL) return (tmp * tmp % mod) * a % mod; return tmp * tmp % mod; } int main() { ios:... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void chkmax(T &x, T y) { if (x < y) x = y; } template <class T> inline void chkmin(T &x, T y) { if (x > y) x = y; } int q, n, f, inv[100100], fac[100100], p[6]; void Euclid(int a, int b, int &x, int &y) { if (!a) ... |
// -------------------------------------------------------------
//
// Generated Architecture Declaration for rtl of inst_e_e
//
// Generated
// by: wig
// on: Mon Jun 26 08:25:04 2006
// cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../../generic.xls
//
// !!! Do not edit this file! Autogenerated by MIX !!!
// $Auth... |
#include <bits/stdc++.h> using namespace std; long long l, w, k; int main() { cin >> l >> w >> k; if (k > l + w - 2) { cout << -1; return 0; } if (k + 1 <= max(l, w)) { long long e = max(l, w); long long t = min(l, w); long long j = (t / (k + 1)) * max(l, w); lo... |
#include <bits/stdc++.h> const int MAXN = 100010; int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], val[MAXN << 1], tot; void addedge(int b, int e, int v) { nxt[++tot] = head[b]; to[head[b] = tot] = e; val[tot] = v; nxt[++tot] = head[e]; to[head[e] = tot] = b; val[tot] = v; } int n, Q; ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = 4 * atan(1); const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9 + 7; int nCase = 0; int dcmp(double x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; } templ... |
#include <bits/stdc++.h> using namespace std; using LL = long long; int a[25]; LL dp[25][5], l, r; LL dfs(int pos, int cnt, bool zero, bool limit) { if (pos == -1) return 1; if (!limit && !zero && dp[pos][cnt] != -1) return dp[pos][cnt]; int up = limit ? a[pos] : 9; if (cnt == 3) up = 0; L... |
#include <bits/stdc++.h> using namespace std; int n; vector<pair<int, int> > edges; vector<int> conn[201]; bool v1[201], v2[201]; int mx = 0; void setEdge(int a, int b, int v) { for (int s = 0; s < conn[a].size(); s++) { if (conn[a][s] == b || conn[a][s] == -1) conn[a][s] = (v == 1 ? b : -1); ... |
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; int main() { int N; cin >> N; vvi tree(N); for (int i = 0; i < N - 1; ++i) { int a, b; cin >> a >> b; a--; b--; tree[a].push_back(b); tree[b].push_back(a); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; t = 1; while (t--) { int n, m; cin >> n >> m; string s[n]; for (int i = 0; i < n; ++i) { cin >> s[i]; } int cnt = 0; ... |
#include <bits/stdc++.h> using namespace std; int n; int a[(int)2e5][2]; int main() { cin >> n; if (n == 3) { cout << 1 2 3 << endl; return 0; } for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; a[i][0]--; a[i][1]--; } int next = 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 la... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long ksm(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } long long gcd(long lo... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int man = 0, ans = 0, n, m; int a[1000]; while (cin >> n >> m) { ans = 0; if (n > m) { printf( %d n , n - m); } else { while (n < m) { if (m % 2 != 0) { m++; ans++... |
// Logic to map a wall edge lighting region's LED pixels to LCD pixels.
// Copyright (c) 2013 Jared Boone, ShareBrained Technology, Inc.
//
// This file is part of the Medusa project.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as p... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { ios_base::sync_with_stdio(false); cin >> n >> m; if (m == 3 && n != 4 && n != 3) { cout << -1; return false; } int x = 0, y = 0; for (int i = 1; i <= m; i++) { cout << x << << y << endl; x++; ... |
// -- (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... |
/**
* 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> int deg[100000]; int xr[100000]; int edges[100000][2]; int main() { int n, t = 0; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d%d , °[i], &xr[i]); } for (int i = 0; i < n; i++) { if (deg[i] == 1) { int k = i; do { e... |
`timescale 1 ps / 1 ps
//-----------------------------------------------------------------------------
// Title : PCI Express PIPE PHY connector
// Project : PCI Express MegaCore function
//-----------------------------------------------------------------------------
// File : altpcietb_pipe_phy.... |
#include<bits/stdc++.h> using namespace std; #pragma region atcoder /*#include <atcoder/all> using namespace atcoder; //using mint = modint998244353; //using mint = modint1000000007;*/ #pragma endregion #pragma region macros using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll... |
// ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014
//
// SPI mode 0 8-bit master module
/*
This file is part of ZX-Evo Base Configuration firmware.
ZX-Evo Base Configuration firmware is free software:
you can redistribute it and/or modify it under the terms of
the GNU General 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... |
/*
* These source files contain a hardware description of a network
* automatically generated by CONNECT (CONfigurable NEtwork Creation Tool).
*
* This product includes a hardware design developed by Carnegie Mellon
* University.
*
* Copyright (c) 2012 by Michael K. Papamichael, Carnegie Mellon University
*
* ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2010; int n, m, k, p, q, d[maxn][maxn]; bool vis[maxn][maxn]; bool solve(int x, int y, int r) { for (int i = max(1, x - r); i <= min(n, x + r); i++) { int tmp = r - abs(i - x); if (y - tmp >= 1 && !vis[i][y - tmp]) { p = i,... |
// megafunction wizard: %LPM_MULT%VBB%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsquare
// ============================================================
// File Name: mult16.v
// Megafunction Name(s):
// altsquare
//
// Simulation Library Files(s):
// altera_mf
// ======================... |
/**
* 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 C-L-G.FPGA1988.Roger Wang. All rights reserved------------------
//
// -- It to be define --
// -- ... |
/**
* 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 d, s; int E[2510050][10]; int Get(int x, int y) { return x * d + y; } int dis[2710500]; char ok[2700050] = {}; vector<int> ans; int ST, EN; int dfs(int x) { if (x == EN) return 1; ok[x] = 1; for (int u = 0; u < 10; u++) if (x != 0 || ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int maxn = 50; int k, w, h; int read() { int x = 0, y = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) y = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = (x << ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, n, day, ans, flag; cin >> n; long long int a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); day = 1; ans = 0; j = 0; while (1) { flag = 0; for (i = j; i < n; i++) { if ... |
#include <bits/stdc++.h> using namespace std; const long long mm = 1000000007; const long long inf = 1e18; long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch -... |
#include <bits/stdc++.h> using namespace std; const long long MAX = 1e18; long long k, n, c; string s; long long p[26][26]; long long f[105][105][26]; char x, y; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s >> k >> n; for (long long i = 1; i <= n; i... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2020 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// Let context messages easily know if given line is expected ok or bad
task ok;
endtask
task bad;
endtask... |
/**
* 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; long long int n = 0, m, l = 0, k, a, b, c, sum = 0, i, r = 0, j, second, h, first = 0, sc, ans = 0, x, t, y; double aa, pp; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> k >> b >> n >> t; if (k ==... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, i, j, k, l; cin >> n >> a; long long arr[n + 2]; for (i = 1; i <= n; i++) { cin >> arr[i]; } long long pos; arr[n + 1] = a; sort(arr + 1, arr + n + 2); for (i = 1; i <= n + 1; i++) { if (arr[i]... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2006 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc; initial cyc = 0;
reg [6... |
//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... |
#include <bits/stdc++.h> using namespace std; int n, m, t; pair<int, int> a[300005]; int b[300005]; int force(int ll, int rr) { int r = 0; for (int i = 1; i <= n; i++) if (a[i].first >= ll && a[i].second <= rr) r++; return r; } struct indexed_tree_2d { vector<int> T[1000006]; voi... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Jorge Sequeira
//
// Create Date: 09/01/2016 06:29:42 PM
// Design Name:
// Module Name: KOA_FPGA
// Project Name: Recursive Karatsuba Offman Multiplication
// Target Devices:
// Tool Ver... |
/*
* 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:
// Engineer:
//
// Create Date: 05/03/2016 05:05:47 AM
// Design Name:
// Module Name: Testbench_uart
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//... |
module spi_slave(
input clk,
input rst,
input ss,
input mosi,
output miso,
input sck,
output done,
input [7:0] din,
output [7:0] dout
);
reg mosi_d, mosi_q;
reg ss_d, ss_q;
reg sck_d, sck_q;
reg sck_old_d, sck_old_q;
reg [7:0] data_d, data_q;
reg done_d, done_q;
reg [2:0] bit_ct_d, bit_ct_q;... |
#include <bits/stdc++.h> int a[128][128], v[128], cor[128], bucket[128]; int m, n; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; ++i) { scanf( %d , &v[i]); cor[i] = 1; for (int j = 2; j <= n; ++j) { int x; scanf( %d , &x); if (x > v[i]) { v... |
#include <bits/stdc++.h> char ch; bool fs; void re(int& x) { while (ch = getchar(), ch < 33) ; if (ch == - ) fs = 1, x = 0; else fs = 0, x = ch - 48; while (ch = getchar(), ch > 33) x = x * 10 + ch - 48; if (fs) x = -x; } using namespace std; pair<int, int> d[62]; in... |
#include <bits/stdc++.h> using namespace std; long long n, clr[300001][3] = {{0}}; vector<long long> v[300001]; void dfs(long long node, long long parent) { for (auto x : v[node]) { if (x == parent) continue; dfs(x, node); clr[node][1] += clr[x][1]; clr[node][2] += clr[x][2]; } ... |
/**
* 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... |
// synthesis verilog_version verilog_2001
`timescale 1 ps / 1 ps
//-----------------------------------------------------------------------------
// Title : PCI Express Reference Design Example Application
// Project : PCI Express MegaCore function
//------------------------------------------------------... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; long long f[MAXN][MAXN][MAXN]; int a[MAXN]; string s; int n; long long solve(int l, int r, int pf) { if (l >= r) return 0; if (r - l == 1) return a[pf]; long long &cur = f[l][r][pf]; if (cur > 0) return cur; cur = max(... |
#include <bits/stdc++.h> using namespace std; ifstream f( test.in ); ofstream g( test.out ); int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n, ans = 0; cin >> n; stack<int> s; int x; cin >> x; s.push(x); for (int... |
#include <bits/stdc++.h> using namespace std; pair<int, int> add(pair<int, int> p1, pair<int, int> p2, int odd, int even) { return make_pair(p1.first + p2.first - odd, p1.second + p2.second - even); } pair<int, int> dfs(vector<int>* adj, int* visited, int* store, int u, int parent, int ... |
//Legal Notice: (C)2021 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... |
//Legal Notice: (C)2015 Altera Corporation. All rights reserved. Your
//use of Altera Corporation's design tools, logic functions and other
//software and tools, and its AMPP partner logic functions, and any
//output files any of the foregoing (including device programming or
//simulation files), and any associated do... |
#include <bits/stdc++.h> using namespace std; char a[100010]; int n, k; int main() { cin >> n >> k >> a; for (int i = 0; i < n && k > 0; i++) { if (a[i] == 4 && a[i + 1] == 7 ) { if (i % 2 == 0) a[i] = a[i + 1] = 4 ; else if (i > 0 && a[i - 1] == 4 ) { if (... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; set<int> s; for (int i = 0; i < n; i++) { int a; cin >> a; s.insert(a); } if (s.size() > k) { cout << -1 << endl; return; } cout << n * k << endl; for (int i = 0; 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 n, a[100010], cnt[100010]; int main() { int max1 = 0, max2 = 0; cin >> n; ; for (int i = 1; i <= n; i++) { cin >> a[i]; ; } for (int i = 1; i <= n; i++) { if (a[i] > max1) { max2 = max1; max1 = a[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... |
/**
* 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... |
/**
* 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... |
`default_nettype none
`include "common.h"
module mmu_if(
input wire iCLOCK,
input wire inRESET,
input wire iFREE_TLB_FLUSH,
/*************************
To Core
*************************/
//Core -> This
input wire iCORE_REQ,
output wire oCORE_LOCK,
input wire iCORE_DATA_STORE_ACK,
input wire [1:0... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long ans = 1; ans += (3 * n * (n + 1)); cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; int bst(int a[], int lw, int hi, int n) { int mid = (lw + hi) / 2; if (lw > hi) return -1; if (a[mid] > n) bst(a, lw, mid - 1, n); else if (a[mid] < n) bst(a, mid + 1, hi, n); else return mid; } long long pw(long long a, long lo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 500005; const int inf = 100000000; struct elem { long long val; int l, r; }; struct V { long long val; int ind; }; bool compare(V x, V y) { if (x.val < y.val) return true; if (x.val == y.val && x.ind < y.ind) return t... |
module Arreglo_Torus (
input RST, // Reset maestro
input CLK, // Reloj maestro
input[3:0] A00,A01, // Coef Matriz A
input[3:0] A10,A11,
input[3:0] B00,B01, // Coef Matriz B
input[3:0] B10,B11,
input ENpH, // Habilitaciones Rp Alto
input ENpL, // Habilitaciones Rp Bajo
input ENa, ... |
#include <bits/stdc++.h> using namespace std; string second, pre, suf; int main() { ios::sync_with_stdio(false); cin >> second; int n = (int)second.size(); int l = 0; int r = n - 1; while (l + 1 < r - 1) { if (second[l] == second[r]) { pre += second[l]; suf += second[... |
module system (
clk_50_clk,
kernel_clk_clk,
memory_mem_a,
memory_mem_ba,
memory_mem_ck,
memory_mem_ck_n,
memory_mem_cke,
memory_mem_cs_n,
memory_mem_ras_n,
memory_mem_cas_n,
memory_mem_we_n,
memory_mem_reset_n,
memory_mem_dq,
memory_mem_dqs,
memory_mem_dqs_n,
memory_mem_odt,
memory_mem_dm,
memory_oct... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); int n, d, arr[2001], mx; long long ans, dp[2001][2]; vector<int> adj[2001]; void DFS(int u = 1, int p = -1) { for (int i : adj[u]) if (i != p) DFS(i, u); dp[u][arr[u] == mx] = 1; dp[u][0] *= (arr[u] >= (mx - d)) && (... |
#include <bits/stdc++.h> using namespace std; long long qu(long long a, long long b) { cout << ? << a << << b << endl; fflush(stdout); string s; cin >> s; if (s[0] == x ) return 1; return 2; } int main() { string s; while (1) { cin >> s; if (s != start ) retu... |
`timescale 1ns / 1ps
// nexys3MIPSSoC is a MIPS implementation originated from COAD projects
// Copyright (C) 2014 @Wenri, @dtopn, @Speed
//
// 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 Found... |
#include <bits/stdc++.h> using namespace std; int main() { long long q; cin >> q; while (q--) { long long c, m, x; cin >> c >> m >> x; long long a = min(c, m); long long left = m - a + x + c - a; if (left >= a) { cout << a << endl; } else { long long t... |
/**
* 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.