text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int r = 0; for (int i = 1; i < 300; i++) { int x1 = a / i; int x2 = b / i; if (x1 + x2 >= n && x1 != 0 && x2 != 0) r = i; } cout << r; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; const long long N = 5e3 + 5; long long a[N]; long long pre[N]; long long dp[N][N]; long long n, m, k; long long check = 0; long long go(long long pos, long long kk) { if (kk == k) return 0; if (pos == n + 1) return ... |
/*
* NAME
* ----
*
* 8-bit grey code generator
*
* DESIGN
* ------
*
* There are two main components to this counter.
*
* The first is the special cases at the start of
* each sequence. The first bit changes at sequence 1,
* second at 2, third at 4, etc.
*
* The second is the repeating sequence aft... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's Power Management ////
//// ////
//// This file is part of the OpenR... |
#include <bits/stdc++.h> using namespace std; namespace INIT { char buf[1 << 15], *fs, *ft; inline char getc() { return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft)) ? 0 : *fs++; } inline int read() { int x = 0, f = 1; char ch... |
#include <bits/stdc++.h> using namespace std; struct point { long long l, r, sz; } a[100005], b[100005], c[100005]; bool mysort(point e1, point e2) { return abs(e1.l - e1.r) > abs(e2.l - e2.r); } int main() { int n1 = 0, n2 = 0, n3 = 0, n, s, x, y, z; cin >> n >> s; long long tot1 = 0, tot2 = ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// HashVoodoo Test Module
// Paul Mumby 2012
//////////////////////////////////////////////////////////////////////////////////
`ifdef SIM
module hashvoodoo_test;
// Inputs
reg clk_p;
reg clk_n;
reg comm_clk;
r... |
/*
Copyright (c) 2014-2017 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... |
/* verilator lint_off UNUSED */
/* verilator lint_off CASEX */
/* verilator lint_off COMBDLY */
//
// address calculation Unit
//
module acu (clk, rstn, add_src , to_regf , from_regf, from_dec, db67 , seg_src );
input clk, rstn;
input [63:0] from_regf; // base&index register selected for address calculation
... |
#include <bits/stdc++.h> using namespace std; template <typename U, typename V> inline void smax(U &a, const V &b) { if (a < b) a = b; } const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double pi = acosl(-1.), eps = 1e-9; const int NN = 1010; int hd[NN]; int nx[NN << 1]; int to[NN << 1]; int ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; vector<vector<int>> adj; vector<bool> vis; vector<int> dep; vector<int> sz; vector<int> dif; void dfsd(int v, int c) { vis[v] = true; c++; for (auto it = adj[v].begin(); it != adj[v].end(); ++it) { if (vis[*it]... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { long long int n, m; cin >> n >> m; vector<long long int> graph[n + 1]; for (long long int i = 0; i < m; i++) { long... |
//
// 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> using namespace std; int main() { string months[] = { January , February , March , April , May , June , July , August , September , October , November , December }; string s; int n, a; cin >> s >> n... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; for (int i = 2; i <= n; i++) { if (n % i == 0) reverse(s.begin(), s.begin() + i); } cout << s; return 0; } |
#include <bits/stdc++.h> using namespace std; string dat[64]; int dp[64][64][64][64]; int main(void) { int n, m, q; scanf( %d%d%d , &n, &m, &q); for (int i = (0); i < (int)(n); ++i) cin >> dat[i]; for (int i = (0); i < (int)(n); ++i) for (int j = (0); j < (int)(m); ++j) dp[i][j][i]... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 5; int N, M; long long tree[4][MAXN][MAXN]; int ju(int x, int y) { int tt = 0; if (x % 2) tt++; if (y % 2) tt += 2; return tt; } void Update(int x, int y, long long v) { int ty = ju(x, y); for (int i = x; i <= N; ... |
#include <bits/stdc++.h> using namespace std; int n, x, s; int a[105]; double f[105][10005]; int main() { cin >> n >> x; for (int i = 1; i <= n; i++) cin >> a[i], s += a[i]; f[0][0] = 1; for (int i = 1; i <= n; i++) for (int j = i; j >= 1; j--) for (int k = s; k >= a[i]; k--) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 5; int arr[5], sum = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } if (sum == 0) cout << -1 << endl; else if (sum % 5 != 0) cout << -1 << endl; else { int s = sum / 5; ... |
module multiplexor_test;
localparam WIDTH=5;
reg sel ;
reg [WIDTH-1:0] in0 ;
reg [WIDTH-1:0] in1 ;
wire [WIDTH-1:0] mux_out;
multiplexor
#(
.WIDTH ( WIDTH )
)
multiplexor_inst
(
.sel ( sel ),
.in0 ( in0 ),
.in1 ( in1 ),
.mux_out ( mux... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool res = false; for (int i = 0; i < s.size() - 1; ++i) { if (s[i] == A && s[i + 1] == B ) { for (int j = i + 2; j < s.size() - 1; ++j) { if (s[j] == B && s[j + 1] == A ) { cout ... |
#include <bits/stdc++.h> using namespace std; struct P { long long first, second, sum; P(long long first = 0, long long second = 0, long long sum = 0) : first(first), second(second), sum(sum) {} bool operator<(const P &b) const { return first < b.first; } }; const long long MAX_V = 500100; ... |
#include <bits/stdc++.h> using namespace std; const int64_t Nmax = 2e5 + 10; const int64_t mod = 1000000007; vector<int64_t> prime; int64_t is_power_of_two(int64_t a) { return a && (!(a & (a - 1))); } int64_t isperfectsquare(int64_t a) { double b = sqrt(a); return (b - ceil(b) == 0); } int64_t p... |
// cog_ctr
/*
-------------------------------------------------------------------------------
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... |
//####################################################################
//# Function: Mailbox FIFO with a FIFO empty/full flag interrupts.
//#
//# E_MAILBOXLO = lower 32 bits of FIFO entry
//# E_MAILBOXHI = upper 32 bits of FIFO entry
//# E_MAILBOXSTAT = {30'b0,fifo_full, ~fifo_empty... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int n, c1, c2; int a[10]; long long f[501]; long long c[501][501]; long long dp[501][501]; long long gao(int a, int b) { if (a == 0 && b == 0) { return 1; } if (dp[a][b] == -1) { long long& cur = dp[a][b] =... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; while (t--) { long long int n, i, arr[200005]; string s; cin >> n; cin >> s; long long int ans = 0; for (i = 0; i < n; i++) {... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char now[1 << 16], *S, *T; if (T == S) { T = (S = now) + fread(now, 1, 1 << 16, stdin); if (T == S) return EOF; } return *S++; } inline long long read() { register long long x = 0, f = 1; char ch = gc(); ... |
/*
* 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() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; int n, x; while (t--) { cin >> n >> x; if (n == 1 || n == 2) cout << 1 << endl; else { if ((n - 2) % x == 0) cout << (n - 2) /... |
// NOTE: Users of BaseJump STL should not instantiate this module directly
// they should use bsg_mem_1r1w_sync_mask_write_byte.
`include "bsg_defines.v"
module bsg_mem_1rw_sync_mask_write_byte_synth
#(parameter `BSG_INV_PARAM(els_p)
, parameter addr_width_lp = `BSG_SAFE_CLOG2(els_p)
, parameter latch_last_... |
/*------------------------------------------------------------------------------
* 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 main() { int requestNum; cin >> requestNum; vector<pair<int, pair<int, int>>> vect(requestNum); for (int i = 0; i < requestNum; i++) { int num, money; cin >> num >> money; vect.push_back(make_pair(money, make_pair(num, i + 1))); ... |
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } int main() { fast(); double n; cin >> n; vector<double> v(n); for (int i = 0; i < n; i++) cin >> v[i]; double sum = 0; for (int i = 0; i < n; i++) su... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; inline void add(long long &a, long long b) { a += b; a %= MOD; } inline void sub(long long &a, long long b) { a -= b; a %= MOD; } inline long long mul(long long a, long long b) { return (long long)a * b % MOD; } ... |
// DEFINES
`define BITS 2 // Bit width of the operands
module bm_dag1_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 out1... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; inline int read() { char c = getchar(); int x = 0, f = 1; while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = x * 10 + c - 0 , c = getchar(); return x * f;... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; cout << 9 * n << << 8 * n << endl; } |
#include <bits/stdc++.h> using namespace std; const long long int INF = 9223372036854775807LL; #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroint-loops ) long long int power(long long int b, long long int e, long long int m) { if (b == 0) return 0; if ... |
// (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... |
// file regFileBoard.v
module regFileBoard(
input wire clock,
input wire clock_debug,
input wire reset,
input wire WriteEnable,
input wire [4:0] read_address_1,
input wire [4:0] read_address_2,
input wire [4:0] read_address_3,
input wire [31:0] write_data_in,
input wire [4:0] write_address,
input wire [4:0] ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, size = 1 << 20, mod = 998244353, inf = 2e9; const long long INF = 1e15; template <class o> void qr(o& x) { char c = getchar(); x = 0; int f = 1; while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 15; const int mod = 1e9 + 7; const int inf = 1e9 + 3; int t, n; string a[3], s; int flag; int conv(string q) { int ans = 0; for (int i = 0; i < q.size(); i++) { ans *= 10; ans += q[i] - 0 ; } return ans; ... |
/*
* This demonstrates a basic dynamic array
*/
module main;
shortreal foo[];
int idx;
initial begin
if (foo.size() != 0) begin
$display("FAILED -- foo.size()=%0d, s.b. 0", foo.size());
$finish;
end
foo = new[10];
if (foo.size() != 10) begin
$display("FAILED -- foo.size()=%0... |
#include <bits/stdc++.h> using namespace std; long long int a, b, c, t, d, e, f; long long int max(long long int x, long long int y) { if (x > y) return x; else return y; } int main() { scanf( %I64d%I64d%I64d , &a, &b, &c); t = max(a, max(b, c)); d = max(t - 1, b); e = max(... |
#include <bits/stdc++.h> using namespace std; class T { private: long node[262145]; long low[262145]; long high[262145]; void update(long n); long amount(long a, long b, long n, long n_a, long n_b); long firstUp(long k, long n, long n_a, long n_b); long firstDown(long k, long n, long ... |
#include <bits/stdc++.h> using namespace std; struct node { int st, en; } TV[200010]; bool cmp(node a, node b) { if (a.st == b.st) { return a.en < b.en; } return a.st < b.st; } int main() { int n; int tv1, tv2; int flag; cin >> n; tv1 = -1; tv2 = -1; flag = ... |
/**
* 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 = 5e5 + 5; int su[N], lst[N], n, i, a, lim; long long ans; pair<int, int> b[N]; int xb; inline int calc(int k) { int i, j; long long s = 0, ans = -1, x, y, z; xb = 0; for (i = 0; i * k < N; ++i) { s += 1ll * i * (su[min(N - 1,... |
#include <bits/stdc++.h> using namespace std; char s[1000010]; bool f[1000010]; int main() { int i, l, ans = 0, ans2 = 0, j, sta; scanf( %s , &s); l = strlen(s); sta = 0; while (s[sta] == s[(sta + 1) % l]) { sta = (sta + 1) % l; } ++sta; memset(f, false, sizeof(bool) * l); ... |
#include <bits/stdc++.h> using namespace std; long int temp, i, j, k, T; int main() { int n, a, b; cin >> n >> a >> b; int h[2007]; for (i = 0; i < n; i++) cin >> h[i]; sort(h, h + n); int val = h[b - 1]; if (h[b] == val) cout << 0 << endl; else cout << h[b] - val << ... |
module ID_STAGE (
input clk,
input rst,
input ID_Zero,
input ID_RegWriteEn,
input [2:0] ID_RegWriteDest,
input [15:0] ID_RegWriteData,
input [15:0] ID_In,
input [15:0] ID_Controller,
output [15:0] ID_AluSrc1,
output [15:0] ID_AluSrc2,
output [15:0] ID_MemWriteData,
output [2:0] ID_... |
Require Import Iron.Tactics.LibTactics.
Require Import Iron.Tactics.Rewrite.
Require Import Iron.Tactics.Rip.
Require Import Omega.
Ltac rs := rewritess.
Ltac rr := autorewrite with global in *.
(********************************************************************)
(* Burn mega-tactic for semantics proofs.
* Th... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 100010; inline int read() { int x = 0, f = 1; char ch = 0; while (!isdigit(ch)) { ch = getchar(); if (ch == - ) f = -1; } while (isdigit(ch)) x = x * 10 + ch - 48... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 10:07:18 03/23/2016
// Design Name:
// Module Name: MAIN
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependenci... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2013 by Alex Solomatnikov.
// SPDX-License-Identifier: CC0-1.0
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
logic [6-1:0] foo[4-1:0];
//initial $display("%m: ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long n, ans, dp[200005][3], sz[200005][3]; vector<int> gr[200005]; void dfs(int x, int p) { sz[x][0]++; for (int i = 0; i < gr[x].size(); i++) { int u = gr[x][i]; if (u == p) continue; dfs(u, x); dp[x][... |
module spi_slave(
input clk,
input rst,
input ss,
input mosi,
output miso,
input sck,
output done,
input [7:0] din,
output [7:0] dout,
output reg frame_start,
output reg frame_end
);
reg mosi_d, mosi_q;
reg ss_d, ss_q;
reg sck_d, sck_q;
reg sck_old_d, sck_old_q;
reg [7:0... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n, m; cin >> n >> m; vector<long long int> dp(n + 1); vector<pair<pair<long long int, long long int>, pair<long long int, long l... |
/*
This file is part of avgai.
avgai 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.
avgai is distributed in the hope that it... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { if (n == 1 || n == 2) cout << -1 n ; else if (n == 3) cout << 210 n ; else { if (n % 6 == 1) { cout << 1 ; for (int i = 3; i < n; i++) cout << 0 ; ... |
#include <bits/stdc++.h> using namespace std; long long m, l, r, k, n; long long a[2][2], b[2][2]; void cc(long long a[2][2], long long b[2][2]) { for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) a[i][j] = b[i][j]; } void mul(long long a[2][2], long long b[2][2], long long m) { long lon... |
#include <bits/stdc++.h> using namespace std; int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1}; const double PI = acos(-1.0); const double EPS = 1e-6; const int MOD = (int)1e9 + 7; const int maxn = (int)2e5 + 5; int cnt[maxn]; int main() { ios_base::sync_with_stdio(... |
// 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 : Tue Sep 19 09:41:30 2017
// Host : DarkCube running 64-bit major release ... |
#include <bits/stdc++.h> using namespace std; vector<int> a[200001]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int x, y; scanf( %d %d , &x, &y); a[x].push_back(y); } set<pair<int, int> > S; for (int i = 1; i <= n; i++) { sort(a[i].begin(), a[i].en... |
// 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 : Wed May 31 20:14:25 2017
// Host : GILAMONSTER running 64-bit major release (... |
#include <bits/stdc++.h> using namespace std; const long long INF = 99999999999999999; long long n, value[200000], zarib[200000], LCM = 1, GCD, x = INF, ans, sum; vector<int> Tree[200000]; long long gcd(long long l, long long r) { if (!l) return r; return gcd(r % l, l); } bool dfs(int v, int last,... |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2014.4
// Copyright (C) 2014 Xilinx Inc. All rights reserved.
//
// ==============================================================
`timescale 1 ns / 1 ps
m... |
module ExampMain
#(parameter P)
(input i, output o, inout io);
endmodule
module ExampStub (/*AUTOARG*/
// Outputs
o,
// Inouts
io,
// Inputs
i
);
/*AUTOINOUTPARAM("ExampMain")*/
// B... |
// MBT 11/9/2014
//
// 1 read-port, 1 write-port ram
//
// reads are asynchronous; we allow reading and writing of same address
//
`define bsg_mem_1r1w_macro(words,bits) \
if (els_p == words && width_p == bits) \
begin: macro ... |
/**
* 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... |
/**********************************************************************
* $my_pow example -- Verilog HDL test bench.
*
* Verilog test bench to test the $my_pow PLI application.
*
* For the book, "The Verilog PLI Handbook" by Stuart Sutherland
* Copyright 1999 & 2001, Kluwer Academic Publishers, Norwell, MA, USA
... |
/*
* 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... |
// ------------------ multiByteReadWrite.v ----------------------
`include "timescale.v"
`include "i2cSlaveTB_defines.v"
module multiByteReadWrite();
reg ack;
reg [31:0] readData;
reg [7:0] dataByteRead;
//reg [7:0] dataMSB;
// ------------------ write ----------------------
task write;
input [7:0] i2cAddr;
input [7... |
`include "defines.v"
`include "HRbridge.v"
`timescale 1ns/1ps
/*module connectRouter_nobuffer
#(parameter addr = 4'b0000) //No. 0 connect router, port 0
(
input `control_w port_l0_i,
output `control_w port_l0_o,
input `control_w FIFO_l0_i,
output `control_w FIFO_l0_o,
input bfull_... |
#include <bits/stdc++.h> using namespace std; class DREAD { friend int fread(); static const int buff_max = 20000000 + 10; char buf[buff_max], *pt; public: void clear() { for (; isspace(*pt); ++pt) ; } void Init() { buf[fread(buf, 1, buff_max, stdin)] = EOF; p... |
#include <bits/stdc++.h> using namespace std; const int inf = INT_MAX / 2; const int Maxn = 305; int a[Maxn + 5][Maxn + 5], f[Maxn + 5][Maxn + 5], g[Maxn + 5][Maxn + 5], n; int solve() { for (int(i) = (1); (i) <= (n); ++(i)) for (int(j) = (1); (j) <= (n); ++(j)) f[i][j] = -inf; f[1][1] = a[1][1]... |
#include <bits/stdc++.h> using namespace std; char s[200001]; long long a[26]; long long cnt = 0; int main() { long long i, j, k, l, m, n, t; cin >> t; cin >> s; l = strlen(s); for (i = 0; i < 26; i++) a[i] = 0; for (i = 1; i < l; i = i + 2) { if ((s[i - 1] - 97) != (s[i] - 65)) ... |
// Copyright 2018 Google LLC
//
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in w... |
// RS-232 RX module
// (c) fpga4fun.com KNJN LLC - 2003, 2004, 2005, 2006
module async_receiver(clk, RxD, RxD_data_ready, RxD_data, RxD_endofpacket, RxD_idle);
input clk, RxD;
output RxD_data_ready; // onc clock pulse when RxD_data is valid
output [7:0] RxD_data;
parameter ClkFrequency = 80000000; // 25MHz
//paramet... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int cnt = 0, cnt1 = 0; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == - ) cnt++; else cnt1++; } if (cnt1 == 0) { cout << YES ; return 0; } if (cnt % cnt1 == 0)... |
/*!
btcminer -- BTCMiner for ZTEX USB-FPGA Modules: HDL code for ZTEX USB-FPGA Module 1.15b (one double hash pipe)
Copyright (C) 2011 ZTEX GmbH
http://www.ztex.de
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
pub... |
#include <bits/stdc++.h> const int N = 2e3 + 9; using namespace std; int n, dp[5][N], a[N], b[5] = {0, 1, 2, 1, 2}; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } for (int i = 1; i <= 4; i++) { for (int j = 1; j <= n; j++) { dp[i][j] = max(... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const int mod = 1e9 + 7; const int N = 1e6 + 10; const long long INF = 1e18; long long power(long long x, long long y) { long long t = 1; while (y > 0) { if (y % 2) y -= 1, t = t * x % mod; else y /= 2... |
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 9; char s[N]; bool vis[N]; struct Point { long long x, y, id; Point(long long _x = 0, long long _y = 0, long long _id = 0) { x = _x; y = _y; id = _id; } Point operator-(const Point& b) const { return Point(x - ... |
#include <bits/stdc++.h> using namespace std; long long t = 1, tt; void solve() { long long n; cin >> n; string a, b; cin >> a >> b; if (n == 1) { if (a == b) cout << 0; else cout << 1; return; } long long ans = 0; for (long long i = 0; i < n / 2; ... |
`ifndef SDIO_DEFINES
`define SDIO_DEFINES
`define SDIO_STATE_RESET 0
`define SDIO_STATE_ACTIVE 1
`define SDIO_C_BIT_TXRX_DIR 1
`define SDIO_C_BIT_CMD_START 2
`define SDIO_C_BIT_CMD_END 7
`define SDIO_C_BIT_ARG_START 8
`define SDIO_C_BIT_ARG_END 39
`define SDIO_C_BIT_CRC_START 40
`d... |
// FIXME: очень плохое APi
//синхронный ресет на дает создать ena триггер
// синхронный ресет не отличим от других сигналов
// "eff sync only subset Verilog" как то так звучало
// детектировать сигнал нужно основным клоком, т.к. мы
// тактируем им напрямую, ширина стробирующий импльсов в один
// такт основого... |
module butterfly1_32(
enable,
i_0,
i_1,
i_2,
i_3,
i_4,
i_5,
i_6,
i_7,
i_8,
i_9,
i_10,
i_11,
i_12,
... |
#include <bits/stdc++.h> using namespace std; long long a, b, qa, qb, answer; int i, j, p, k, lcm, d; int dist[1000000]; char inq[1000000]; int gcd(int x, int y) { if ((x % y) == 0) return y; return gcd(y, x % y); } void ComputeDist() { for (i = 0; i <= lcm; i++) { dist[i] = lcm + 1; ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { return (!y ? x : gcd(y, x % y)); } long long lcm(long long x, long long y) { return x / gcd(x, y) * y; } void file() {} void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); file(); } int dx[] = {-... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; const long long inf = 1e18; int f[maxn][32], rt; long long ans, a[maxn]; vector<int> G[maxn]; void dfs(int u, int p) { long long d = 0; f[u][0] = p; for (d = 1; d <= 20; d++) { if (f[u][d - 1] != -1) f[u][d] = f[f[u]... |
`include "spi_master.v"
module oled_cls (
input clk,
input reset,
input cls_start,
output reg cls_fin,
output spi_csn,
output spi_sdo,
output spi_sclk,
output reg spi_dcn // active=command mode, inactive=data mode
);
`define CLS_SM_W 4
localparam STATE_IDLE ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int count = 0; for (int i = 0; i < n - 1; i++) { if (s[i] == s[i + 1]) { count++; } } cout << count; } |
// megafunction wizard: %ALTDDIO_OUT%VBB%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: ALTDDIO_OUT
// ============================================================
// File Name: delay.v
// Megafunction Name(s):
// ALTDDIO_OUT
//
// Simulation Library Files(s):
// altera_mf
// ============================... |
/**
* 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[300000], b[300000]; int tree[1 << 21], lazy[1 << 21]; int prop(int s, int e, int i) { tree[i] += lazy[i]; if (s != e) lazy[2 * i + 1] += lazy[i], lazy[2 * i + 2] += lazy[i]; lazy[i] = 0; return 0; } int update(int s, int e, int as, int ae, ... |
#include <bits/stdc++.h> using namespace std; int answer(); int main() { long long t; t = 1; while (t--) { answer(); } return 0; } int answer() { string k; cin >> k; int sup[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2}; if (k.size() > 1) { cout << sup[k[0] - 0 ] * sup[... |
#include <bits/stdc++.h> using namespace std; long long int powmod(long long int a, long long int e) { if (e == 0) return 1; long long int x = powmod(a * a % 1000000007, e >> 1); return e & 1 ? x * a % 1000000007 : x; } set<int> unvis; set<pair<long long int, long long int> > forbid; void dfs(in... |
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2014.4 (win64) Build Tue Nov 18 18:29:27 MST 2014
// Date : Tue Jun 30 18:14:28 2015
// Host : Vangelis-PC running 64-bit major release (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.