text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int maxn = 500010; int n, m; char a[maxn], b[maxn]; char s[maxn * 2], c[maxn * 3]; int z[maxn * 3]; int lcp[maxn]; int lcs[maxn]; void z_init(int len) { int l = 1, r = 1; z[1] = len; for (int i = 2; i <= len; i++) { if (i > r) { ... |
// Copyright (c) 2015 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; int n, m, x, q[100100]; char t; vector<int> d; bool used[100100]; void calc(int x) { d.resize(0); for (int i = 2; i * i <= x; i++) if (x % i == 0) { while (x % i == 0) x /= i; d.push_back(i); } if (x != 1) d.push_back(x); ... |
// (C) 2001-2014 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; int main() { int n; scanf( %d , &n); if (n % 2) printf( black n ); else printf( white n1 2 n ); } |
#include <bits/stdc++.h> using namespace std; const int N = 15e4 + 5; int n, b[N]; long long a[N]; int prev(int x) { int y = x - 1; if (y == 0) y = n; return y; } int nxt(int x) { return x % n + 1; } int main() { scanf( %d , &n); bool f = true; for (int i = 1; i <= n; i++) scanf(... |
#include <bits/stdc++.h> using namespace std; char str[25][25]; int cost[25][25]; const int maxc = 1 << 20; int dp[maxc]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) scanf( %s , str + i); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) scanf( %d ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23.02.2016 23:02:44
// Design Name:
// Module Name: can_controller_testbench
// 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, 2015 by Johan Bjork.
parameter N = 4;
interface a_if #(parameter PARAM = 0) ();
logic long_name;
modport source (output long_name);
modport sink (input long_name);
endinterf... |
// 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 : Thu Feb 02 03:23:40 2017
// Host : TheMosass-PC running 64-bit major release ... |
#include <bits/stdc++.h> using namespace std; int n, p, cnt, r[1010]; pair<int, int> c[1010]; bool check[1010]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> c[i].second >> c[i].first; if (c[i].second > c[i].first) swap(c[i].second, c[i].first); } sort(c, c + n); ... |
/*
* Copyright 2012, Homer Hsing <>
*
* 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 ... |
#include <bits/stdc++.h> using namespace std; int main() { long long ans = 0, now, a[14], b[14]; for (int i = 0; i < 14; i++) cin >> a[i]; for (int i = 0; i < 14; i++) { if (a[i] != 0) { for (int j = 0; j < 14; j++) b[j] = a[j]; int r = b[i] % 14, q = b[i] / 14; b[i] = 0; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 10; long long n; pair<char, long long> ar[N]; vector<long long> vec; set<long long> st; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; n *= 2; for (long long i = 0; i < n; i++) { char c; ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 16:00:14 05/19/2015
// Design Name:
// Module Name: display2
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Depend... |
#include <bits/stdc++.h> using namespace std; using nagai = long long; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int c = 0; int t = 1; while (t <= n) { n -= t, ++c, t *= 2; } if (n) ++c; cout << c << n ; retur... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> edges; vector<int> large; bool ok = true; vector<pair<long long, long long>> dfs(int cur) { vector<pair<long long, long long>> child; for (int i : edges[cur]) { auto temp = dfs(i); child.insert(child.end(), temp.begin(), tem... |
`timescale 1ns / 1ps
module control_unit();
parameter ADDR_SIZE = 12;
parameter WORD_SIZE = 16;
reg sysclk;
initial begin //clock
sysclk <= 1'b1;
forever #1 sysclk = ~sysclk;
end
initial begin
$dumpfile("control_unit.vcd");
$dumpvars;
end
/*
*... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n, x1, x2; pair<int, int> c[N], f[2]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> x1 >> x2; for (int i = 0; i < n; i++) cin >> c[i].first, c[i].second = i; sort(c, c + n); ... |
/*------------------------------------------------------------------------------
* 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; template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); } template <typename T> T gcd(const T a, const T b) { return b ? gcd(b, a % b) : a; } templa... |
#include <bits/stdc++.h> using namespace std; unsigned long long f(unsigned long long x, int b) { for (int i = 0; i < 64; i++) if (__builtin_popcountll(x) < b) x |= 1ULL << i; return x; } unsigned long long brute(unsigned long long l, unsigned long long r) { unsigned long long ret = l; for... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
// (C) 2001-2015 Altera Corporation. All rights reserved.
// Your use of Altera Corporation's design tools, logic functions and other
// software and tools, and its AMPP partner logic functions, and any output
// files any of the foregoing (including device programming or simulation
// files), and any associated doc... |
// final sub module for text
module study_text
(
input wire clk,
input wire [9:0] pix_x, pix_y,
output wire [3:0] study_on,
output reg [2:0] study_rgb
// we output text_rgb only because we have to select it according to FSM
);
// signal declaration
wire [10:0] rom_addr;
reg [6:0] ch... |
#include <bits/stdc++.h> using namespace std; int main() { long long k, a, b; cin >> k >> a >> b; long long k1, k2, r1, r2; if (a >= 0) { k1 = a / k; r1 = a % k; } else { k1 = a / k; r1 = a % k; if (r1) { k1 -= 1; r1 += k; } } if (b >= ... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > E[200005]; int U[200005], V[200005], D[200005]; int n, m; int vs[200005]; queue<int> q; int dfs(int u, int in) { q.push(u); for (int len = 0;; len++) { int sz = q.size(); if (sz == 0) break; in = len % 2; ... |
//
// mbt 11/26/2014
//
// this module converts between the various link-level flow-control
// protocols.
//
// fixme: many of the cases have not been tested. naming convention might
// be better. more asserts would be good. send_v_and_ready_p does not seem to
// be implemented. clocked versions should be handled by s... |
#include <bits/stdc++.h> using namespace std; long long d[40000]; char s[4005]; void input() { int i, j, len, a, sum; long long res; scanf( %d %s , &a, &s); len = strlen(s); for ((i) = 0; (i) < (len); (i)++) { sum = 0; for ((j) = (i); (j) <= (len - 1); (j)++) { sum += s[j... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, x, l; cin >> n; vector<int> tab; for (long long int i = 0; i < n; ++i) { l = 0; cin >> x; if (x <= 7) tab.push_back(1); else if (x % 7 == 0) tab.push_back(x / 7); else if (x % 6 ... |
// -----------------------------------------------------------------------
//
// Copyright 2004,2007 Tommy Thorn - 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 Foundatio... |
// (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 "assert.vh"
module cpu_tb();
reg clk = 0;
//
// ROM
//
localparam MEM_ADDR = 3;
localparam MEM_EXTRA = 4;
reg [ MEM_ADDR :0] mem_addr;
reg [ MEM_EXTRA-1:0] mem_extra;
reg [ MEM_ADDR :0] rom_lower_bound = 0;
reg [ MEM_ADDR :0] rom_upper_bound = ~0;
wire [2... |
//-------------------------------------------------------------------
//-- baudtx_tb.v
//-- Banco de pruebas para la tranmision de datos
//-------------------------------------------------------------------
//-- BQ August 2015. Written by Juan Gonzalez (Obijuan)
//-------------------------------------------------------... |
`timescale 1ns/1ns
// 2K memory card (100ns 2048*8bit RAM)
module memcard(
input [23:0] CDA,
inout [15:0] CDD,
input nCE,
input nOE,
input nWE,
input nREG, // Ignore
output nCD1, nCD2,
output nWP
);
parameter nINSERTED = 1'b1; // Memcard not inserted !
//parameter nINSERTED = 1'b0; // ... |
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017
// Date : Wed Sep 20 21:07:50 2017
// Host : EffulgentTome running 64-bit major rele... |
/**
* 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 main() { priority_queue<pair<unsigned long long int, int> > matches; unsigned long long int n; int m; unsigned long long int a; int b; unsigned long long int max = 0; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2017.2
// Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved.
//
// ==============================================================
`timescale 1 ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { vector<long> vt; long i = 0, n, temp, count = 1; cin >> n; for (int i = 0; i < n; i++) { cin >> temp; vt.push_back(temp); } sort(vt.begin(), vt.end()); whil... |
#include <bits/stdc++.h> using namespace std; string s; int n, cnt[60], have, r = 1; int main() { ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> s; n = s.size(); s = + s; for (int i = (1); i <= (n); ++i) { while (r <= n && have < 26) { if (s[r] == ? ) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n, m, k, i, j, a[200002], sum = 0; vector<long long int> v; set<pair<long long int, long long int>> s; cin >> n >> m >> k; for (i = 0; i < n; 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... |
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const long long LLINF = 9223372036854775807LL; const int maxn = 30010; int a[maxn] = {}; int used[maxn] = {}; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d , &a[i]); vector<int> ans1, ans... |
/*
verilog fetch/decode/memory stage module.
*/
`include "defines.v"
module stages(
input wire [`REGW-1:0] ins,
input wire [`STGW-1:0] cs,
input wire zf,
output reg [`REGO-1:0] gr_raddr1, gr_raddr2, gr_waddr,
output reg gr_we, pc_we, mem_we, pc_ie
);
reg pzf;
initial gr_we = 1'b0;
initial pc_ie = ... |
/**
* 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... |
//////////////////////////////////////////////////////////////////////
//
// clkgen
//
// Handles clock and reset generation for rest of design
//
//
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2009, 201... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); int t; cin >> t; for (int i = 0; i < t; i++) { long long a, b; long long uns = 0; cin >> a >> b; uns = abs(a - b) / 5; if (abs(a - b) % 5 == 1) uns++; ... |
//
// Copyright (c) 2002 Steven Wilson ()
//
// 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)
// ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return b; return gcd(b % a, a); } long long powerMod(long long x, long long y) { long long res = 1; x %= 1000000007; while (y > 0) { if (y & 1) res = (res * x)... |
module ARM_CU_ALU_TestBench;
parameter sim_time = 750*2; // Num of Cycles * 2
wire [17:0] signals;
wire IR_CU, RFLOAD, PCLOAD, SRLOAD, SRENABLED, ALUSTORE, MFA, WORD_BYTE, READ_WRITE, IRLOAD, MBRLOAD, MBRSTORE, MARLOAD;
wire [4:0] opcode;
wire [3:0] CU;
reg [31:0] IR;
reg [3:0] SR;
reg MFC , Reset , Clk ;
//... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 10; long long n, a, cnt, ans, sum, l, r; string g; void DNM() { cin >> n; cin >> g; sort(g.begin(), g.end()); cout << g << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); ... |
/*
* 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; long long pow(long long a, long long b) { long long res = 1; while (b) { if (b & 1) { res = (res * a) % 1000000007; } b >>= 1; a = (a * a) % 1000000007; } return res; } int main() { long long n, k; cin >> n >> ... |
#include <bits/stdc++.h> using namespace std; long long v[2][200005]; long long c[2][200005]; int n, k, a, b, q, e, day, ord; const int maxn = 200005; void add(int i, int value, int z) { for (; i < maxn; i += (i + 1) & -(i + 1)) v[z][i] += value; } long long get(int i, int z) { long long res = 0... |
// ====================================================================
// MAH PONK
//
// Copyright (C) 2007, Viacheslav Slavinsky
// This design and core is distributed under modified BSD license.
// For complete licensing information see LICENSE.TXT.
// ----------------------------... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> p(n, 0); for (int i = 0; i < n; i++) { int aux; cin >> aux; p[i] = aux - 1; } vector<long long int> dp(n + 1, 0); for (int i = 1; i < n + 1; i++) { dp[i] = (long long int)(dp[i... |
#include <bits/stdc++.h> using namespace std; const int INF = 2e9; long long gcd(long long a, long long b) { while (b) { a %= b; swap(a, b); } return a; } int main() { long long l, r, x, y; cin >> l >> r >> x >> y; long long d = 1; long long res = 0; map<int, int> m... |
#include <bits/stdc++.h> using namespace std; void yala_bena() { cin.tie(0); std::ios::sync_with_stdio(0); } const int m_r = 999999; int k = -1; int bestsum, limit; vector<long long> ans; int binary(int number) { while (number) { k++; if (number % 2) return k; number /= 2; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long qpow(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a; b >>= 1; a = a * a; } return res; } int a[500005]; int main() { int n, k; cin >> n >> k; fo... |
#include <bits/stdc++.h> using namespace std; unsigned long long int dist[1150][1150], visited[1150][1150]; char ans[1050][1050]; void solve() { long long n, i, j, m; cin >> n >> m; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) cin >> ans[i][j]; } int startx, starty, endx, endy; ... |
`timescale 1ns / 1ps
`default_nettype none
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 20:06:40 03/19/2011
// Design Name:
// Module Name: jace_en_fpga
// Project Name:
// Target Devices:
// Tool versions:
// Description:... |
//////////////////////////////////////////////////////////////////////////
// Department of Computer Science
// National Tsing Hua University
// Project : FIFO for CS4125 Digital System Design
// Module : fifo.v
// Author : Chih-Tsun Huang
// E-mail :
// Revision : 4
// Date : 2014/04/28
// Abstract ... |
#include <bits/stdc++.h> using namespace std; int main() { int T, d; scanf( %d , &T); while (T--) { scanf( %d , &d); double a = 0, b = 0; double x = d * d - 4 * d; if (x < 0) { printf( N n ); continue; } else { a = (d - sqrt(x)) / 2.0; b = d ... |
#include <bits/stdc++.h> using namespace std; const long long N = 610001; const long long inf = (long long)5e16; struct node { long long val, id; }; node a[N], b[N]; bool cmp(node x, node y) { if (x.val == y.val) return x.id < y.id; return x.val < y.val; } long long n, m, ans[N], pos[N]; ... |
module user_design(clk, rst, exception, input_timer, input_rs232_rx, input_ps2, input_i2c, input_switches, input_eth_rx, input_buttons, input_timer_stb, input_rs232_rx_stb, input_ps2_stb, input_i2c_stb, input_switches_stb, input_eth_rx_stb, input_buttons_stb, input_timer_ack, input_rs232_rx_ack, input_ps2_ack, input_i2... |
#include <bits/stdc++.h> using namespace std; const long long iinf = 1 << 29; const long long inf = 1ll << 60; const long long mod = 1e9 + 7; void GG() { cout << No n ; exit(0); } long long mpow(long long a, long long n) { long long re = 1; while (n > 0) { if (n & 1) re = re * a % m... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000009; const double PI = acos(-1.0); const double eps = 1e-8; const int MAXN = 0; const int MAXM = 0; long long n, k, t, b, z; int main() { z = 1; int ans = 0; cin >> k >> b >> n >> t; while (z <= t) { ans++; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr << Time : << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << ms n ; long long t; cin >> t; while (t--) { long long n, g = 0, s = 0, b = 0, i, gidx, bi... |
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Stefan Wendler
*
* 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 us... |
// -------------------------------------------------------------
//
// File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\controllerHdl\controllerHdl_Rotor_To_Electrical_Position.v
// Created: 2014-09-08 14:12:04
//
// Generated by MATLAB 8.2 and HDL Coder 3.3
//
// ------------------------------------------------... |
#include <bits/stdc++.h> using namespace std; struct grp { long long to, wt, edgeCode; char type; }; struct Node { long long x, dis; }; struct comp { inline bool operator()(const Node& n1, const Node& n2) const { if (n1.dis != n2.dis) return n1.dis < n2.dis; return n1.x < n2.x; ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 10:51:19 05/03/2016
// Design Name:
// Module Name: uart_tx
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
//... |
#include <bits/stdc++.h> using namespace std; int n, m, cnt, flag; vector<int> graph[100005]; bool vis[100005]; void dfs(int node, int parent) { vis[node] = 1; int x, u, v, i; cnt++; for (i = 0; i < graph[node].size(); i++) { v = graph[node][i]; if (v == parent) continue; if ... |
#include <bits/stdc++.h> using namespace std; struct Query { int left; int right; int index; bool operator<(const Query &other) const { return right < other.right; } }; const int N = 1e6 + 100; int a[N]; int xorSum[N]; Query q[N]; int ans[N]; struct FenwickTree { FenwickTree() { fi... |
#include <bits/stdc++.h> using namespace std; int main() { int n; char m[11], digit[10] = { 0 }, digitcount(0); scanf( %d%s , &n, &m); while (n != 0) { digit[digitcount++] = 0 + n % 10; n /= 10; } sort(digit, digit + digitcount); if (digit[0] == 0 ) { for (int i = 1;... |
//////////////////////////////////////////////////////////////////
// //
// Arithmetic Logic Unit (ALU) for Amber 2 Core //
// //
// This file is part of the Amber project ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a[s.length()]; int ans = -1; int n = s.length(); for (int i = 0; i < s.length(); i++) { a[i] = int(s[i]) - 48; } for (int i = 0; i < n; i++) { if (a[i] % 8 == 0) { ans = a[i]; ... |
#include <bits/stdc++.h> using namespace std; int n, x; int dist[501][501]; bool color[501]; unsigned short num_red; unsigned short ans[501][501][501], best[501][501], sizes[501]; unsigned short inf = ~0; vector<unsigned short> edge[501]; void dfs(unsigned short& now, unsigned short& before) { for... |
#include <bits/stdc++.h> using namespace std; int main() { int a[200], n, c = 0; double sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } sort(a, a + n); while (double(sum / n) < 4.5) { sum += (5 - a[c]); c++; } cout << c; re... |
#include <bits/stdc++.h> using namespace std; const int oo = numeric_limits<int>::max(); const int n_oo = numeric_limits<int>::min(); const int ALF = 26; struct SuffixAutomaton { int toInt(char c) { return c - a ; } char toChar(int j) { return char(j + a ); } struct Nodo { vector<int> hijo... |
`define STATE_BYTE_START 3'h0
`define STATE_BYTE_WAIT_FOR_BUSY 3'h1
`define STATE_BYTE_WAIT_FOR_NOT_BUSY 3'h2
`define STATE_STOPPED 3'h3
`define MESSAGE "Hello, world!\r\n"
`define MESSAGE_LEN 15
`define MESSAGE_LEN_BITS `MESSAGE_LEN * 8
module hello(
input clk_5... |
#include <bits/stdc++.h> int main() { int n, input; int count = 1; int s = 3; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &input); if (input == 10) { if (s == 1) { count++; } s = 0; } else if (input == 1) { if (s == 0) { ... |
module ft245_sync_if
#(
parameter DEBUG=0, // Enable it for simulation
parameter EXTRA_READ_GUARD=0, // Add an extra guard in the bus turn-around after read
parameter FAST_WRITE_OLD=0, // Jump from WRITE_OLD to WRITE
parameter USE_STATE_RESET=0) // Add an extra state for the reset state
... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, A, B, x, y; while (cin >> x >> y >> A >> B) { int Count = 0; for (i = A; i <= x; i++) { for (j = B; j <= y; j++) { if (i > j) { Count++; } } } cout << Count << endl; ... |
/**
* 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 mod = 1e9 + 7; long long Bpow(long long a, long long s) { if (s == 0) { return 1; } long long u = Bpow(a, s / 2); if (s & 1) return u * u % mod * a % mod; else return u * u % mod; } int32_t main() { long long n; ... |
// Module SEQUENCER
//
// Author: Goran Devic
// https://baltazarstudios.com/poem-fpga/
//
// Sequences the ASCII character data from display ROM, through the font ROM, and out
// as a monochrome wire data
module TXT (
input clk, // Input 25.175 MHz clock, this is a pixel clock for this VGA mode
... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b) { return gcd(b, a % b); } else return a; } int main() { long long int l, r; cin >> l >> r; if (abs(l - r) < 2) { cout << -1 << endl; return 0; } long l... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300 + 10; int n, a[maxn], b[maxn]; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d , a + i); for (int i = 0; i < n; ++i) scanf( %d , b + i); vector<int> seq; for (int i = 0; i < n; ++i) if (b[i] != a[i])... |
// (C) 1992-2014 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 simulati... |
// -*- Mode: Verilog -*-
// Filename : adc.v
// Description : Behavioral ADC Model
// Author : Philip Tracton
// Created On : Wed Dec 16 12:36:20 2015
// Last Modified By: Philip Tracton
// Last Modified On: Wed Dec 16 12:36:20 2015
// Update Count : 0
// Status ... |
#include <bits/stdc++.h> using namespace std; template <class A, class B> inline bool mina(A &first, B second) { return (first > second) ? (first = second, 1) : 0; } template <class A, class B> inline bool maxa(A &first, B second) { return (first < second) ? (first = second, 1) : 0; } int mod_co... |
/*
* 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> int main() { long long int m, n, a; scanf( %lld %lld %lld , &m, &n, &a); if (m % a == 0 && n % a == 0) { printf( %lld , m * n / a / a); } if (m % a != 0 && n % a == 0) { printf( %lld , ((m + a) / a) * (n / a)); } if (m % a != 0 && n % a != 0) { pr... |
/*
* Copyright (c) 2000 Chris Lattner
*
* 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... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + ch - 0 ; ch = getchar(); } return ... |
#include <bits/stdc++.h> using namespace std; bool cmp(int u, int y) { return u > y; } int main() { int i, j; int n, m, x; int a[100009], b[100009]; int cnt; while (scanf( %d %d , &n, &x) != EOF) { for (i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n, cmp); for (i = 0; i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.