text
stringlengths
59
71.4k
module BarrelShifter(input [31:0] Rs,Rm,IR,input SR29_IN,output SR29_OUT,output [31:0] Out); /* Data processing immediate IR[27:25] == 000 & IR[4] = 0/ IR[6:5] Shiftype / IR[11:7] Shift Amount/ Shift val Rm Data register shift IR[27:25] == 000 / IR[6:5] Shiftype / Rs Shift Amount/ Shift val Rm Data processing immediat...
#include <bits/stdc++.h> using namespace std; int n; int main() { scanf( %d , &n); for (int i = 0; i < 2 * n + 1; i++) { for (int j = 0; j < 2 * n + 1; j++) { if (i < n + 1) { if (j < n - i) { printf( ); } else if (j < n + i) { if (j <= n) { ...
`ifndef _alu `define _alu module alu( input [5:0] funct, input [5:0] opcode, input [31:0] a, b, output reg [31:0] out, output zero); // control (opcode -> ...) wire regdst; wire [1:0] branch_s2; wire memread; wire memwrite; wire memtoreg; wire [...
`timescale 1ns/100ps module top; reg pass = 1'b1; integer idelay = 2; real rdelay = 2.0; real rin = 1.0; reg ctl = 1'b1; wire outr, outi, muxr, muxi; wire real rout; reg in = 1'b1; assign #(idelay) outi = in; assign #(rdelay) outr = ~in; assign #(rdelay) rout = rin; assign #(idelay) muxi = ctl...
//***************************************************************************** // (c) Copyright 2009 - 2010 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 /...
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; void checkmin(int &x, int y) { if (x > y) x = y; } void checkmax(int &x, int y) { if (x < y) x = y; } inline int read() { int x = 0, f = 1; char c = getchar(); while (c > 9 || c < 0 ) { if (c == - ) f = -1;...
#include <bits/stdc++.h> using namespace std; typedef pair<long long, long long> ll; typedef vector<long long> vl; typedef vector<ll> vll; typedef vector<vl> vvl; template <typename T> ostream &operator<<(ostream &o, vector<T> v) { if (v.size() > 0) o << v[0]; for (unsigned i = 1; i < v.size(); i+...
#include <bits/stdc++.h> using namespace std; int X[1 << 11]; int Y[1 << 11]; int B[1 << 11]; int NX[1 << 11]; int NY[1 << 11]; int E[1 << 11][1 << 11]; int gN; int dfs(int a) { if (a == gN - 1) return 1; B[a] = 1; int i; for (i = (0); i < (gN); ++i) if (B[i] == 0 && E[a][i] > 0 ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; vector<string> v, l, b; for (long long int i = 0; i < n; i++) { string s; cin >> s; v.push_back(s); } long long int c = -1; for (long long int i = 0; i < n; i++) { for (l...
#include <bits/stdc++.h> using namespace std; set<pair<pair<int, int>, pair<int, int> > > s; vector<int> ed[2][300000]; int n, m, k; int a[300000], b[300000]; long long ans[300000]; bool add(int x, int y, int dx, int dy) { pair<pair<int, int>, pair<int, int> > g = make_pair(make_pair(x, y), ma...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; struct modint { int n; modint() : n(0) {} modint(int n) : n(n) {} }; modint operator+(modint a, modint b) { return modint((a.n += b.n) >= mod ? a.n - mod : a.n); } modint operator*(modint a, modint b) { return modint(1L...
#include <bits/stdc++.h> using namespace std; long long bins(long long l, long long r) { while (l + 1 < r) { long long m = (l + r) >> 1; cout << ? << l << << m << endl; cout.flush(); char c; cin >> c; if (c == e ) return 0; if (c == y ) { l = m; }...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e6 + 100; const long long MAXL = 21; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long x, r, l; cin >> x >> l >> r; long long ans = 0; long long a = 1; while (2 * a <= x) a = 2 *...
#include <bits/stdc++.h> using namespace std; const int maxn = 10000; const int maxm = 20000; const int maxk = 10; const int inf = 25; int tot_edge, sz; int head[maxn]; int nxt[maxm]; int to[maxm]; int cap[maxm]; int flow[maxk + 1][maxm]; int qu[maxn]; int prv[maxn]; int when[maxn]; int pa...
#include <bits/stdc++.h> using namespace std; int n, nc, a[111], b[111]; string c[111]; struct Node { int lab; Node *left, *right; Node(int x) { lab = x; left = NULL; right = NULL; } }; void printfalse() { cout << IMPOSSIBLE ; exit(0); } Node *solve(int x, int ...
/** * 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 la...
#include <bits/stdc++.h> using namespace std; long long a[27]; int main() { long long n; string s; cin >> n; cin >> s; long long c = 0, i, d; for (i = 0; i < (2 * n) - 2; i++) { if (s[i] >= a && s[i] <= z ) { d = s[i] - a ; a[d]++; } else { d = s[i] ...
#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}}; int n, v, e; vector<int> a, b; vector<vector<int> > conn, edges; vector<in...
#include <bits/stdc++.h> using namespace std; long long fast_power(long long x, long long y) { if (y == 0) return 1; long long temp = fast_power(x, y / 2); temp = ((temp % 1000000007) * (temp % 1000000007)) % 1000000007; if (y % 2 != 0) temp = ((temp % 1000000007) * (x % 1000000007)) % 1000000007; ...
#include <bits/stdc++.h> using namespace std; const int N = 1000010; const double eps = 1e-8; int n, T, cnt1, cnt2; long double sum1; double sum2; struct water { int a, t; } A[N], B[N], Tmp[N]; bool cmp1(const water &a, const water &b) { return a.t < b.t; } bool cmp2(const water &a, const water ...
#include <bits/stdc++.h> using namespace std; long long scan_d() { char t = getchar(); long long you = 0; while (t > 9 || t < 0 ) t = getchar(); while (t <= 9 && t >= 0 ) { you *= 10; you += t - 0 ; t = getchar(); } return you; } long long dp[1050][1050]; long ...
module Auto2(clock0,clock180,reset,leds,vga_hsync,vga_vsync,vga_r,vga_g,vga_b); input wire clock0; input wire clock180; input wire reset; output wire [7:0] leds; output wire vga_hsync; output wire vga_vsync; output wire vga_r; output wire vga...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t, n, k; cin >> t; while (t--) { long long ats = 0; cin >> n >> k; while (n) { ats += n % k; n -= n % k; while (n % k == 0 && n) n ...
// 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 : Sun May 28 19:32:43 2017 // Host : GILAMONSTER running 64-bit major release (...
/** * 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 `timescale 1ns / 1ps module joypad_snes_adapter( input wire clock, input wire reset, // to gameboy input wire [1:0] button_sel, output wire [3:0] button_data, output reg [15:0] button_state, // to controller input wire controller_data, output wire ...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long dx[] = {-1, 0, 1, 0}; long long dy[] = {0, -1, 0, 1}; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; vector<long long> v(n); vector<long long> a; ...
#include <bits/stdc++.h> using namespace std; typedef pair<long long, long long> ll; typedef vector<long long> vl; typedef vector<ll> vll; typedef vector<vl> vvl; template <typename T> ostream &operator<<(ostream &o, vector<T> v) { if (v.size() > 0) o << v[0]; for (unsigned i = 1; i < v.size(); i+...
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long int x; cin >> x; cout << 25; }
#include <bits/stdc++.h> using namespace std; int n, m; long long sum[1505][1505]; long long ans[1505]; long long t[1505]; int main() { int i, j, x; long long val, now, res; scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) scanf( %I64d , &val), sum[i][j]...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Jafet Chaves Barrantes // // Create Date: 15:45:17 04/03/2016 // Design Name: // Module Name: contador_AD_HH_T_2dig // Project Name: // Target Devices: // Tool versions: // Descr...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long inf = 0x3f3f3f3f; const long long llinf = 1e18; const long long nax = 0; long long n; vector<long long> arr(5005); vector<bool> ada(5005), masuk(5005); int main() { ios_base::sync_with_stdio(0); cin.ti...
#include <bits/stdc++.h> using namespace std; const int N = 7010; map<long long, int> cnt; int n; long long ar[N], br[N]; bitset<N> bit[N]; bitset<N> res; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> ar[...
/* Copyright (c) 2016 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; int n, k, d, done[300005] = {0}; vector<int> graph[300005]; map<pair<int, int>, int> edge; set<int> p; void go() { queue<pair<int, int> > q; for (auto it : p) q.push({it, 0}); while (!q.empty()) { int x = q.front().first, P = q.front().second; ...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2014, University of British Columbia (UBC); All rights reserved. // // // // Redistribution and use in source and binary forms, w...
/**************************************** Mul Unit - Booth Algorithm - 32bit Adder Make : 2010/12/07 Update : ****************************************/ `default_nettype none module execute_mul_booth32( //iDATA input wire [31:0] iDATA_0, input wire [31:0] iDATA_1, //oDATA output wire [63:0] oDATA...
#include <bits/stdc++.h> using namespace std; const int MX = 1147483646; const long long MX2 = 9223372036854775800; const int MOD = 1000000007; int p[30]; int find(int n) { if (p[n] < 0) return n; return p[n] = find(p[n]); } void uni(int e1, int e2) { e1 = find(e1); e2 = find(e2); if...
#include <bits/stdc++.h> using namespace std; bool func(deque<int>& v) { int x = v.back(); if (x > 1) { v.pop_back(); int y = x / 2; int y2 = x - y; if (y == 1) v.push_front(y); else v.push_back(y); if (y2 == 1) v.push_front(y2); else ...
// (C) 2001-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 doc...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; int n, m, q; vector<int> E[maxn]; int op[maxn], a[maxn], b[maxn], c[maxn]; int ans[maxn]; bitset<1001> Bit[1001]; bitset<1001> C; void dfs(int x) { if (x == 0) { for (int i = 0; i < E[x].size(); i++) { ans[E[x][i...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 2e5; int p[MAXN + 10], rub[MAXN + 10]; bool mark[MAXN + 10]; bool palin(int x) { stringstream sst; sst << x; string s; sst >> s; for (int i = 0; i < s.length(); i++) if (s[i] != s[s.length() - i - 1]) return false; ...
// cog_ram /* ------------------------------------------------------------------------------- Copyright 2014 Parallax Inc. This file is part of the hardware description for the Propeller 1 Design. The Propeller 1 Design is free software: you can redistribute it and/or modify it under the terms of the GNU Ge...
#include <bits/stdc++.h> using namespace std; int DEBUG = 0; int main(int argc, char **argv) { DEBUG = (argc >= 2) ? atoi(argv[1]) : 0; int t; cin >> t; for (int c = 0; c < t; c++) { char tmp; int board[8][8]; int kx[2]; int ky[2]; int eger = 0; for (int i = 0; ...
/* * 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 //------------------------------------------------ module UPCOUNTER_POSEDGE # (parameter SIZE=16) ( input wire Clock, Reset, input wire [SIZE-1:0] Initial, input wire Enable, output reg [SIZE-1:0] Q ); always @(posedge Clock ) begin if (Reset) Q = Initial; else begin i...
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; long long a[maxn]; int n; long long k; long long d[maxn]; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]); long long sum = 0; int num = 0; for (int i = 1; i <= n; i++) { d[i] = s...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // 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...
// (c) Copyright 1995-2017 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 license and does not grant ...
#include<iostream> #include<algorithm> using namespace std; class node{ public: int a; int b; }; bool com(node a,node b){ return a.a<b.a; } int main(){ int times=0; cin>>times; while(times--){ int t=0; cin>>t; node *arr=new no...
/** * 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; map<int, int> values; map<int, bool> reverseVisited; map<int, vector<int> > rev; stack<int> lastVisited; map<int, bool> visited; map<int, vector<int> > cities; void dfs(int init) { visited[init] = true; for (int i = 0; i < cities[init].size(); i++) {...
#include <bits/stdc++.h> using namespace std; long long getint() { char ch = getchar(); long long f = 1, x = 0; while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 0 ; ch = getchar(); } return f * x; } const...
#include <bits/stdc++.h> using namespace std; int n, m; char** mat; short ***sparse, ***rem; void build() { sparse = new short**[n + 1]; rem = new short**[n + 1]; for (int i = 0; i <= n; ++i) { sparse[i] = new short*[m + 1]; rem[i] = new short*[m + 1]; } for (int i = 0; i <= n;...
#include <bits/stdc++.h> using namespace std; int n; long long c[200005]; int b[200005]; int a[100005]; void up(int n, int k) { if (!n) return; while (n <= 200000) { b[n]++; c[n] += k; k++; n <<= 1; } } void solve(int n) { int cur = 0; long long num = n * 2; ...
#include <bits/stdc++.h> using namespace std; int find(int a[], int n) { int max = 1; int m = a[1]; for (int i = 2; i < n; i++) { if (m <= a[i]) { max = i; m = a[i]; } } return max; } int main() { int c = 0; int n; cin >> n; int a[n]; cin >> a[...
/***************************************************************************** * File : processing_system7_bfm_v2_0_ddrc.v * * Date : 2012-11 * * Description : Module that acts as controller for sparse memory (DDR). * *****************************************************************************/ `timescale 1ns/...
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const int mod = inf + 7; const double eps = 1e-9; const double pi = acos(-1.0); int n, ind = -1; int a[100100], b[100100]; pair<int, int> c[100100]; int v[100100], pos[100100]; vector<pair<int, int> > ans; bool is_happy(int x)...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: fifo.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // ==================================================...
/* Copyright (c) 2016-2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2008 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t ( input wire CLK, output reg RESET ); neg neg (.clk(CLK)); little litt...
module stimulus (output reg A, B); initial begin // both inputs are x #0 {A, B} = 2'bxx; // both inputs are z #10 {A, B} = 2'bzz; // one input is a zero #10 {A, B} = 2'b0x; #10 {A, B} = 2'bx0; #10 {A, B} = 2'b0z; #10 {A, B} = 2'bz0; // one input is a one #10 {A, B} = 2'b...
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 1; int n; int main() { scanf( %d , &n); n = abs(n); int i = 0; while (1) { int s = i * (i + 1); s /= 2; if (s >= n) { if (s % 2 && n % 2) { printf( %d , i); exit(0); } ...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2016.1 // Copyright (C) 1986-2016 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1...
#include <bits/stdc++.h> using namespace std; const int maxn = (3e5) + 10, mod = 1e9 + 7; int n, a[maxn]; map<int, int> mark; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 0; int num = 0; ...
/** * 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...
module step_ex_im(clk, rst_, ena_, rdy_, r0_din, r0_dout, r0_we_, immed, high); input clk; input rst_; input ena_; output rdy_; output[7:0] r0_din; input[7:0] r0_dout; output r0_we_; input[3:0] immed; input high; reg rdy_en; assign rdy_ = rdy_en ? 1'b0 : 1'bZ; re...
#include <bits/stdc++.h> using namespace std; void DEBUG(vector<long long> a) { printf( { ); for (long long x : a) printf( %lld , x); printf( } n ); } int mod; void DEBUG(long long mask) { printf( mask: ); for (int i = 0; i < mod; ++i) printf( %d , (mask >> i) & 1); printf( n ); }...
`include "hglobal.v" `default_nettype none module nd_fifo #(parameter FSZ=1, // 1, 2 or 4 ASZ=`NS_ADDRESS_SIZE, DSZ=`NS_DATA_SIZE, RSZ=`NS_REDUN_SIZE) ( `NS_DECLARE_GLB_CHNL(gch), `NS_DECLARE_OUT_CHNL(snd0), `NS_DECLARE_IN_CHNL(rcv0) ); parameter RCV_REQ_CKS = `NS_REQ_CKS; parameter SND_ACK_CKS = `NS_...
/** * 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; class segmentTree { public: int* tree; int N; int size; void update(int qidx, int val) { update(qidx, val, 0, N - 1, 0); } void update(int qidx, int val, int left, int right, int idx) { if (left == right && left == qidx) { tree[idx] ...
// based on https://people.ece.cornell.edu/land/courses/ece5760/DE2/indexVGA.html // dla simulation module vgadla ( input wire clk50, input wire [3:0] key, input wire [17:0] sw, inout wire [15:0] sram_dq, output wire [19:0] sram_addr, output wire sram_ub_n, output wire sram_lb_n, output...
#include <bits/stdc++.h> using namespace std; int px[4000010]; int py[4000010]; char c[2010][2010]; int n, m; bool pd(int x, int y, int d) { if (x < 0 || y < 0 || x + d >= n || y + d >= m) return false; for (int t = 1; t <= px[0]; t++) if ((px[t] != x) && (px[t] != x + d) && (py[t] != y) && (p...
// EE 471 Lab 1, Beck Pang, Spring 2015 // Main function for calling different counter onto the board // @require: only call one counter a time module DE1_SoCRegTest (CLOCK_50, LEDR, SW, KEY); input CLOCK_50; // connect to system 50 MHz clock output reg [9:0] LEDR; input [9:0] SW; input [3:0] KEY; wir...
`timescale 1ns/1ps /*************************************************************************** Name: Date: 7/11/2016 Founction: pwm capture deal Note: ****************************************************************************/ module pwm_capture( pwm_input,clk,rst_n,enable,tx_start,tx_data,tx_complete,capture_tx_rst...
// Copyright (c) 2014 CERN // Maciej Suminski <> // // 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) // any late...
#include <bits/stdc++.h> using namespace std; long long n, q; string s; int main() { cin >> n >> q; while (q--) { vector<pair<long long, long long> > v; long long x, l = 1, r = n, cur = n / 2 + 1; cin >> x >> s; while (cur != x) { v.push_back({l, r}); if (x < cur)...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, x; cin >> a >> b >> x; string s = ; if (a >= b) { s.push_back( 0 ); a--; } else { s.push_back( 1 ); b--; } while (x) { if (x == 1) { if (s.back() == 1 ) { while (b) s.p...
#include <bits/stdc++.h> using namespace std; double eps = 1e-6; double pi = acos(0.0) * 2; double dinf = 1e250; long long INF = static_cast<long long>(2e18); long long inf = static_cast<long long>(1e9 + 7); long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } template <class T> v...
/* Copyright (c) 2014-2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e5 + 13; long long root, sz[maxN], h[maxN], ans, val[maxN], m, n, pw[maxN], pre[maxN]; map<long long, long long> mp; vector<long long> vec; vector<pair<long long, long long>> adj[maxN]; bool mark[maxN], fl; void dfs(long long v, long ...
// (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...
#include <bits/stdc++.h> int main() { int d1, d2, d3, sum = 0; scanf( %d%d%d , &d1, &d2, &d3); if (d1 >= d2) { sum += d2; } else { sum += d1; } if (d1 + d2 >= d3) { sum += d3; } else { sum += d1 + d2; } if ((d1 >= d2) && (d1 <= d2 + d3)) { sum += d1; ...
#include <bits/stdc++.h> using namespace std; const int N = 200001; int cs1[N]; int cs2[N]; int ss1[N]; int ss2[N]; int sum(int i, int cs[]) { int s = 0; while (i > 0) { s += cs[i]; i -= i & -i; } return s; } void add(int i, int k, int cs[]) { while (i < N) { cs[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...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> a[105]; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i + 1; } sort(a, a + n); for (int i = 0; i < n / 2; i++) cout << a[i].second << << a[n - i - 1].second <...
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)4e18; int n, q; long long c[110000]; long long v[110000]; long long d[110000]; int u[110000]; int main() { ios::sync_with_stdio(0); cin >> n >> q; for (int i = 0; i < n; ++i) cin >> v[i]; for (int i = 0; i < n...
#include <bits/stdc++.h> using namespace std; int main() { int t, a, b, c, d, k; cin >> t; while (t--) { cin >> a >> b >> c >> d >> k; int pen = (a + c - 1) / c; int penc = (b + d - 1) / d; if (pen + penc <= k) cout << pen << << penc << endl; else cout <...
#include <bits/stdc++.h> using namespace std; const int P = 998244353, INF = 0x3f3f3f3f; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long qpow(long long a, long long n) { long long r = 1 % P; for (a %= P; n; a = a * a % P, n >>= 1) if (n & 1) r = r * a % P; r...
#include <bits/stdc++.h> using namespace std; set<string> ss; string s; void readInput() { cin >> s; } void solve() { for (int i = 0; i <= s.length(); i++) { for (char c = a ; c <= z ; c++) { string tmp; tmp += s.substr(0, i) + c + s.substr(i, s.length()); ss.insert(tmp); ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2022 by Geza Lore. // SPDX-License-Identifier: CC0-1.0 `ifdef verilator `define dontOptimize $c1("1") `else `define dontOptimize 1'b1 `endif module t (/*AUTOARG*/...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const double EPS = 1e-6; const string alpha = abcdefghijklmnopqrstuvwxyz ; const long long INFINF = 1e18; const int INF = 1e9; const int maxN = 1e6; int T; void tc() { int N; cin >> N; string second = ; int d = 0...
/* * Milkymist 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 distribut...
/* * 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) * ...
/** * 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...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2018 Miodrag Milanovic <> * Copyright (C) 2012 Clifford Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this per...