text
stringlengths
59
71.4k
#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, ...
#include <bits/stdc++.h> using namespace std; int n; vector<pair<int, int>> moves_knight(int x, int y) { vector<pair<int, int>> v; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (abs(x - i) + abs(y - j) == 3 && abs(x - i) * abs(y - j) == 2) v.push_back({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; int a, b, c, Count = 1; int main() { cin >> a >> b >> c; if ((a + b > c) && (a + c > b) && (b + c > a)) { cout << 0 << endl; return 0; } while ((a + b < c) || (a + c < b) || (b + c < a)) { ++Count; if (a + b < c) { if (a...
/* This file is part of JT51. JT51 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 3 of the License, or (at your option) any later version. JT51 is distributed in the hope tha...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long k; cin >> k; if (k <= 36) { for (long long i = 1; i <= (k / 2); i++) { cout << 8; } if (k % 2 == 1) { cout << 4; } } else { cout...
#include <bits/stdc++.h> using namespace std; long double pi = 3.141592653589793238462643383279502884197; vector<long long int> v(14); void Compute() { for (long long int i = 1; i < 14; i++) { v[i] = pow(2, i) + v[i - 1]; } } void solve() { long long int n; cin >> n; long long int ...
`timescale 1ns/1ps // reference time = 1ns, precision value = 1ps `include "commands.vh" `define H_PERIOD 41.666 `define PERIOD 83.333 `define PERIOD10 833.33 module communication_tb; initial begin $dumpfile("communication.vcd"); $dumpvars(0, communication_tb); # $finish; // 1 100 000 000 ns = 1.1s end r...
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { int n, k, j, i, a[10001], s[1002], n1, n2, num[1002], h1, h2; double x, sum1, sum2, l, r, m; scanf( %d %d , &n, &k); h1 = 1000; h2 = 0; for (i = 0; i < n; i++) { cin >> a[i]; if (h1 > a[i]) h1 = a[i]...
`include "assert.vh" `include "cpu.vh" module cpu_tb(); reg clk = 0; // // ROM // localparam MEM_ADDR = 6; localparam MEM_EXTRA = 4; localparam STACK_DEPTH = 7; reg [ MEM_ADDR :0] mem_addr; reg [ MEM_EXTRA-1:0] mem_extra; reg [ MEM_ADDR :0] rom_lower_bound = 0; reg ...
/** * 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...
// (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...
/* * 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; template <class T> istream &operator>>(istream &in, vector<T> &arr) { for (T &i : arr) { in >> i; } return in; } template <class T> ostream &operator<<(ostream &in, vector<T> &arr) { for (T &i : arr) { in << i << ; } return...
// // Copyright 2011 Ettus Research LLC // // 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 3 of the License, or // (at your option) any later version. // // This program is dis...
#include <bits/stdc++.h> const double eps = (1e-5); using namespace std; int dcmp(long double a, long double b) { return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1; } long long getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1; } int setBit1(int num, int idx) { return num | (1 << idx); }...
// ----------------------------------------------------------------------------- // // Copyright 2013(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // - Redistrib...
#include <bits/stdc++.h> using namespace std; const int N = 210; int n, k, m; long long a[N]; int b[N]; int f[N][6010]; int ans = 0; int c[N], d[N]; int main() { scanf( %d%d , &n, &m); for (int i(1); i <= (n); ++i) scanf( %lld , a + i); for (int i(1); i <= (n); ++i) { for (; a[i] % 2...
#include <bits/stdc++.h> using namespace std; const int N = 300010; map<pair<int, int>, int> mp; struct point { int first, second; int l, r; point() {} point(int first, int second, int l, int r) : first(first), second(second), l(l), r(r) {} }; long long ans[N << 1]; long long sum; ...
#include <bits/stdc++.h> #define ll long long using namespace std; const ll N = 5005, MOD = 998244353; vector<vector<ll>> dp(N, vector<ll>(N)); vector<vector<int>> edges(N); vector<int> h(N); int n, k; void add(ll &x, ll y) { if((x += y) >= MOD) { x -= MOD; } } void dfs(int x, int p) { ...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a < b) swap(a, b); if (b == 0) return a; while (b) { long long int re = a % b; a = b; b = re; } return a; } vector<int> a[1000 + 10], b[1000 + 10]; vector<int> c1(1000 ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, k; cin >> n; long long int a[n], b[n], c[n]; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = 1; c[i] = 1; } long long int ans = 1; for (int i = 1; i < n; i++) { if (a[i] > a[i - 1]) b...
// Verilog netlist generated by Workcraft 3 module VME (d, lds, dtack, dsr, dsw, ldtack); input dsr, dsw, ldtack; output d, lds, dtack; wire U1_ON, IN_BUBBLE3_ON, IN_BUBBLE5_ON, U7_ON, IN_BUBBLE10_ON, OUT_BUBBLE1_ON, U14_ON, IN_BUBBLE16_ON, IN_BUBBLE18_ON, U20_ON, IN_BUBBLE23_ON, IN_BUBBLE25_ON, IN_BUBBLE28...
/** * 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...
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/versclibs/data/simprims/OBUFDS.v,v 1.6 2005/07/21 23:37:03 fphillip Exp $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // All Right Reserved. ////////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0); int main() { ios_base::sync_with_stdio(0); cin.tie(0); int q; cin >> q; while (q--) { int n, r; cin >> n >> r; set<int> s; vector<int> v; for (long long i = 0; i < n; i++) { int a...
module CPU( CLK, // Main clock // Wave function generators ROUT, COUT, A, // Address Bus D, // Data Bus. Serves as input/output // Interrupts RES, // Reset IRQ, // Interrupt-Request NMI, // Non-maskable Interrupt PHI2, WONE, // AKA $4016W.0 WTWO, // AKA $4016W.1 WTHREE,...
/** * 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> #pragma comment(linker, /STACK:200000000 ) using namespace std; const long long oo = 1LL << 60; const long long kNumMoves = 4; const long long kMoves[kNumMoves][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}}; struct Line { Line() : m(0), c(0) {} Line(long long slope, long long yOr...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int cnt = 0; int num; for (int i = 0; i != n; ++i) { scanf( %d , &num); if (num % 2 == 1) ++cnt; } if (cnt >= 1) printf( First n ); else printf( Second n ); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 5004; const int MAXNN = MAXN * 2 + 10; const int INF = 0x3f3f3f3f; struct Edge { int u, v, f, cap; Edge() { f = 0; } Edge(int uu, int vv, int cc) : u(uu), v(vv), f(0), cap(cc) {} inline int other(int w) { return w == u ? v : u; } ...
#include <bits/stdc++.h> using namespace std; vector<int> dijkstra(vector<vector<int>> &edges, int s) { vector<int> dist(edges.size(), 1e9); queue<int> pq; dist[s] = 0; pq.push(s); while (!pq.empty()) { auto u = pq.front(); pq.pop(); auto d = dist[u]; if (d == dist[u]) ...
#include <bits/stdc++.h> using namespace std; inline long long in() { int32_t x; scanf( %d , &x); return x; } const long long maxn = 1e5 + 10; const long long mod = 1e9 + 7; const long long inf = 1e9 + 10; long long pref[2][maxn], pref2[maxn]; long long maxDp[maxn], minDp[maxn]; int32_t ma...
#include <bits/stdc++.h> int a, b, i, j, n; std::string s; bool isgood(int n) { int i; for (i = 2; i < n; i++) if (n % i == 0) return false; return true; } void sol() { if (!isgood(b)) { printf( NO ); return; } for (i = a + 1; i < b; i++) if (isgood(i)) { ...
/* Distributed under the MIT license. Copyright (c) 2017 Dave McCoy () 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, mo...
#include <bits/stdc++.h> using namespace std; int main() { int n, page; cin >> n; vector<int> pages(7); for (int i = 0; i < 7; i++) { cin >> page; pages[i] = page; } int ans = 0; while (true) { n -= pages[ans]; if (n <= 0) { break; } ans = (ans...
/* * 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...
// -- (c) Copyright 2011 - 2012 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...
`timescale 1us/100ns module fifo( output [7:0] dout, output indicator, // Indicates a state change. input [7:0] din, input din_valid, input clk, input reset_n ); parameter SIZE = 20, INDEX_WIDTH = 8, MAX_INDEX = SIZE * 8 - 1; localparam WAITING = 0, RECEIVING =...
#include <bits/stdc++.h> using namespace std; long long n, m, k, x, i, sum, j, r = 1, B[20][20]; char A[20][20]; int main() { cin >> n >> m; for (i = 0; i < n; i++) { cin >> x; sum += x; } if (sum == 0) cout << 0; else { if (abs(sum) <= m) cout << 1 ; e...
module cache_tb(); reg clk, rst_n, i_acc, d_rd_acc, d_wr_acc; reg [15:0] i_addr, d_addr, d_wrt_data; wire stall; wire [15:0] instr, data; MemoryHierarchy mem(clk, rst_n, i_acc, d_rd_acc, d_wr_acc, i_addr, d_addr, d_wrt_data, stall, instr, data); initial begin clk = 1'b0; rst_n = 1'b0; i_acc = 1'b0; ...
#include <bits/stdc++.h> using namespace std; int L = 2e5; vector<vector<int>> g(L); vector<int> dp(L), d(L, 0), par(L, -1); vector<bool> used(L); int dist; int ask1(int u) { cout << d << u + 1 << endl; int t; cin >> t; if (t == -1) { while (true) { } } return t; }...
/** * This is written by Zhiyang Ong * for EE577b Extra Credit Homework , Question 2 * * Behavioral model for the Hamming encoder */ module ham_15_11_encoder (input d[10:0],output c[14:0]); // Output signals representing the 15-bit encoded vector output reg [14:0] c; // Input signals representing the 15-bi...
#include <bits/stdc++.h> using namespace std; int t, i, j, n, r, it, cc, best, u[22], msk[22], bc[1100100], ok[1100100]; bool c[22][22]; char a[100100], b[100100]; void dfs(int i) { u[i] = it; for (int j = 0; j < 20; j++) if ((c[i][j] || c[j][i]) && u[j] != it) dfs(j); } int main() { sca...
`timescale 1ns/1ps `define DATA_WIDTH 8 module top(); reg [4:0] checker_enable_reg = 5'b11111; wire reset_n_wire; wire opcode_valid_wire; wire opcode_wire; wire [`DATA_WIDTH-1:0] data_wire; wire done_wire; wire [`DATA_WIDTH-1:0] result_wire; wire overflow_wire; wire clk_wire; reg int_clk; initial...
// DEFINES `define BITS 2 // Bit width of the operands module bm_dag3_log_mod(clock, reset_n, a_in, b_in, c_in, d_in, out0, out1); // SIGNAL DECLARATIONS input clock; input reset_n; input [`BITS-1:0] a_in; input [`BITS-1:0] b_in; input c_in; input d_in; output [`BITS-1:0] out0; output ...
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, l, r; cin >> t; while (t--) { cin >> n; r = n; l = (-1) * (n - 1); cout << l << << r << n ; } return 0; }
//Legal Notice: (C)2016 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; struct Node { long long x, y; } Edge[300005]; long long pre[300005]; bool cmp(Node a, Node b) { return a.y > b.y; } int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %lld%lld , &Edge[i].x, &Edge[i].y); } ...
module VGA_Ctrl ( // Host Side iRed, iGreen, iBlue, oCurrent_X, oCurrent_Y, oAddress, oRequest, // VGA Side oVGA_R, oVGA_G, oVGA_B, oVGA_HS, oVGA_VS, oVGA_SYNC, oVGA_BLANK, oVGA_CLOCK, // Control Signal iCLK, ...
#include <bits/stdc++.h> using namespace std; struct node { int x, y, f; char na; } f[30]; bool cmp(node a, node b) { return a.na < b.na; } char s[1005][1005]; int s1[1005][1005]; int s2[1005][1005]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %s...
`timescale 1ns / 1ps module gost89_ecb_tb; reg clk; always #1 clk = ~clk; reg [511:0] sbox = 512'h 4a92d80e6b1c7f53eb4c6dfa23810759581da342efc7609b7da1089fe46cb2536c715fd84a9e03b24ba0721d36859cfedb413f590ae7682c1fd057a4923e6b8c; reg [255:0] key = 256'h 0475f6e05038fbfad2c7c390edb3ca3d1547124291ae1e8a2f...
#include <bits/stdc++.h> using namespace std; const int N = 200 * 1000 + 85; int n, m; int a[N]; vector<int> vec[N]; pair<pair<int, int>, int> b[N]; int mapp[N]; int ans[N]; int seg[N << 2]; inline void add(int, int, int = 1, int = 0, int = N); inline int get(int, int = 1, int = 0, int = N); int...
#include <bits/stdc++.h> using namespace std; pair<long long, long long> a[100100]; vector<long long> v, v2; int main() { int n, i; cin >> n; long long Answer = 0; for (i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; v.push_back(a[i].first); v2.push_back(a[i].second); ...
module InstructionDecode(instr, clk, hlt, writeAddr, writeData, writeEnable, p0, p1, imm, p0Addr, p1Addr, regAddr, shamt, aluOp, branchOp, regWe, memRe, memWe, addz, branch, jal, jr, aluSrc0, aluSrc1, ovEn, zrEn, neEn); input [15:0] instr; // For register writeback input clk, hlt; input [15:0] writeData; ...
// 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 : Wed Oct 18 15:15:21 2017 // Host : TacitMonolith running 64-bit Ubuntu 16.04.3...
#include <bits/stdc++.h> using namespace std; int n; char s1[51], s2[51], op[50][5]; int memo1[50][50][26], memo2[50][50][26], memo3[50][50]; int check1(int l, int r, char c) { if (l == r) return s1[l] == c; int &ret = memo1[l][r][c - a ]; if (ret == -1) { ret = 0; for (int i = l; i <...
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009, 2010 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 distri...
////////////////////////////////////////////////////////////////////// //// //// //// dbg_sync_clk1_clk2.v //// //// //// //// This file is part of the SoC/O...
////////////////////////////////////////////////////////////////////////////// /// Copyright (c) 2012, Jahanzeb Ahmad /// All rights reserved. /// /// Redistribution and use in source and binary forms, with or without modification, /// are permitted provided that the following conditions are met: /// /// * Redistribu...
#include <bits/stdc++.h> using namespace std; long long n, k, ans; bool chk_odd(long long lim) { long long get = 0, bas = 1, val = lim * 2 + 1; for (int i = 1; i <= 60; ++i, bas *= 2) { long long start = val * bas; if (start > n) break; get += min(bas, n - start + 1); } return ge...
///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE AC 97 Controller //// //// Serial Output Block //// //// ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 9; int a[MAX_N]; void mergesort(int l, int r, int &k, int &remain) { if (k > 0 && r - l > 1) { k -= 2; int m = (l + r) / 2; mergesort(l, m, k, remain); mergesort(m, r, k, remain); } else { int c = r - l; ...
#include <bits/stdc++.h> int main() { long n(0); scanf( %ld , &n); const long maxSquare = n * n; int total(0); for (long a = 1; a < n; a++) { for (long b = a; b < n; b++) { long sumOfSquares = a * a + b * b; if (sumOfSquares > maxSquare) { break; } 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...
/* * Copyright (c) Atomic Rules LLC, Auburn NH., 2009-2010 * * Atomic Rules LLC * 287 Chester Road * Auburn, NH 03032 * United States of America * Telephone * * This file is part of OpenCPI (www.opencpi.org). * ____ __________ ____ * / __ \____ ___ ____ / ____...
// // Copyright (C) 2009-2012 Chris McClelland // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This ...
#include<bits/stdc++.h> #define fo(i, n) for(int i=0; i<n; i++) #define boost ios::sync_with_stdio(false); cin.tie(0) #define ll long long int using namespace std; int main() { boost; int t; cin>>t; while(t--){ int n, max_freq = 0, i; cin>>n; map<int, int> m; f...
/* * 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, X; int main() { scanf( %d%d , &N, &X); string s; if (N == 5) s += >...v nv.<.. n..^.. n>.... n..^.< n1 1 ; else if (N == 3) s += >vv n^<. n^.< n1 3 ; else if (N == 100) s += v.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<....
#include <bits/stdc++.h> using namespace std; long long jc[210000], ny[210000]; char s[210000]; int n, f[210000], g[210000], ans; int C(int n, int m) { if (m > n) return 0; return jc[n] * ny[m] % 1000000007 * ny[n - m] % 1000000007; } int main() { scanf( %s , s + 1); n = strlen(s + 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 law...
#include <bits/stdc++.h> using namespace std; double dis(double ax, double ay, double bx, double by) { return sqrt(pow(ax - bx, 2) + pow(ay - by, 2)); } bool f(double a, double b, double c) { if (a == sqrt(pow(b, 2) + pow(c, 2))) return true; else return false; } int main() { cou...
/** * 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; bool sum(int num) { int ssum = 0; while (num > 0) { ssum = ssum + num % 10; num = num / 10; } if (ssum == 10) { return true; } else { return false; } } int main() { int test, num = 19; cin >> test; while (t...
#include <bits/stdc++.h> using namespace std; double pi = 2 * acos(0.0); template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << { ; for (const auto &x : v) os << << x; return os << } ; } void solve() { long long int l, r, m; cin >> l >> r >> m; long ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer _mode; reg _guard1; reg [127:0] r_wide0; reg _guard2; wir...
#include <bits/stdc++.h> using namespace std; const int N = 255; double f[N][N * N]; int x, k, p; int main() { scanf( %d%d%d , &x, &k, &p); for (int i = 0; i <= k; i++) { int xx = x + i, cnt = 0; while (xx % 2 == 0) { xx /= 2; cnt++; } f[0][i] = cnt; } f...
#include <bits/stdc++.h> const int max_n = 150; const unsigned int lowest = 31; const int size = (max_n >> 5) + 1; struct row { unsigned int bits[size]; void set_bit(unsigned int j) { bits[j >> 5] |= (1 << (j & lowest)); } bool get_bit(unsigned int j) { return ((bits[j >> 5] >> (j & lowest)) &...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } 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 la...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; long long mulmod(long long a, long long b, long long MOD) { if (b == 0) return 0; long long res = mulmod(a, b >> 1, MOD); res += res; res %= MOD; return (b & 1) ? (a + res) % MOD : res; } int gcd(int ...
#include <bits/stdc++.h> using namespace std; int dp[1002][20002]; int main() { ios_base::sync_with_stdio; int n, m, x, y, i, j, a; cin >> n; long long ans = 0; for (i = 1; i <= n; i++) { cin >> a; dp[i][10000 + a]++; dp[i][10000 - a]++; for (j = 0; j < a; j++) { ...
#include <bits/stdc++.h> using namespace std; template <class T> istream& operator>>(istream& is, vector<T>& v) { for (T& x : v) is >> x; return is; } template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { if (!v.empty()) { os << v.front(); for (int i = 1; i < v.si...
// Name: WcaDCOffset.v // // Copyright(c) 2013 Loctronix Corporation // http://www.loctronix.com // // 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 Licen...
#include <bits/stdc++.h> using namespace std; bool SR(int &x) { return scanf( %d , &x) == 1; } bool SR(long long &x) { return scanf( %lld , &x) == 1; } bool SR(double &x) { return scanf( %lf , &x) == 1; } bool SR(char *s) { return scanf( %s , s) == 1; } bool RI() { return true; } template <typename I, typ...
// (C) 2001-2011 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...
/** * 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 T1, typename T2> void chkmin(T1 &x, T2 y) { if (x > y) x = y; } template <typename T1, typename T2> void chkmax(T1 &x, T2 y) { if (x < y) x = y; } inline void debug(int x) { fprintf(stderr, ycx has aked ioi %d times n , x); } na...
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e3 + 10, MOD = 1e9 + 7; int n, ans, l = -1, r = 1e4 + 10, mid, mark[MAXN]; pair<int, int> a[MAXN]; bool first; vector<int> adj[MAXN]; inline int Dis(int i, int j) { return abs(a[i].first - a[j].first) + abs(a[i].second - a[j].second); }...
#include <bits/stdc++.h> using namespace std; int main(void) { int n, m; int i = 0, tmp; int P, Q; cin >> n >> m; i = n; cin >> P; while (i--) { cin >> tmp; } cin >> Q; i = m; while (i--) { cin >> tmp; } int sm = 1, sn = 1; if (P < 0) sn = -1; ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 06:30:43 09/25/2013 // Design Name: Main_Module // Module Name: C:/Users/Fabian/Documents/GitHub/taller-diseno-digital/Lab3/laboratorio3/test_main.v // Project Name: ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 1e5 + 10, mod = 1e9 + 7; long long a[maxn], d[maxn]; bool mark[maxn]; long long dfs(int v, int p) { mark[v] = 1; if (v == p) return 0; if (mark[a[v]]) return -1; int k = dfs(a[v], p); return (k == -1 ? -1 : k + 1); } in...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:46:09 02/22/2015 // Design Name: // Module Name: SpecialAdd // Project Name: // Target Devices: // Tool versions: // Description: // // Depe...
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, cnt = 0; cin >> n; int a[n + 1][n + 1]; vector<int> v; vector<int> v1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } int no = 0; for (int i = 0; i < n;...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b > a) { return gcd(b, a); } if (b == 0) { return a; } return gcd(b, a % b); } long long expo(long long a, long long b, long long mod) { long long res = 1; while (b > 0) { if...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 06/14/2017 09:30:41 AM // Design Name: // Module Name: Msg_In // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Rev...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, t, cnt = 0, flag, cs = 1; pair<int, int> A[110]; scanf( %d %d , &j, &k); for (i = 0; i < j; i++) { scanf( %d , &A[i].first); A[i].second = i + 1; } sort(A, A + j); vector<int> v; int sum = 0; for ...
#include <bits/stdc++.h> using namespace std; const int N = (int)1e3 + 5; const int INF = (int)1e9 + 7; int x[N], y[N]; int n; map<pair<int, int>, int> id; vector<pair<int, int> > g[2][2]; int dist(int i, int j) { return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]); } void calc(...