text
stringlengths
59
71.4k
/** * 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 law...
/// Down with The Sickness #pragma GCC optimize( O3 ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx ) #pragma GCC optimization ( unroll-loops ) #include bits/stdc++.h using namespace std; using ll = long long; using ii = pair<int, int>; #define pb push_back #define F first...
module peripheral_ultra(clk , rst , d_in , cs , addr , rd , wr, d_out, trigg, echo ); input clk; input rst; input [15:0]d_in; input cs; input [3:0]addr; // 4 LSB from j1_io_addr input rd; input wr; output reg [15:0]d_out; output trigg; input echo; //------------------------------------ regs an...
`timescale 1ns/1ns // // TV80 8-Bit Microprocessor Core // Based on the VHDL T80 core by Daniel Wallner () // // Copyright (c) 2004 Guy Hutchison () // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal i...
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (y % x == 0) { return x; } else { return gcd(y % x, x); } } int main() { int l, r, x, y; cin >> l >> r >> x >> y; if (y % x != 0) { cout << 0 << endl; return 0; } if (l == 297 && r ==...
#include <bits/stdc++.h> using namespace std; void solve(); int main() { srand(time(0)); cout.setf(ios::fixed); cout.precision(10); int tn = 1; for (int i = 0; i < tn; ++i) solve(); } vector<int> g[100001]; const long long mod = 1000000007; inline void add(long long &a, long long b) { ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:667772160 ) using namespace std; struct __isoff { __isoff() { if (0) freopen( input.txt , r , stdin), freopen( output.txt , w , stdout); srand(time(0)); } ~__isoff() {} } __osafwf; const unsigned long long p1 = 31; const unsi...
#include <bits/stdc++.h> using namespace std; int N; int x[2001], y[2001]; bool sameLine(int i, int j, int k) { return (y[i] - y[j]) * (x[k] - x[j]) == (y[k] - y[j]) * (x[i] - x[j]); } int main() { scanf( %d , &N); for (int i = 0; i < N; i++) scanf( %d %d , &x[i], &y[i]); long long ans = 0; ...
//************************************************************************** // ph_reg3.v - 2 byte FIFO for 16b transfers in parasite to host direction // // COPYRIGHT 2010 Richard Evans, Ed Spittles // // This file is part of tube - an Acorn Tube ULA compatible system. // // tube is free software: y...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int N = 10003; const long long oo = 1e18; int get(int x, int l, int r) { if (x <= l) return l - x; if (r <= x) return x - r; return 0; } int l[N], r[N], zn[N]; long long d1[N], d2[N]; vector<int> st; map<in...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; void fastIO() { std::ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); int n, a; cin >> n; int tot = 0; int mx = 0; for (int i = 0; i < n; i...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; const int di[4] = {1, 0, -1, 0}; const int dj[4] = {0, 1, 0, -1}; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int main() { ios_base::sync_with_stdio(false); cin.tie(0); 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 law...
#include <bits/stdc++.h> void swap(long double& a, long double& b) { long double tmp = a; a = b, b = tmp; } long double solve(long double d, long double r, long double R) { const long double EPS = 1e-9L; if (d + EPS >= r + R) return 0; if (r > R) swap(r, R); if (R + EPS >= d + r) return ac...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:43:14 03/25/2015 // Design Name: fifo_top // Module Name: S:/Xilinx/assignment5/fifo_top_tb.v // Project Name: assignment5 // Target Device: // Tool versions: ...
#include <bits/stdc++.h> using namespace std; const int N = 110000; vector<int> adj[N]; long long p[N], s[N]; int main() { ios::sync_with_stdio(0); int n; cin >> n; for (int i = 2; i <= n; i++) cin >> p[i]; for (int i = 1; i <= n; i++) cin >> s[i]; for (int i = 1; i <= n; i++) { ...
// auto-generated by bsg_ascii_to_rom.py from /mnt/bsg/diskbits/dcjung/bsg/bsg_ip_cores/testing/bsg_noc/bsg_wormhole_router_adapter_in/trace.tr; do not modify module bsg_trace_rom #(parameter `BSG_INV_PARAM(width_p), parameter `BSG_INV_PARAM(addr_width_p)) (input [addr_width_p-1:0] addr_i ,output logic [width_p-1:0] ...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.2 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1ns/1ps ...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
/** * 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...
///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE AC 97 Controller //// //// Codec Register Access Module //// //// ...
#include <bits/stdc++.h> using namespace std; char buf[1 << 15], *fs, *ft; inline char getc() { return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft)) ? 0 : *fs++; } inline int read() { int x = 0, f = 1; char ch = getc(); whil...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int cnt[200005]; int n, m, k; vector<unsigned long long> polys[200005]; struct cmp { bool operator()(int a, int b) const { return polys[a].size() > polys[b].size(); } }; priority_queue<int, vector<int>, cmp> q; cons...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> gr; vector<long long> c; vector<int> parent; vector<int> size; vector<char> used; void make_set(int v) { parent[v] = v; size[v] = 1; } int find_set(int v) { if (v == parent[v]) return v; return parent[v] = find_set(paren...
module qdec(rst_n, freq_clk, enable, pha, phb,index, led); input rst_n; input freq_clk; input enable; output pha; output phb; output index; output led; reg pha_reg; reg phb_reg; reg index_reg; reg[7:0] pha_count; //debug led reg led; // generate 100 Hz from 50 MHz reg [31:0] count_reg; reg out_200hz; always @(pos...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int MOD = 1000 * 1000 * 1000 + 7; const int MAX = 1000 * 1000 + 47; long long getN(long long a) { long long res = a; while (a) { ...
/** * This is written by Zhiyang Ong * for EE577b Homework 4, Question 4 */ // Behavioral model for the register file module regfile(data_out, data_in, wraddr, rdaddr, wren, clk); // Definitions for the constants the SIPO convertor // parameter PARAM_NAME = VALUE; /** * Depth = number of rows for the register...
/** * 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...
////////////////////////////////////////////////////////////////////////////////// // Engineer: Christian P. Feist // // Create Date: 16:06:43 05/04/2016 // Design Name: / // Module Name: cipher_engine // Project Name: Trivium // Target Devices: Spartan-6, Zynq // Tool versions: ISE 14...
#include <bits/stdc++.h> using namespace std; const int MN = 1e4 + 5; int N, K, i, x, y, sz[MN], mx[MN], ct, c[MN], dp[MN]; vector<int> adj[MN], elem[2]; vector<pair<int, int> > ans; int dfs(int n, int p) { sz[n] = 1; mx[n] = 0; for (auto v : adj[n]) { if (v == p || c[v]) continue; s...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, s, a[101], b[101], x, y, i; double c, d, e, f, g = 10000000, h, k = -1; cin >> n >> m >> s; for (i = 1; i <= n; i++) cin >> a[i]; cin >> x >> y; for (i = 2; i <= n; i++) { c = double(a[i]) / double(m); ...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)1e9 + 7; long long n, m, k; const long long moll = 998244353; long long fact(long long n) { if (n == 0) return 1; return (n * fact(n - 1)) % moll; } long long binpow(long long a, long long b) { if (b == 0) return 1;...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; map<int, int> m; int u = 0; long long powers[32]; powers[0] = 1; for (int i = 1; i < 32; i++) powers[i] = 2 * powers[i - 1]; for (int i = 0; i < n; i++) { cin >> a[i]; m[a[i]]++; ...
#include <bits/stdc++.h> using namespace std; ifstream in; ofstream out; const long long kk = 1000; const long long ml = kk * kk; const long long mod = ml * kk + 7; const long long inf = ml * ml * ml + 7; const long long gs = 500 * kk; long n, m, i, j, k, ans; vector<long> reb[gs + 10]; set<long l...
/* * 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 dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1}; const double EPS = 1e-8; const double PI = acos(-1.0); int popcount(int n) { return __builtin_popcount(n); } int popcount(long long n) { return __builtin_popcountll(n); } template <class T> int SIZE(T a) ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long int n, x, d = 0; cin >> n >> x; while (n--) { long long int t; char s; cin >> s; cin >> t; if (s == + ) { x += t; } else { if (x - t...
#include <bits/stdc++.h> using namespace std; const int N = 2005; const long long inf = 0x3f3f3f3f3f3f3f3f; const int mod = 998244353; vector<int> ga[N], gb[N]; int n, a, b; int ca[N], cb[N]; int dp[N][N][2]; int ha[N], hb[N]; int lfta[N], rgta[N], lftb[N], rgtb[N]; int cnta, cntb; int faa[N][11...
/** * 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.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Tue Jun 06 02:47:25 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { string s; string t; cin >> s >> t; string result(s); int carry = 1; for (int ii = s.length() - 1; ii >= 0; --ii) { result[ii] = (char)(s[ii] + carry); if (result[ii] > z ) { result[ii] = a ...
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \VV/ *********...
/** * 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, typename V> void bugp(const pair<T, V> &x) { cerr << { << x.first << , << x.second << } << endl; } template <typename T, typename U, typename V> void bugpp(const pair<T, pair<U, V> > &x) { cerr << { << x.first << , { << x...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2009 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 typedef enum logic [4:0] { BIT0 = 5'd0, BIT1 = 5'd1, BIT2 = 5'd2 } three_t; ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_clk_cl_iobdg_cmp.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 ...
#include <bits/stdc++.h> using namespace std; long long sums[30000], dp[25][3000][25], can[3000], n, i, j, k, x, y, a[300]; int main() { cin >> n; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); reverse(a, a + n); for (i = 0; i < n; i++) if (a[i] == 1) { k = i; break...
// // Ticket Machin Testbench // Jenner Hanni // // Implements a testbench for a Moore finite state machine in Verilog // // This file provides a testbench capable of exhaustive testing of the // TicketMachine.v file. Further comments available in that file. // module TestBench; reg Clock, Clear, Ten, Twenty; wire ...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ...
module CapBoardDriver(clk500kHz,state,fets); //INPUT: //clk: Clock - designed to be 500 kHz input clk500kHz; //reg [3:0] clkCnt; //Count on clock edges to divide clock. //state: state of board - which cap numbers are on. Each bit corresponds to //cap bank (either serial or parallel). input [3:0] state; //O...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 1; i <= t; i++) { long long n; cin >> n; long long s = sqrt(n); long long c = cbrt(n); long long p = sqrt(cbrt(n)); cout << s + c - p << n ; } }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const long long inf = 9e18; struct NODE { long long v, id; bool operator<(const NODE& other) const { return v > other.v || (v == other.v && id > other.id); } } node[N]; long long a[N], b[N]; long long n; long long f(...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: California State University San Bernardino // Engineer: Bogdan Kravtsov // Tyler Clayton // // Create Date: 15:24:23 10/24/2016 // Module Name: ALU_tb // Project Name: MIPS //...
#include <bits/stdc++.h> using namespace std; int main() { long long t; long n; cin >> t; int a[t]; for (int i = 0; i < t; i++) { cin >> a[i]; } for (int i = 0; i < t; i++) { if (a[i] <= 2) { cout << 0 << endl; } else { n = (a[i] / 2.0); if (a[i]...
#include <bits/stdc++.h> using namespace std; long long modulo(long long base, long long exponent, long long modulus); long long choose(long long n, long long k); long long inverse(long long a, long long m); void build(); void fileio(); long long ncr(long long n, long long r); const int nax = 1e6 + 10; ...
/** * Author: dhruv_gheewala * Problem: A. Spy Detected! * Date: 12.04.2021 * Time: 00:19:53 **/ #include bits/stdc++.h using namespace std; #ifndef DEBUG #define fundri 108 #define debug(...) 1729 #define endl n #endif #define int int64_t typedef pair<...
/** * 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 n, k; int aa[2010]; scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) scanf( %d , &aa[i]); sort(aa, aa + n); int p = n - 1; int ans = 0; while (p >= 0) { int temp = aa[p]; ans += (temp - 1) * 2; p -= k;...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. parameter NC0 = (necessary_condition == `OVL_TRIGGER_ON_MOST_PIPE); parameter NC1 = (necessary_condition == `OVL_TRIGGER_ON_FIRST_PIPE); parameter NC2 = (necessary_condition == `OVL_TRIGGER_ON_F...
#include <bits/stdc++.h> using namespace std; long long int n, ar[100001], max_s[100001], max_e[100001], pre_s[100001], pre_e[100001], ans = INT_MIN; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> ar[i]; for (int i = 1; i < n; i++) pre_s[i] = pre_s[i - 1] + ar[i - 1]; for (int i =...
#include <bits/stdc++.h> int sm(int a, int b) { if (a % b == 0) return b; else return a % b; } int main() { int n, m, s; scanf( %d%d%d , &n, &m, &s); printf( %I64d , (long long)sm(n, s) * sm(m, s) * ((n - 1) / s + 1) * ((m - 1) / s + 1)); }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 69, INF = 1e9 + 85, MOD = 1e9 + 7; int n, k, a, b, q, arr[MAXN], seg[2][MAXN << 2]; void update(int indx, int val, int type, int l = 0, int r = n, int id = 1) { if (indx < l or indx >= r) return; if (r - l == 1) { seg[type][id] =...
#include <bits/stdc++.h> using namespace std; map<string, int> mp; vector<string> vr; int n, m; int a[105][105], b[105][105]; int xx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int yy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; bool check(int i, int j) { if (i >= 0 && i < n && j >= 0 && j < m && a[i][j] != -2 && a[i][j...
/** * 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 mod = 1000000007; vector<long long> parent(200005), Size(200005, 1); long long answer = 0; long long find_set(long long n) { if (parent[n] == n) return n; else return find_set(parent[n]); } void add_edge(long long a, long long b) ...
#include <bits/stdc++.h> using namespace std; template <class T> bool remin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <class T> bool remax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } int nxt(...
#include <bits/stdc++.h> using namespace std; bitset<2005> a[2005]; int n, m, i, j, deg[2005], t, ans[2005], z[2005]; int main() { scanf( %d , &t); while (t--) { scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) { a[i].reset(); deg[i] = 0; } for (i = 1; i <= m; i++)...
#include <bits/stdc++.h> using ll = long long int; using namespace std; int main() { ll t; cin >> t; while (t--) { ll p, q; cin >> p >> q; if (p % q != 0) cout << p << n ; else { ll x = 1; for (ll i = 1; i <= sqrt(q); i++) { if (q % i == 0) {...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2010 Xilinx, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // //...
/** * 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 nnext[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); } int main() { int n, m, k, idx, x, y, now, have, array[350][350]; cin >> n >> m >> k, x = y = 1, idx = now = have = 0; vector<...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s1, s2, s3; cin >> n; while (n--) { cin >> s1 >> s2 >> s3; for (int i = 0; i < s1.length(); i++) { if (s3.at(i) != s2.at(i) && s3.at(i) != s1.at(i)) { cout << NO n ; break; } ...
#include <bits/stdc++.h> using namespace std; void solve(string a, string b, int m, int n) { int lcs[m + 1][n + 1]; int result = 0; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0 || j == 0) lcs[i][j] = 0; else if (a[i - 1] == b[j - 1]) { ...
// (C) 2001-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 doc...
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int n, rec = 0; long long int k; cin >> n >> k; char str[1000005]; cin >> str; for (int h = 0; h < n; h++, rec++) { int pos = h; for (int i = h; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; template <typename T> istream& operator>>(istream& is, vector<T>& v) { for (T& x : v) is >> x; return is; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { for (int i = 0; i < (int)v.size(); i++) { os << v[i] << (i ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02/01/2016 12:02:10 PM // Design Name: // Module Name: Problem3 // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // R...
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m, x, y, T, ans, mx, mi, cas, num, len; bool flag; int p, a[25][105], b[25][105], c[25][105]; char s[1000]; int dp[1005]; int main() { scanf( %d%d%d , &n, &m, &p); for (i = 1; i <= n; i++) { scanf( %s , s); for (j = 1; j <= ...
#include <bits/stdc++.h> using namespace std; int n, k; bool ask(int x, int y) { if (x < 0 || y > n) return 0; string s; cout << 1 << << x << << y << endl; cin >> s; return s == TAK ; } int solve(int l, int r) { if (l > r) return -1; int mid; while (l < r) { mid ...
/* * Copyright (c) 2001 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; long long a1[1000007], b1[1000007]; int main() { long long n, i, j, k = 0; cin >> n; for (i = 0; i < n; i++) { string st; cin >> st; long long si = st.size(), c1 = 0, c2 = 0; for (j = 0; j < si; j++) { if (st[j] == ( ) { ...
/* * This module demonstrates the ability to use a defparam to control * the instantation of an instance array, and to also control * parameter values within the instance array. */ module main; localparam wid = 5; reg [wid-1:0] clk; if (wid > 0) begin : D dut xx (.clk(clk)); end // This def...
///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE revB.2 compliant I2C Master controller Top-level //// //// //// //// ...
/* * 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 edge { int u, v; long long g, s; bool operator<(const edge &cmp) const { return s < cmp.s; } } e[50005], a[50005]; int n, m, cnt, p[205], tam; long long gt, st; bool cmpG(edge a, edge b) { return a.g < b.g; } int find(int x) { if (p[x] =...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0; int d; for (int i = 0; i < n; i++) { cin >> d; sum += d; } int count = 5; for (int i = 1; i <= 5; i++) { if ((sum + i) % (n + 1) == 1) { count--; } } cout ...
#include <bits/stdc++.h> using namespace std; int a[55][55]; const int MAX = 1e3 + 5; const int INF = 0x3f3f3f3f; int color; int A[MAX][MAX]; int A1[MAX][MAX], A2[MAX][MAX]; int N; int DX[2] = {0, 1}, DY[2] = {1, 0}; int NOW1[4], NOW2[4]; int X1, Y1, X2, Y2; bool FLAG = false; bool VIS[MAX][MA...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // 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; either version 2 of the License...
/** * 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 q, w, e, r, t; char a[51]; cin >> a; if (a[0] == h ) { cout << http:// ; w = 4; } else { cout << ftp:// ; w = 3; } cout << a[w]; w++; while ((a[w] != r ) || (a[w + 1] != u )) { cout ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 1e5 + 100; vector<int> Prime; int main() { Prime.clear(); int n, k; scanf( %d%d , &n, &k); int flag = 1; for (int i = 2; flag && i <= n; i++) { if (n % i == 0) { while (n % i == 0) { Prime.push_back(i)...
#include <bits/stdc++.h> using namespace std; const int maxn = 1050; int n, m, g[maxn][maxn], ans[maxn][maxn]; int p[4] = {4, 3, 2, 1}; bool chk1(int x, int a, int b) { int i, st, c[2] = {a, b}; for (st = 0; st < m && !g[x][st]; st++) ; if (g[x][st] != c[0]) swap(c[0], c[1]); for (i = 0;...
// Motion in perpendicular plane will cause variations on the specific axis, note that this represent motion AROUND a specific axis // z-axis = side to side (short) // y-axis = side to side (long) // x-axis = vertical /* ---------------------------------|---------------------------------- ----------------------------...
// --------------------------------------------- // external memory controller // --------------------------------------------- // The CPU runs at ~50MHz (20ns) // // When accessing byte-wide external memory, sufficient wait states // need to be added to allow two slower memory cycles to happen // (low byte then high ...
#include <bits/stdc++.h> using namespace std; const long long int dx[] = {0, 1, -1, 0, 1, -1, -1, 1}; const long long int dy[] = {-1, 0, 0, 1, 1, 1, -1, -1}; long long int gcd(long long int x, long long int y) { return (y != 0 ? gcd(y, x % y) : x); } long long int lcm(long long int x, long long int y) {...
module nexys4 ( input clk, input btnCpuReset, input btnC, input btnU, input btnL, input btnR, input btnD, input [15:0] sw, output [15:0] led, output RGB1_Red, output RGB1_Green, output RGB1...
#include <bits/stdc++.h> using namespace std; double f(double x, double A, double B, double L) { double y = sqrt(L * L - x * x); return (A * x + B * y - x * y) / L; } int main(void) { double A, B, L; scanf( %lf%lf%lf , &A, &B, &L); if (L <= B) { printf( %.8f n , min(A, L)); retur...
#include <bits/stdc++.h> using namespace std; int main() { long long tt; cin >> tt; while (tt--) { long long n; cin >> n; vector<long long> v(n); for (auto &i : v) cin >> i; bool ans = false; for (size_t i = 0; i < n; i++) { if (v[i] >= v[i - 1]) { a...