text
stringlengths
59
71.4k
// file: clk_wiz_v3_6.v // // (c) Copyright 2008 - 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...
#include <bits/stdc++.h> using namespace std; long n, s[1 << 10]; vector<long> v[1 << 10]; long spre, slim, found; long trem, tail; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> s[i]; for (int j = 0; j < 666; j++) v[i].push_back(0); } ...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e6 + 10; long long a[maxn], sum[maxn], n, m, big = 0, tmp; int main() { scanf( %lld , &n); for (int i = 0; i < n; i++) { scanf( %lld , &m); a[m]++; big = max(big, m); } for (int i = 0; i <= big; i++) { for (i...
//datae:2016/3/20 //engineer:zhaoshaomin //module name: return address stack which is used to predict indirect branch target , // in MIPS such as JR or JALR(which i didn't implemente) module core_ras(//input clk, rst, //inst fetch stage prediction...
/* Copyright (c) 2014 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; pair<long long, long long> a[1000005]; bool fl1, fl2, fl3, fl4; long long dist(pair<long long, long long> a, pair<long long, long long> b) { return abs(a.first - b.first) + abs(a.second - b.second); } signed main() { ios_base::sync_with_stdio(false); ...
`define GLBL module prbs_gen ( input ck, input rst, input i_req, output o_rdy, output o_vld, output [63:0] o_res_lower, output [63:0] o_res_upper ); reg r_init_active; reg [6:0] r_init_cnt; reg r_init_done; always @(posedge ck) begin if (rst) begin r_init_active <= 1'b0; ...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017 // Date : Wed Sep 20 21:13:47 2017 // Host : EffulgentTome running 64-bit major rele...
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const int maxn = 21; const int dx[4] = {0, 0, 1, -1}; const int dy[4] = {1, -1, 0, 0}; int Map[maxn][maxn], Value[maxn], X[maxn], Y[maxn], XX[maxn], YY[maxn]; int vis[maxn][maxn][260][129], VV[maxn][maxn][260][129], inq[maxn][...
// (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; long long cal(long long x) { return (x + 1) * (x + 2) >> 1; } int main() { int a, b, c, l; while (scanf( %d%d%d%d , &a, &b, &c, &l) != EOF) { long long ans = 0; for (int i = 0; i <= l; i++) ans += 1LL * (i + 1) * (i + 2) / 2; for (long long i...
#include <bits/stdc++.h> using namespace std; int ost(int k, int res) { int ans = 0; while (k < (double)res / 2) { ans++; k *= 2; } return ans; } int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 5; const long long MOD = 1e9 + 7; const long long INF = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x, y; cin >> n >> x >> y; set<double> s; int count = 0; while (n--) ...
`timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit must be 1 10 or 100 * -base is the time base for each unit, ranging from seconds * to femtoseconds, and must be:...
// ================================================================== // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< // ------------------------------------------------------------------ // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // --------...
`include "../module/controller.v" // Controller testbench: Supplies test vectors and dumps the results to file and // standard output. Do not modify! module controller_tb; reg ph1, ph2, reset; reg [5:0] opcode; reg zero; wire memread; wire memwrite; wire [3:0] irwrite; wire pcen; wir...
#include <bits/stdc++.h> using namespace std; int a[2 * 50004]; int main(void) { int n, k; cin >> n >> k; for (int i = 1; i <= 2 * n; i++) { a[i] = i; } for (int i = 1; i <= k; i++) { swap(a[2 * i], a[2 * i - 1]); } for (int i = 1; i <= 2 * n; i++) { cout << a[i] << ...
module scratch_pad_synthesis(clk, in, out, sel); parameter PORTS = 8; parameter WIDTH = 64; parameter FRAGMENT_DEPTH = 512; parameter REORDER_DEPTH = 32; parameter FIFO_DEPTH = 32; parameter REORDER_BITS = log2(REORDER_DEPTH-1) + 1; parameter DEPTH = FRAGMENT_DEPTH * PORTS; parameter ADD...
/* * 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> long long mod = 1000000007; using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } void solve() { long long n; cin >> n; vector<long long> a(n); priority_queue<pair<long long, long long> > pq; for (int i...
#include <bits/stdc++.h> using namespace std; long long int ara[1000000]; int wow[7 * 22000]; void make_wow(int x) { int xx; int l; int k = 1; stack<int> s; for (int i = 1; i <= x; i++) { xx = i; while (xx != 0) { l = xx % 10; xx /= 10; s.push(l); } ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const ll INF = 1e16 + 2; signed main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); vector<pair<ll, ll>> pts; pts.emplace_back(); ll ax, ay, bx, by; cin >> pts[0].first >> pts[0]....
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Case Western Reserve University // Engineer: Matt McConnell // // Create Date: 22:29:00 09/09/2017 // Project Name: EECS301 Digital Design // Design Name: Lab #4 Project // Module Name: ...
// megafunction wizard: %FIFO%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: gsensor_fifo.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // ==========================...
module single_register(datain, dataout, clk, clr, WE); input [31:0] datain; output [31:0] dataout; input clk, clr, WE; reg [31:0] register; always @(posedge clk or posedge clr) begin if(clr) register = 0; else if(WE == 1) register = datain; end assign dataout = register; endm...
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; if (k == 1) { cout << Yes << endl; return; } vector<int> divs; for (int i = 2; i < k; ++i) if (!(k % i)) { cerr << i << endl; divs.push_back(1); while (!(k % i)) ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long inf = (1LL << 60); const double pi = acos(-1); long long powmod(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; ...
/*! * <b>Module:</b>drp_other_registers * @file drp_other_registers.v * @date 2016-03-13 * @author Andrey Filippov * * @brief Additional registers controlled/read back over DRP * * @copyright Copyright (c) 2016 Elphel, Inc . * * <b>License:</b> * * drp_other_registers.v is free software; you can redist...
(** Extraction : tests of optimizations of pattern matching *) (** First, a few basic tests *) Definition test1 b := match b with | true => true | false => false end. Extraction test1. (** should be seen as the identity *) Definition test2 b := match b with | true => false | false => false end. Ext...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// file: clk_wiz_1.v // // (c) Copyright 2008 - 2013 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 ...
// ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014,2015,2016 // // NMI generation /* 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 Public ...
/** * 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 a[105][105], v[105][105], dp[105][105]; long long slove(int x, int y, int n, int m) { long long t = a[x][y] - (x + y - 2); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { v[i][j] = a[i][j] - (t + i + j - 2); } } ...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; bool isprime(int a) { for (int i = 2; i <= sqrt((double)a); i++) { if (a % i == 0) return false; } return true; } int main() { int n; cin >> n; if (n <= 7) cout << 1 << endl << n; else { ...
#include <bits/stdc++.h> using namespace std; int main() { int t = 0, counterarr[3] = {5, 7, 5}, c = 0; string x; bool arr[3] = {}; while (t < 3) { getline(cin, x); for (int i = 0; i < x.length(); i++) { if (x[i] == a || x[i] == e || x[i] == u || x[i] == i || ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, x; int A[200010] = {0}, L[200010] = {0}, R[200010] = {0}; scanf( %d%d%d , &n, &k, &x); for (int i = 1; i <= n; i++) { scanf( %d , A + i); } sort(A + 1, A + 1 + n); for (int i = 1; i <= n; i++) { L[i] = A[i] ...
#include <bits/stdc++.h> const long long int MOD = 1000000007ll; const int mxsz = 200005; using namespace std; int main() { std::ios_base::sync_with_stdio(false); long long int n, m, a; cin >> n >> m >> a; int ar1[n + 1], ar2[m + 1]; for (int i = 1; i <= n; i++) { cin >> ar1[i]; } ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, vmx; long long seed; struct node { int l, r; mutable long long val; bool operator<(const node &x) const { return l < x.l; } }; set<node> tr; set<node>::iterator split(int pos) { set<node>::iterator iter = tr.l...
#include <bits/stdc++.h> using namespace std; const int maxn = 100; int a[maxn], s[maxn], f[maxn], n, ans; int pmin, pmax; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , a + i), f[i] = -1; sort(a, a + n); swap(a[0], a[n - 1]); for (int i = 0; i < n; i++) printf( %d ...
// generated by gen_VerilogEHR.py using VerilogEHR.mako // Copyright (c) 2019 Massachusetts Institute of Technology // 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...
/** * 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 inf = 0x3f3f3f3f; const double eps = 1e-6; const long long mod = 1000000007; inline string getstr(string &s, long long l, long long r) { string ret = ; for (long long i = l; i <= r; i++) ret.push_back(s[i]); return ret; } long lon...
#include <bits/stdc++.h> int n, m, k; char s[2505][2505]; long long a[2505][2505]; inline long long sum(int r1, int c1, int r2, int c2) { return a[r2][c2] - a[r1 - 1][c2] - a[r2][c1 - 1] + a[r1 - 1][c1 - 1]; } inline long long go(int r1, int c1, int r2, int c2) { if (r1 == r2 && c1 == c2) return sum...
// (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; string s; int ans, pre, cnt; int main() { cin >> s; for (int i = 0; i < s.size(); i++) { pre += s[i] - 0 ; cnt++; if (cnt == 3 || (s[i] - 0 ) % 3 == 0 || pre % 3 == 0) ans++, pre = 0, cnt = 0; } cout << ans << endl; re...
#include <bits/stdc++.h> using namespace std; inline int read() { int ans = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) ch = getchar(); while (ch >= 0 && ch <= 9 ) ans = (ans << 1) + (ans << 3) + (ch ^ 48), ch = getchar(); return ans; } inline long long L_read() { long ...
#include <bits/stdc++.h> using namespace std; int addOne(int x) { return x + 1; } int main() { int a, b; cin >> a >> b; while (b) { a = addOne(a); b--; } cout << a << endl; }
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b); long long int gcd(long long int a, long long int b); int prime(int n); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t = 1; while (t...
#include <bits/stdc++.h> using namespace std; void dbg() { std::cout << # n ; } template <typename T, typename... Args> void dbg(T a, Args... args) { std::cout << a << ; dbg(args...); } const long long maxn = 2e5 + 10; const long long MAX = 1000; const long long inf = 0x3f3f3f3f; const 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; int main() { int t; cin >> t; while (t-- > 0) { int n, m; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int i = 0, t = 0, f = 0; while (i < n - 1) { if (a[0] != 1) { f = 1...
#include <bits/stdc++.h> const int INF = 1000000; using namespace std; int main() { int a, b, m; vector<int> r(1); scanf( %d %d %d %d , &a, &b, &m, &r[0]); for (int i = 1; i < 2 * m + 2; i++) { r.push_back((a * r[i - 1] + b) % m); } vector<int> ans(2 * m + 2, INF); int res = 1; ...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
#include <bits/stdc++.h> using namespace std; int a[1500][1500]; int visited[1500][1500]; int n, m; struct node { int x, y; }; node vis[1500][1500]; int main() { int sx, sy; char x; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { scanf( n ); for (int j = 0; j < m; j...
`timescale 1ns / 1ps /* Group Members: Kevin Ingram and Warren Seto Lab Name: Traffic Light Controller (Lab 3) Project Name: eng312_proj3 Design Name: Traffic_Test_E_eng312_proj3.v Design Description: Verilog Test Bench to Implement Test E (1 PM) */ module Traffic_Test; // Inputs ...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; int main() { string s; cin >> s; int index = s.size() - 1; vector<char> din3(s.size(), 0); vector<char> din2(s.size(), 0); if (index - 2 >= 5) din3[index - 2] = 1; if (index - 1 >= 5) din2[index - 1] = 1; ind...
#include <bits/stdc++.h> using namespace std; int main() { int k1, k2, k3, count[6], min_elt = INT_MAX; memset(count, 0, sizeof(count)); scanf( %d%d%d , &k1, &k2, &k3); count[k1 >= 5 ? 5 : k1]++; count[k2 >= 5 ? 5 : k2]++; count[k3 >= 5 ? 5 : k3]++; min_elt = min(k3, min(k1, k2)); if...
#include <bits/stdc++.h> using namespace std; int n, m; long long f[305][305][5]; struct point { int x, y; point(int x = 0, int y = 0) : x(x), y(y) {} } a[305]; struct edge { int u, v; double w; edge(int u = 0, int v = 0, double w = 0) : u(u), v(v), w(w) {} bool operator<(const edge ...
#include <bits/stdc++.h> using namespace std; int n, m; int team[101]; char c[101]; int dp[21][(1 << 20) + 5]; int a[1001]; int solve(int pos, int mask) { if (pos == n) return 0; if (dp[pos][mask] != -1) return dp[pos][mask]; int ans; if (team[pos] == 1) { ans = -(1 << 30); 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...
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const long long LINF = LLONG_MAX; int main() { std::ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; vector<int> a(n, 0); int ind = 0, length = n + 1; for (int i = 0; i < m; i++) { int l, r; cin ...
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-13; int ROUND(double x) { return (int)(x + 0.5); } bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; } bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); } double SQSUM(double...
/** * 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...
/** * This is written by Andrew Mattheisen * and Zhiyang Ong */ module conv_encoder (output [1:0] c, input b, input clk, input reset); // Output signals for the design module // Input signals for the design module // Declare "reg" signals... // Output bus that will be assigned values reg [1:0] c; /* ...
/* * 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 f(vector<int>& a, int x) { if (a[x] == x) return x; a[x] = f(a, a[x]); return a[x]; } bool mer(vector<int>& a, int x, int y) { if (f(a, x) == f(a, y)) return true; else return false; } void uni(vector<int>& a, int x, int y) { ...
/** * 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...
//------------------------------------------------------------------- //-- inv_tb.v Banco de pruebas para el inversor //------------------------------------------------------------------- //-- (c) BQ August 2015. Written by Juan Gonzalez //------------------------------------------------------------------- //-- GPL LI...
#include <bits/stdc++.h> using namespace std; int main() { string s; static int x[27]; int n, k; cin >> n >> k; cin >> s; for (int i = 0; i < k; i++) { char r; cin >> r; x[r - a ] = 1; } long long res = 0, tr = 0; for (int i = 0; s[i]; i++) { if (x[s[i] -...
#include <bits/stdc++.h> using namespace std; int main() { long long t, a, b; cin >> t; while (t--) { cin >> a >> b; int f = 0; long long area = a * a - b * b; if ((a - b) != 1) cout << NO ; else { area = a + b; for (int i = 2; i <= sqrt(a + b); i++...
`timescale 1ns / 100ps // File name : p3hw3fall2015DataUnit.v // Jianjian Song // Data Unit of a 4-bit serial multiplier with adder and shift regissters module DataUnit(Product, Multiplicant, Multiplier, Shift1, Shift0, reset, clock); input clock, reset; input [3:0] Multiplicant, Multiplier; input [2:0] Shift1, Shi...
#include <bits/stdc++.h> using namespace std; int T; long long r, b, k, g; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { scanf( %d , &T); while (T--) { scanf( %lld%lld%lld , &r, &b, &k); if (r > b) swap(r, b)...
`ifdef __ICARUS__ `define SUPPORT_CONST_OUT_OF_RANGE_IN_IVTEST `endif module top; reg pass; reg [2:0] res [0:7]; reg [2:0] in [0:7]; reg [7:0] dummy [0:6]; time run_time [0:7]; time exp_time [0:7]; integer i; initial begin pass = 1'b1; #1; // Initialize the input array. for (i=0; i<8...
#include <bits/stdc++.h> using namespace std; int n, k, n1, ans, m, per1, per2, add; const int maxn = 1000007; long long tree[maxn * 4][4]; void build() { for (int j = n1 - 1; j < n1 + n - 1; j++) { tree[j][0] = j - n1 + 2; tree[j][1] = j - n1 + 2; tree[j][2] = 0; tree[j][3] = 0; ...
#include <bits/stdc++.h> const int N = 500500; std::vector<int> g[N]; int d[N]; int n, maxM, maxD; void go(int cur, int par = -1, int dist = 0) { if (dist > maxD) maxD = dist; bool f = false; for (auto v : g[cur]) if (v != par) { go(v, cur, dist + 1); f = true; } if...
/* * 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...
#include <bits/stdc++.h> using namespace std; const int N = 1000; int dist[N * N], memo[N * N]; vector<pair<int, int>> H, T; vector<int> ladj[N * N]; int vis[N * N]; inline int f(int x, int y) { return x * N + y; } int bfs(int start) { int n = N * N; fill(dist, dist + n, INT_MAX); fill(memo,...
#include <bits/stdc++.h> char buf[1 << 21], *p1 = buf, *p2 = buf; using namespace std; template <class T> void rd(T &k) { char c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++); int f = 1; k = 0; while (c < 0 || c > 9...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:43:32 09/23/2013 // Design Name: // Module Name: Data_Parameters // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies...
#include <bits/stdc++.h> using namespace std; struct problem { int score1, score2; int time1, time2; double fail; long long expscore1, expscore2; double ratio; }; int N, T; problem P[1010]; long long dpscore[1010][1600]; double dppenal[1010][1600]; void update(int n, int t, long long...
#include <bits/stdc++.h> using namespace std; int n, m, c, a, b; int main() { scanf( %d , &n); while (n--) { scanf( %d%d , &a, &b); if (a != b) if (a > b) m++; else c++; } if (m != c) if (m > c) printf( Mishka ); else prin...
/////////////////////////////////////////////////////////////////////////////// // vim:set shiftwidth=3 softtabstop=3 expandtab: // // Module: unused_reg.v // Project: NetFPGA // Description: Unused register block // /////////////////////////////////////////////////////////////////////////////// module unused...
#include <bits/stdc++.h> using namespace std; const int N = 100100; const int BIT = 17; int n, m; int P[N]; int pot2[33]; set<int> S[18]; set<int>::iterator it; long long sol; inline int find(int bit, int pos) { if (S[bit].empty()) return 0; it = S[bit].lower_bound(pos); if (it == S[bit]...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int a; cin >> a; string s; cin >> s; map<int, int> Freq; for (int i = 0; i < s.size(); i++) { int sum = 0; bool zero = false; for (int j = i; j < s.size(); ...
#include <bits/stdc++.h> using namespace std; int x[7]; int y[7]; bool inside1(float x1, float y1) { if (x1 + .5 >= x[3] && x1 + .5 <= x[4] && y1 + .5 >= y[3] && y1 + .5 <= y[4]) return 1; return 0; } bool inside2(float x1, float y1) { if (x1 + .5 >= x[5] && x1 + .5 <= x[6] && y1 + .5 >= y...
/** * 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; string a, ar, b, fi; int i, j, ans, o1[3000], o2[3000]; int main() { ios_base::sync_with_stdio(0); cin >> a >> b; ar = a; reverse(ar.begin(), ar.end()); for (; i < b.size(); ++i) { if (a.find(b[i]) == string::npos) { cout << -1 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...
#include <bits/stdc++.h> using namespace std; multimap<long long int, long long int> par; char en = n ; long long int inf = pow(10, 14); long long int mod = 1e9 + 7; long long int parent[2][500005]; long long int findRoot(long long int a, long long int which) { if (parent[which][a] == a) return a; ...
#include <bits/stdc++.h> using namespace std; long long fpm(long long b, long long e, long long m) { long long t = 1; for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0; return t; } template <class T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; } template <...
module fetch (clk, stall, busy, pc, rw, access_size, enable, j_addr, jump, br_addr, branch); parameter START_ADDR = 32'h8002_0000; // input input clk; input stall; input busy; input [31:0] j_addr; input jump; input [31:0] br_addr; input branch; // output output [31:0] pc; outpu...
#include <bits/stdc++.h> using namespace std; const int MOD(1000000007); const int INF((1 << 30) - 1); const int MAXN(); map<string, int> d; int main() { d[ void ] = 0; int n; scanf( %d , &n); for (int i = 0; i < n; i++) { string a, b, c; cin >> a; if (a == typedef ) { ...
#include <bits/stdc++.h> using namespace std; int output(int n) { int sum = 0; while (n != 1) { int i; for (i = 2; i * i <= n; i++) if (n % i == 0) { sum += n; n /= i; break; } if (i * i > n) { sum += n; break; } } ...
#include <bits/stdc++.h> using namespace std; void solve() { string ss, tt; cin >> ss >> tt; int l = ss.size(); vector<int> s(30); vector<int> t(30); for (int i = 0; i < l; i++) { s[ss[i] - a ]++; t[tt[i] - a ]++; } bool ok = false; for (int i = 0; i < s.size(); i++...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; double sqrDist(double x1, double y1, double x2, double y2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); } double dist(double x1, double y1, double x2, double y2) { return sqrt(sqrDist(x1, y1, x2, y2)); } const double...
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,avx ) using namespace std; const int MAXSIZE = 10000020; int bufpos; char buf[MAXSIZE]; void init() { buf[fread(buf, 1, MAXSIZE, stdin)] = 0 ; bufpos = 0; } int readint() { int val = 0; for (; !isdigit(buf[bufpos]); ...
#include <bits/stdc++.h> using namespace std; const long long nmax = (long long)1e6 + 10; inline long long up(char ch) { return z - ch; } inline long long lo(char ch) { return ch - a ; } inline long long eq(char ch) { return 1; } long long dp[2002][2002]; long long tmp[2002]; signed main() { ios_...