text stringlengths 59 71.4k |
|---|
#include<bits/stdc++.h> using namespace std; #ifndef ONLINE_JUDGE #include Mohit.h #endif typedef long long ll; typedef long double ld; #define endl n #define rep(i,n) for(ll i = 0; i < (n); ++i) #define repA(i, a, n) for(ll i = a; i <= (n); ++i) #define repD(i, a, n) for(ll i = a; i... |
//----------------------------------------------------------------------------
//-- Memoria RAM genérica
//------------------------------------------
//-- (C) BQ. October 2015. Written by Juan Gonzalez (Obijuan)
//-- GPL license
//----------------------------------------------------------------------------
//-- Memoria... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) using namespace std; template <typename T> bool mycomp(T x, T y) { return (x == y); } bool paircomp(const pair<long long int, long long int> &x, const pair<long... |
/**
* 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 unsigned long long maxn = 200005; unsigned long long n, m, vis[maxn]; unsigned long long sum, A, B, C, he[maxn]; struct node { unsigned long long x, y; bool operator<(const node &a) const { return x == a.x ? x < a.x : y < a.y; } } chongtu[maxn]; ... |
#include <bits/stdc++.h> using namespace std; double pi = 3.1415926536; int main() { int n; cin >> n; int r[n]; for (int i = 0; i < n; i++) cin >> r[i]; double area = 0; sort(r, r + n); for (int i = n - 1; i >= 0; i -= 2) { if (i > 0) area += (r[i] * r[i] - r[i - 1] * r[i... |
// megafunction wizard: %In-System Sources and Probes%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsource_probe
// ============================================================
// File Name: hps_reset.v
// Megafunction Name(s):
// altsource_probe
//
// Simulation Library Files(s):
// altera_mf
// ===... |
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 5; const int MOD = 1e9 + 7; long long cnt[N], x; int n, tmp; vector<vector<long long> > matMul(vector<vector<long long> > &A, vector<vector<long long> > &B) { vector<vector<long long> > C(N, vector<long... |
/**
* 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... |
// bsg_barrier
//
// Light-weight configurable wire/logic efficient barrier.
//
// This barrier works with any nearest-neighbor connected topology (e.g., chain, torus, mesh, ruche)
// with bidirectional links.
//
// This allows all of the node hardware to be identical, but configured according into a number
// of subgr... |
/**
* 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; #pragma comment(linker, /STACK:1024000000,1024000000 ) const double pi = acos(-1.0), eps = 1e-8; const int maxm = 1100000, inf = 0x3f3f3f3f; bool f[maxm]; vector<int> v[maxm]; int top, st[maxm]; int a[maxm]; void dfs(int x, int pre) { f[x] = true; ... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2005 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc; initial cyc=0;
reg [7:0] crc;
reg [223:0] sum;
wire [255:0] mglehy = {3... |
#include <iostream> using namespace std; typedef long long ll; int main() { int t; cin >> t; while (t--) { ll n, m, x; cin >> n >> m >> x; x--; ll j = x / n, i = x % n; cout << i * m + j + 1 << n ; } cin.ignore(2); return 0; } |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: scfifo
// ============================================================
// File Name: fifo_360_64.v
// Megafunction Name(s):
// scfifo
//
// Simulation Library Files(s):
// altera_mf
// ===============================... |
#include <bits/stdc++.h> using namespace std; long long DP[100005][25], arr[100005], freq[100005], l = 1, r, ans; void alter_range(long long l1, long long r1) { while (l1 < l) { l--; ans += freq[arr[l]]++; } while (r < r1) { r++; ans += freq[arr[r]]++; } while (l < l1) ... |
#include <bits/stdc++.h> using namespace std; const long long N = 3E5 + 7, mod = 998244353; long long n, a[N], inv[N], ans; signed main() { scanf( %lld , &n); for (long long i = 1; i <= n << 1; i++) scanf( %lld , &a[i]); sort(a + 1, a + 2 * n + 1); for (long long i = 1; i <= n; i++) ans = (ans -... |
//-----------------------------------------------------
// Design Name : hw1_A
// File Name : hw1_A.v
// Function : This program designs a single mux-based bus.
// Coder : hydai
//-----------------------------------------------------
module hw1_A (
input [15:0] data,
input [6:0] control,
input clk,
input rst_n,... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; int ar[N], ar1[N]; signed main() { ios::sync_with_stdio(0); cin.tie(0); int n, i, j, k, l, r; long long sum; cin >> n >> sum; if (sum < 1ll * n * (n + 1) / 2) { cout << -1; return 0; } for (i = 1; i ... |
#include <bits/stdc++.h> using namespace std; int n, a[100009], x[100009], h[100009], id[100009], seg[400009]; void upd(int pos, int l, int r, int pp, int v) { if (l == r) { seg[pos] = v; return; } int m = (l + r) / 2; if (m >= pp) upd(2 * pos + 1, l, m, pp, v); else up... |
#include <bits/stdc++.h> std::string a, b; std::string cal(std::string a) { if (a.length() % 2) return a; std::string s1 = cal(a.substr(0, a.length() / 2)); std::string s2 = cal(a.substr(a.length() / 2, a.length())); if (s1 < s2) return s1 + s2; return s2 + s1; } int main() { std::cin >>... |
#include <bits/stdc++.h> using namespace std; const int N = 5010; struct SA { bool _t[N * 2]; int _s[N * 2], _sa[N * 2], _c[N * 2], x[N], _p[N], _q[N * 2], hei[N], r[N]; int operator[](int i) { return _sa[i]; } void build(int *s, int n, int m) { memcpy(_s, s, sizeof(int) * n); sais(_s,... |
module step_ex_ld(clk, rst_, ena_, rdy_,
mem_re_, abus, dbus,
r1_dout, r0_din, r0_we_);
input clk;
input rst_;
input ena_;
output rdy_;
output mem_re_;
output[7:0] abus;
input[7:0] dbus;
input[7:0] r1_dout;
output[7:0] r0_din;
output r0_we_;
reg rdy_en;
assign rd... |
/**
* 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; ofstream fo( test.out ); ifstream fi( test.inp ); int n, m, k, dem; int x[200005], y[200005]; int main() { long long a; cin >> a; for (long long i = 2; i * i <= a; i++) { while (a % (i * i) == 0) a /= i; } cout << a; } |
// File: mm_vgasys.v
// Generated by MyHDL 0.9dev
// Date: Sun Mar 8 19:46:55 2015
`timescale 1ns/1ns
module mm_vgasys (
clock,
reset,
vselect,
hsync,
vsync,
red,
green,
blue,
pxlen,
active
);
input clock;
input reset;
input vselect;
output hsync;
reg hsync;
output vsync;
r... |
#include <bits/stdc++.h> using namespace std; vector<int> poz[100]; int main() { string s; cin >> s; for (int i(0); i <= 26; i++) poz[i].push_back(-1); for (int i(0); i < s.size(); i++) poz[s[i] - a ].push_back(i); for (int i(0); i <= 26; i++) poz[i].push_back(s.size()); int kmin = s.size... |
/**
* 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; vector<int> a; int main() { string s; cin >> s; int i, l = 0, can = 0, can_too = 0; for (i = 0; i < s.length(); i++) { if (s[i] == @ && can == 0) { can = 1; a.push_back(i); } else if (s[i] == . && can && !can_too) { ... |
#include <bits/stdc++.h> using namespace std; map<int, long long> ans, re, now; int n, h[200005], tot, mp[200005], siz[200005], mz[200005], rem[200005], cnt; bool vis[200005]; struct DX { int v, p; } dx[400005]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } void add(int u, int v) { dx[... |
#include <bits/stdc++.h> using namespace std; int main() { int n; long long tab[200001], min1, odl = -1, wynik, first; cin >> n; cin >> tab[0]; min1 = 0; first = 0; for (int i = 1; i < n; i++) { cin >> tab[i]; if (tab[i] == tab[min1]) { if (odl < i - min1) odl = i - m... |
// Regression test for bug reported by Niels Moeller on 21-Mar-2015 via
// iverilog-devel mailing list. Extended to cover similar problems. This
// is just testing compiler error recovery.
module test();
integer array[3:0];
integer i1;
always @* begin
for (i1 = 0; i1 < 4; i1 = i1 + 1) begin
array[i1] = undecl... |
`define BLACK_COLOR 8'b00000000
`define WHITE_COLOR 8'b11111111
`define WIDTH 640
`define HEIGHT 480
module Gpu(clk, reset, data_bus, address_bus, w, r, hs, vs, color);
input clk /* verilator clocker*/;
input reset;
input w, r;
inout [15:0] data_bus;
input [7:0] address_bus;
output reg hs, vs;
... |
#include <bits/stdc++.h> using namespace std; const int nsz = 3e5; int n; long long k, mod, a[nsz + 5], b[nsz + 5], ans; map<long long, int> mp; long long inline qpow(long long a, int p) { long long res = 1; for (; p; p >>= 1) { if (p & 1) { res *= a; res %= mod; } ... |
/*
* Zet processor core
* Copyright (C) 2010 Zeus Gomez Marmolejo <>
*
* This file is part of the Zet processor. This processor is free
* hardware; 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,... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; scanf( %i %i %i %i , &a, &b, &c, &d); int sum1 = max(3 * a / 10, a - a / 250 * c); int sum2 = max(3 * b / 10, b - b / 250 * d); if (sum1 > sum2) { printf( Misha n ); } else if (sum1 == sum2) { printf( Tie ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAX_N = 1e5 + 50; int w[MAX_N]; void solve() { int n, m; cin >> n >> m; long long ret = ((long long)w[n] + (long long)w[m] - 1LL) * 2LL; cout << ret % MOD << n ; } void precal() { w[0] = 0; w[1] = 1;... |
Require Import Fiat.Common
Fiat.Computation
Fiat.ADT.ADTSig
Fiat.ADT.Core
Fiat.ADTRefinement.Core Fiat.ADTRefinement.SetoidMorphisms
Fiat.ADTRefinement.GeneralRefinements.
(* A generic refinement and honing tactic for switching the
representation of an ADT. *)
Section HoneR... |
#include <bits/stdc++.h> using namespace std; int const N = 3e5 + 5; int const NN = 20; int const MAX = 1e9 + 1; int n, a[N]; struct ITMAX { pair<int, int> tree[4 * N]; pair<int, int> get_interval(pair<int, int> p, pair<int, int> q) { return make_pair(min(p.first, q.first), max(p.second, q.sec... |
#include <bits/stdc++.h> using namespace std; int arr[92]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; if (n == 1) { if (arr[0] == 15) cout << DOWN ; else if (arr[0] == 0) cout << UP ; else cout << -1; } else { if (... |
#include <bits/stdc++.h> using namespace std; int n, k; int a[222], sum[222]; struct node { int a, id; } b[222]; bool cmp(node s, node d) { return s.a < d.a; } int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i], b[i].a = a[i], b[i].id = i; ; sum[0] = a[0]; for (int... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's Store Buffer ////
//// ////
//// This file is part of the OpenR... |
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2014 Francis Bruno, All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Found... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = double; using vi = vector<int>; const int l = 20; const int maxn = 300006; int e[maxn][l]; int tote; map<int, int> S; int a[maxn]; int yy[maxn]; int rr[maxn]; int h[maxn][1000 / l]; int n, q; int app[maxn]; in... |
// This file is part of multiexp-a5gx.
//
// multiexp-a5gx 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... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: scfifo
// ============================================================
// File Name: sfifo_48x256.v
// Megafunction Name(s):
// scfifo
//
// Simulation Library Files(s):
// altera_mf
// ==========================================... |
#include <bits/stdc++.h> namespace modular { const int MOD = 1000000007; inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; } inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; } inline int mul(int x, int y) { return 1LL * x * y % MOD; } inline int qpow(int x, int y) { i... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { int n, k, inits[26]; char str[101]; bool poss = false, started[26] = {false}; scanf( %d%s , &k, str); n = strlen(str); if (n < k) { puts( NO ); break; } int cnt... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m, p; long long ans = -1e18; struct nd { int val, c; friend bool operator<(nd a, nd b) { return a.val < b.val; } } a[N], b[N]; struct mon { int x, y, z; friend bool operator<(mon a, mon b) { return a.x < b.x; } }... |
module tester;
reg rrst ;
reg [63:0] rdata ;
reg [31:0] rparameter_Block ;
reg [63:0] rparameter_Block2 ;
reg [7:0] rbmRequestType ;
reg [7:0] rbRequest ;
reg [15:0] rwValue ;
reg [15:0] rwIndex ;
reg [15:0] rwLength ;
reg renable ;
wire wbusy ;
wire [31:0] wdata_out;
wire [63:0] wdata_out2;... |
#include <bits/stdc++.h> using namespace std; const int N = 5001; long long n, m, a[N + 1], b[N + 1], type[N], l[N], r[N], x[N]; int main() { ios_base::sync_with_stdio(false); cin >> n >> m; for (int i = 1; i <= n; i++) a[i] = 1e9; for (int j = 1; j <= m; j++) { cin >> type[j] >> l[j] >> r... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200015; const int MOD = 1000000007; int a[MAXN]; bool F(int len, int num) { bool flag; int pres; for (int i = 0; i <= num - 1; i++) { flag = true; pres = i; for (int j = 0; j <= len - 1; j++) { if (a[pres] == ... |
// bsg_mesosync_link devides the chip's clock to a slower clock for IO
// based on the configuration it receives.
//
// bsg_mesosync_output module has three phases to be calibrated. After reset,
// it would send out a known pattern so the other side (master) can bit-allign
// its input. Next it would send all possi... |
#include <bits/stdc++.h> using namespace std; const int N = 2e4 + 5; char s[N]; int dp[10][N]; int ans[N]; int len; int dfs(int num, int idx) { if (~dp[num][idx]) return dp[num][idx]; if (idx == len) return 1; else if (idx > len) return 0; int &ret = dp[num][idx]; ret = dfs... |
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ld = long double; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T1, typename T2> ostream &operator<<(ostream &out, const pair<T1, T2> &item) {... |
// (c) Copyright 1995-2016 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 ... |
/**
* 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... |
//****************************************************************************************************
//*---------------Copyright (c) 2016 C-L-G.FPGA1988.lichangbeiju. All rights reserved-----------------
//
// -- It to be define --
// -- ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
`timescale 1 ns / 1 ps
//////////////////////////////////////////////////////////////////////////////////
// Company: AGH UST
// Engineer: Wojciech Gredel, Hubert Górowski
//
// Create Date:
// Design Name:
// Module Name: Change2Negedge
// Project Name: DOS_Mario
// Target Devices: Basys3
// ... |
#include <bits/stdc++.h> using namespace std; int main() { int a = 0; cin >> a; int z = 0, e = 0; char b; for (int i = 0; i < a; i++) { cin >> b; if (b == D ) z++; if (b == A ) e++; } if (e == z) cout << Friendship ; else if (e < z) cout << Danik ; ... |
#include <bits/stdc++.h> using namespace std; vector<int> pf(const string& s) { int n = s.size(); vector<int> pi(n); for (int i = 1; i < n; i++) { int j = pi[i - 1]; while (j > 0 && s[i] != s[j]) j = pi[j - 1]; if (s[i] == s[j]) j++; pi[i] = j; } return pi; } int main... |
// ----------------------------------------------------------------------
// Copyright (c) 2016, The Regents of the University of California All
// rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:... |
/*
Distributed under the MIT license.
Copyright (c) 2015 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; const int maxn = 2e5 + 100; char s[maxn], t[maxn]; int s_big[30], s_small[30], t_big[30], t_small[30]; int main() { while (scanf( %s%s , s + 1, t + 1) != EOF) { memset(s_big, 0, sizeof(s_big)); memset(s_small, 0, sizeof(s_small)); memset(t_bi... |
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016
// Date : Mon Sep 18 13:00:14 2017
// Host : vldmr-PC running 64-bit Service Pack 1 ... |
module I2C(
// clock and reset
input clk,
input reset,
// inputs
input [6:0] chip_addr,
input [7:0] reg_addr,
input [7:0] value,
input enable,
input is_read,
// I2C pins
inout sda,
inout scl,
// outputs
output reg [7:0] data,
output reg done,
output i2c... |
#include <bits/stdc++.h> using namespace std; using u128 = __uint128_t; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t = 1; while (t--) { long long n; cin >> n; vector<long long> ans(n, 0); cout << ? << 1 << << n << endl; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 6; int n, m, a[N]; int main() { int x[3], y[3]; cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2]; int len[3] = {(x[1] - x[0]) * (x[1] - x[0]) + (y[1] - y[0]) * (y[1] - y[0]), (x[2] - x[0]) * (x[2] - x[0]) + (y[2] ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long arr[n + 5], mx = 0, mn = INT_MIN; for (int i = 0; i < n; i++) cin >> arr[i]; if (arr[n - 1] > 0) arr[n] = -1; else arr[n] =... |
`timescale 1ns / 1ps
`include "Defintions.v"
`define LOOP1 8'd8
`define LOOP2 8'd5
module ROM
(
input wire[15:0] iAddress,
output reg [27:0] oInstruction
);
always @ ( iAddress )
begin
case (iAddress)
0: oInstruction = { `NOP ,24'd4000 };
1: oInstruction = { `STO , `R7,16'b0001 };
2: o... |
/**
* @module alu_flags
* @author sabertazimi
* @email
* @brief get flags after alu calculation
* @param DATA_WIDTH data width
* @input srcA A port data
* @input srcB B port data
* @input aluop operation code
* @output zero equal flag
* @output of signed overflow flag
* @output uof unsigned overflow flag
*... |
//==================================
// dc_planar
// luyanheng
// creat:2014-9-16
// modify:2015-1-9
//==================================
module dc_planar(
rstn,
clk,
counterrun1,
counterrun2,
gx,
gy,
cnt,
blockcnt,
bestmode,
bestmode16,
bestmode32,
modebest,
modebest16,
modebest32,
... |
/*
* Milkymist VJ SoC
* Copyright (C) 2007, 2008, 2009 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 distributed ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long long int n; cin >> n; long long int a[n]; long long int mx = 0; long long int sum = 0; for (long long int i = 0; i < n; i++) { cin >> a[i]; mx = max(mx, a[i]); sum +... |
`timescale 1ps / 1ps
module AXI_DDR2_test(
);
// HELPER
function integer clogb2;
input integer value;
integer i;
begin
clogb2 = 0;
for(i = 0; 2**i < value; i = i + 1)
clogb2 = i + 1;
end
endfunct... |
#include <bits/stdc++.h> using namespace std; vector<tuple<int, int, int, int> > ask; int mat[105][105]; int main() { int n, m, q, op, r, c, x, i, j; scanf( %d%d%d , &n, &m, &q); for (i = 0; i < q; i++) { scanf( %d , &op); if (op == 1 || op == 2) { scanf( %d , &x); ask.em... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, d; cin >> n >> d; int a[n], sum = 0; for (int i = 0; i < n; i++) cin >> a[i], sum += a[i]; if (sum + 10 * (n - 1) <= d) cout << (d - sum) / 5; else cout << -1; } |
#include <bits/stdc++.h> using namespace std; long long read() { long long x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f = ch == - , ch = getchar(); while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return f ? -x : x; } const int N = 1005; int n, k, b; ... |
//----------------------------------------------------------------------------
// Copyright (C) 2009 , Olivier Girard
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must re... |
#include <bits/stdc++.h> using namespace std; long long bef[1000100], af[1000100]; long long calc(long long n) { return (n * (n + 1)) / 2; } int main() { int k; string s; cin >> k >> s; memset(bef, 0, sizeof bef); memset(af, 0, sizeof af); long long last(1000010), cur(1), i(0); vecto... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cerr.tie(0); int n, tmp; vector<pair<int, int> > a; cin >> n; for (int i = 0; i < n; i++) cin >> tmp, a.push_back(make_pair(tmp, i + 1)); sort(a.begin(), a.end()); int c1 = 0, c2 =... |
#include <bits/stdc++.h> using namespace std; int const N = 70; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; char s[N][N]; int vis[N][N]; int n, m; int dfs(int x, int y) { if (s[x][y] != # || vis[x][y]) return 0; vis[x][y] = 1; for (int i = 0; i < (4); i++) dfs(x + dx[i], y + dy[i])... |
`timescale 1ns / 1ps
///////////////////////////////////////////////////////////////////////////////////////////
// Company: Digilent Inc.
// Engineer: Andrew Skreen
//
// Create Date: 08/16/2011
// Module Name: display_controller
// Project Name: PmodGYRO_Demo
// Target Devices: Nexys3
// Tool versions: ISE ... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's IC FSM ////
//// ////
//// This file is part of the OpenR... |
#include <bits/stdc++.h> using namespace std; bool isprime(long long int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } vector<lo... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, oo = inf; inline long long read() { register long long x = 0, f = 1; register char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ... |
/*
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> int diru[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dirv[] = {-1, 0, 1, -1, 1, -1, 0, 1}; using namespace std; template <class T> T sq(T n) { return n * n; } template <class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a % b) : a); } template <class T> T lcm(T a, T b)... |
#include <bits/stdc++.h> using namespace std; int n, m, h, t, r, x, y, dis[210][210], h1[210], t1[210], h2[210], t2[210], bfs[210 * 210][2], L, R; void renew(int x, int y, int v) { if (x + y > r) return; if (dis[x][y] == -1) { dis[x][y] = v; bfs[++R][0] = x; bfs[R][1] = y; } ... |
#include <bits/stdc++.h> using namespace std; int max2[205][6005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); fill_n(max2[0], 205 * 6005, -1); max2[0][0] = 0; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { long long int a; cin >> a; int p2 =... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: playback_driver.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 it 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 law... |
#include <bits/stdc++.h> using namespace std; int gl, gr, bl, br; bool check(int g, int b) { if (g - 1 <= b && b <= 2 * (g + 1)) return true; else return false; } int main() { scanf( %d %d %d %d , &gl, &gr, &bl, &br); if (check(gl, br) || check(gr, bl)) cout << YES << endl;... |
// Explore how procedural concatenations work in various contexts.
// Some of the checks are specific to the 1364-2005 standard.
//
// Cary R.
module main;
reg pass;
reg [31:0] a_c, b_c, c_c, d_c, a_r, b_r, c_r, d_r;
reg [127:0] y_c;
integer seed, fres;
// These will have the following value depending on th... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; ++i) { int n; cin >> n; string s; cin >> s; int sum(0), pos(-1), pos1(-1), ot(-1), num(0); for (int i = 0; i < s.length(); ++i) sum += (s[i] - 0 ); for (int i = 0... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a1, a2, b1, b2, k = 1, f = 0, ans = 0; scanf( %d , &n); while (k <= 4) { scanf( %d%d%d%d , &a1, &a2, &b1, &b2); if (n >= a1 + b1 || n >= a1 + b2) ans = a1; else if (n >= a2 + b1 || n >= a2 + b2) ans = a2;... |
#include <bits/stdc++.h> using namespace std; const double PI = 2.0 * acos(0.0); const double EPS = 1e-6; int dp[100005]; static int topp; void LIS(int x) { if (topp == 0) dp[topp++] = x; else if (x > dp[topp - 1]) dp[topp++] = x; else { int left = 0, right = topp; while ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.