text stringlengths 59 71.4k |
|---|
/**
* 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; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve() { int n, k, d; cin >> n >> k >> d; vector<int> dist(n, -1); vector<vector<pair<int, int>>> za(n); vector<int> keep(n - 1), par(n); queue<int> q; for (int i = ... |
// Modified 2010 by Matt Ettus to remove old verilog style and
// allow 16-bit operation
//////////////////////////////////////////////////////////////////////
//// ////
//// spi_top.v ////
//// ... |
`include "reg_define.v"
`include "version.v"
module AXI2SREG
(
clk,
rst,
en,
wen,
din,
dout,
addr,
ien,
oen,
async,
tddmode,
ibase,
isize,
obase,
osize,
frame_len,
frame_adj,
tstart,
tend,
rstart,
rend,
iacnt,
ibcnt,
oacnt,
obcnt,
test,... |
/**
* 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() { int n, k; cin >> n >> k; int i1, i2, a1, a2; cout << ? ; for (int i = 1; i <= k; ++i) cout << i << ; cout << n ; cout.flush(); cin >> i1 >> a1; cout << ? ; for (int i = 1; i <= k + 1; ++i) { if (i == i1... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const long long Inf = 0x3f3f3f3f3f3f3f3f; int n, x, y, z, cnt, tot, head[maxn], vis[maxn]; long long res, r[maxn], l[maxn], l0[maxn], r0[maxn], sum[maxn], ans1, ans2 = Inf, f[maxn], cir[maxn]; struct Edge { int to, next, w; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(0); int opx, t, c; cin >> t >> c; int dfx = 1; long long lorenzo = 0; while (c--) { cin >> opx; if (dfx != 1) lorenzo += t - dfx + 1; dfx = opx + 1; } cout << lorenzo; ... |
#include <bits/stdc++.h> using namespace std; int x, s, t; int main(void) { cin >> t >> s >> x; int a = (x - t) / s; if (t == x) { cout << YES << endl; } else if (a <= 0) { cout << NO << endl; } else if (t + a * s == x || t + a * s + 1 == x) { cout << YES << endl; }... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const double eps = 1e-9; const double pi = acos(-1); struct P { int x, y; } a[N]; int n, vi[N], t[N]; double l[N], r[N], q[N]; long long k; void change(int k, int v) { for (; k; k -= k & (-k)) t[k] += v; } int ask(int k)... |
#include <bits/stdc++.h> using namespace std; void BFS(double, double, double &a); double pSquares(double, double); double n, m, k, r; struct queue_compare { bool operator()(const pair<double, double> &p1, const pair<double, double> &p2) const { return pSquares(p1.first, p1.secon... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company: California State University San Bernardino
// Engineer: Bogdan Kravtsov
// Tyler Clayton
//
// Create Date: 11:35:36 10/17/2016
// Module Name: REG_tb
// Project Name: MIPS
/... |
#include <bits/stdc++.h> using namespace std; int main(void) { long long int n = 0ll, k = 0ll, p = 0ll, pn = 0ll, even = 0ll, odd = 0ll; while (cin >> n) { cin >> k >> p; if (k == 0) { for (long long int i = 0; i < p; i++) { cin >> pn; cout << . ; } c... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> bpow = {{1, 1}}; struct HashArr { const long long base = 137137, mod[2] = {(int)1e9 + 7, (int)1e9 + 9}; vector<pair<long long, long long>> h; void init(vector<int>& a) { int n = a.size(); h.resize(n + 1); ... |
// ***************************************************************************
// ***************************************************************************
// 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; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int y, b, r; int l, m, n; int ans; cin >> y >> b >> r; l = y; m = b; n = r; int mins = min(min(y, b), r); if (mins == r) { ans = r + (r - 1) + (r - ... |
// ====================================================================
// 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 t; cin >> t; while (t--) { int n; cin >> n; int a[n], b[n], o = 0, z = 0, sorted = 1; for (int i = 0; i < n; i++) { cin >> a[i]; if (i > 0 && a[i] < a[i - 1]) sorted = 0; } for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; vector<int> a; int k, t, n, mx; string s; int main() { cin >> n >> k; cin >> s; for (int i = 0; i < s.size(); i++) if (s[i] == . ) a.push_back(i); for (int i = 0; i < a.size() - 1; i++) mx = max(mx, a[i + 1] - a[i]); if (mx > k) co... |
//-----------------------------------------------------------------------------
// The way that we connect things in low-frequency read mode. In this case
// we are generating the unmodulated low frequency carrier.
// The A/D samples at that same rate and the result is serialized.
//
// Jonathan Westhues, April 2006
//... |
#include <bits/stdc++.h> using namespace std; long long n = 0, m = 0, q = 0; long long ans = 0; vector<vector<int>> G = vector<std::vector<int>>(100001); vector<long long> f(112345), fa(100001), dep(100001), val(100001), sz(100001), s(100001); long long F(long long x) { return x == f[x] ? x : (f[x] = ... |
#include <bits/stdc++.h> using namespace std; void prv(vector<int> v) { int n = v.size(); for (int i = 0; i < n; i++) cout << v[i] << ; } void swap(long long int &a, long long int &b) { int tm = a; a = b; b = tm; } bool comp(const pair<int, int> &p1, const pair<int, int> &p2) { if... |
// 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 : Mon Jun 05 10:58:35 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... |
// megafunction wizard: %LPM_DIVIDE%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: lpm_divide
// ============================================================
// File Name: DIV.v
// Megafunction Name(s):
// lpm_divide
// ============================================================
// ************************... |
/*============================================================================
This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point
Arithmetic Package, Release 1, by John R. Hauser.
Copyright 2019 The Regents of the University of California. All rights
reserved.
Redistribution an... |
`include "nettype.h"
`include "global_config.h"
`include "stddef.h"
`include "isa.h"
`include "cpu.h"
module if_reg (
input wire clk,
input wire reset,
input wire [`WordDataBus] insn,
input wire stall,
input wire flush,
input wire [`WordAddrBus] new_pc,
i... |
// ***************************************************************************
// ***************************************************************************
// 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; char ans[1000000]; int main() { int n, c, k = 1, u = 0, w = 1, h = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int m = 0; while (w) { u = 0; for (int i = 0; i < n; i++) { if (a[i] == 0) u++; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int n, m; struct bian { int from, to; }; struct tree { bian eg[N << 2]; int num, front[N << 1]; int zong; int fa[N << 1], siz[N << 1]; void add(int x, int y) { eg[++num].to = y; eg[num].from = front[x];... |
`timescale 1ns / 1ps
module spi_amba_connector(
input clk,
input rst,
input hwrite,
input [31:0] hwdata,
input [31:0] haddr,
input hsel,
output [31:0] hrdata,
input [ 7:0] spi_data_out,
input spi_busy,
... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; if (n <= 30) { cout << NO n ; } else if (n == 36) { cout << YES n ; cout << 5 6 10 15 ... |
module TopLevel (
input wire clk,
input wire rst_in,
input wire[3:0] switch_in,
output wire buzzer,
output wire[3:0] led_out,
inout wire ps2CLK_in,
input wire ps2DATA_in,
//output wire vgaR_out,
//output wire vgaG_out,
//output wire vgaB_out,
//output wire vgaHSYNC_out... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9; int n, m; long long a[200100], fibo[200100], sumfibo[200100]; struct Segment_Tree { int left, right, len; long long s0, s1; } tree[200100 << 2]; struct Data { long long a[2][2]; } bb[200100], one, b; Data operator*(const Da... |
/*
* 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... |
/*
* 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 l1, l2, r1, r2, k; int main() { cin >> l1 >> r1 >> l2 >> r2 >> k; if (l2 > r1 || r2 < l1) { cout << 0 << n ; return 0; } long long l, r; if (r1 < r2) { r = r1; } else { r = r2; } if (l1 > l2) { ... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: dcfifo
// ============================================================
// File Name: fifo_128x512a.v
// Megafunction Name(s):
// dcfifo
//
// Simulation Library Files(s):
// altera_mf
// =============================... |
// ----------------------------------------------------------------------
// Copyright (c) 2015, 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:... |
`include "mux.v"
`include "addsub32.v"
`include "shifter.v"
module alu(
input [31:0] a,
input [31:0] b,
input [3:0] aluc,
output [31:0] r,
output zero,
output carry,
output negative,
output overflow
);
reg zero_temp;
reg carry_temp;
reg negative_temp;
reg overflow_temp;
reg [31:0] r_temp;
assign r=r_temp;
assign z... |
/**
* 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; struct num { static const int MA = 1e9 + 7, MB = 1e9 + 9; int a, b; num() {} num(int x) : a(x), b(x) {} num(int a, int b) : a(a), b(b) {} num operator+(const num& x) const { return num((a + x.a) % MA, (b + x.b) % MB); } num operator... |
/**
* 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: DEMUX1_4_DMS_TBV.v
// Generated by MyHDL 0.10
// Date: Sun Sep 23 18:24:21 2018
`timescale 1ns/10ps
module DEMUX1_4_DMS_TBV (
);
// myHDL -> testbench for module `DEMUX1_4_DMS`
reg x = 0;
wire y0;
wire y1;
reg s0 = 0;
reg s1 = 0;
wire y2;
wire y3;
wire [17:0] xTV;
wire [17:0] s0TV;
wire [17:0] s1TV;
wire... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
//
`timescale 1ns/1ps
module test_afifo
();
parameter DEPTH = 8, ADDRESS_WIDTH = 3, WIDTH=8;
parameter clk_period = 2;
parameter half_period = 1;
reg CLK;
reg REN;
reg WEN;
reg RESET;
reg valid;
reg [WIDTH-1:0] Data_in [DEPTH-1:0];
wire [WIDTH-1:0] Data_out [DEPTH-1:0];
wire [DEPTH-1:0] Full_out;
wire [DEPTH-1:0] ... |
//
// Copyright (c) 2014 Colin Rothwell
// Copyright (c) 2014 A. Theodore Markettos
// All rights reserved.
//
// This software was developed by SRI International and the University of
// Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
// ("CTSRD"), as part of the DARPA CRASH research programme... |
#include <bits/stdc++.h> using namespace std; bool isrange(int second, int first, int n, int m) { if (0 <= second && second < n && 0 <= first && first < m) return true; return false; } int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1}, ddy[8] = {1, 0, -1, 0, 1, 1, -1, -1}, ddx[8] = {0, 1, 0, -1, 1,... |
#include <bits/stdc++.h> using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector<int> c0(n, 0); std::vector<int> c1(n, 0); for (int i = 0; i < n; i++) { ... |
//caution do not edit this file manually it is a template in tenjin format
`define Buff_size 32
////////////////////////////////////////////
#{MODULE_TEXT}
///////////////////////////////////////////
input clk; // 50MHz
input rst_n; //reset, neg edge.
input rs232_rx; // RS232 rec
//output rs232_tx; // RS232 transfer
/... |
//
// Copyright (c) 1999 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)
// ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Create Date: 21:13:46 07/24/2014
// Design Name: EMU Device
// Module Name: DigiMic_Interface
//////////////////////////////////////////////////////////////////////////////////
module DigiMic_Interface... |
#include <bits/stdc++.h> using namespace std; const bool debug = false; const int maxn = 1002003; const long long magic = 1000 * 1000 * 1000 + 7; int n, k; long long aa[maxn]; struct RMQ { int l, r; RMQ *left, *right; long long res; int resIndex; }; RMQ* build(long long* vs, int l, int... |
// TOOL: vlog2tf
// DATE: Wed May 28 10:38:34 2014
// TITLE: Lattice Semiconductor Corporation
// MODULE: Section5_Top
// DESIGN: Section5_Top
// FILENAME: Section5_Top_tf.v
// PROJECT: Unknown
// VERSION: 2.0
// This file is auto generated by the Diamond
`timescale 1 ms / 1 ms
// Define Module ... |
/*
main function:
1)allocate cpuid for pkt by the key
2)only achive round robin mode in this version
tips: all fifo are showahead mode
*/
`timescale 1 ps / 1 ps
module DISPATHER_INPUT(
input clk,
input reset,
//--------------------------------CPUID Manage Module-------------------------
input [4:0] in_cpuid,//id of c... |
module ringbuffer #(parameter AW = 8, DW = 48)
(
input reset,
input clock,
input read_clock_enable,
input write_clock_enable,
output [DW-1:0] read_data,
input [DW-1:0] write_data,
output reg empty,
output reg overflow);
reg [AW-1:0] next_write_addr;
reg [AW-1:0] read_addr;
reg [AW-1:0] write_addr;... |
#include <bits/stdc++.h> using namespace std; const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 9; int n, k, indx[10], ans = OO; char arr[10][10]; int num(int r) { int ret = 0; for (int i = 0; i < k; ++i) { ret = ret * 10 + (arr[r][indx[i]] - 0 ); } return ret; } int main() { ... |
#include <iostream> #include <vector> #include <string> #include <cstring> #include <cmath> #include <climits> #include <algorithm> #include <map> #include <stack> #include <unordered_map> #include <set> #include <unordered_set> #include <utility> #include <iomanip> using namespace std; ... |
#include <bits/stdc++.h> using namespace std; const unsigned long long Mode = 1e9 + 7; void Modulo(unsigned long long &x) { x = ((x % Mode + Mode) % Mode); } unsigned long long Pow(unsigned long long x, unsigned long long y) { unsigned long long res = 1; for (unsigned long long i = 0; (1ULL << i) <= y; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int maxn = 2 * 1e5; char s[maxn]; int n; int l, r; int is_pal(int l, int r) { for (int i = l; i <= (r + l) / 2; i++) { if (s[i] != s[r - (i - l)]) return 0; } return 1; } int main() { cin >> (s + 1); r =... |
#include <bits/stdc++.h> #pragma GCC target( avx,tune=native ) using namespace std; template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << [ ; for (auto const &vv : V) os << vv << , ; os << ] ; return os; } template <class L, class R> ostream &operator<<(ostream &os, p... |
/**
* 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 int con = 0; vector<pair<long long int, long long int> > v; long long int t[5000][5001]; vector<vector<pair<long long int, long long int> > > ans(5001); bool istrue[5001]; vector<long long int> a[5001]; long long int dis[5001]; int n; int ppp =... |
/*
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... |
#include <bits/stdc++.h> using namespace std; const int mn = 2010; long long a[mn], b[mn]; int main() { int n, k; long long p; scanf( %d %d %lld , &n, &k, &p); for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); for (int i = 1; i <= k; i++) scanf( %lld , &b[i]); sort(a + 1, a + n + 1); ... |
#include <bits/stdc++.h> const int MaxN = 1000; using namespace std; char s[MaxN + 5]; int n; int vis[200 + 5]; int main() { while (~scanf( %d , &n)) { scanf( %s , s + 1); int Max = 0; for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { memset(vis, 0, sizeof... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n, k; cin >> n >> k; for (int i = 1; i <= k; ++i) cout << 2 * i << << 2 * i - 1 << ; for (int i = 2 * k + 1; i <= 2 * n; ++i) cout << i << ; return 0; } |
#include <bits/stdc++.h> using namespace std; int a[5001], n; int dfs(int l, int r) { int Min = a[l], ans = 0; for (int i = l + 1; i <= r; i++) Min = min(Min, a[i]); ans = Min; for (int i = l; i <= r; i++) a[i] -= Min; for (int i = l; i <= r; i++) if (a[i]) { int tmp = i + 1; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { register int x = 0, f = 1, ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * f; } int n; int a[1010]; int b[10... |
/*
* 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 DP[1000000]; long long counter[1000000]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; counter[x]++; } DP[0] = 0; DP[1] = counter[1]; for (int i = 0; i < 1000000; i++) { DP[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 20; long long a[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, sum = 0, mx = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; mx = max(mx, a[i]); sum += a[i]; }... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; unsigned long long ans = 0; for (int i = 0; i < s.size(); i++) { int x = s[i] - 0 ; if (x % 4 == 0) ans++; if (i > 0) { x += 10 * (s[i - 1] - 0 ); if (x % 4 == 0) ans += i; } ... |
#include<bits/stdc++.h> using namespace std; namespace program { const int N = 100005; struct edge { int to, nxt; edge() {} edge(int to_, int nxt_): to(to_), nxt(nxt_) {} } e[N << 1]; int hd[N], cnt, fir[N], end[N]; vector<pair<int, int> > del, ins; void adde(int u, int v) {... |
/**
* 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 arr[200005], arr2[200005], n, repeat = 1, maxi, mas; long double result[200005]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); } for (int i = 0; i < n; i++) { scanf( %d , &arr2[i]); if (arr[i]... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, mid, ans = 0; int all[100001]; all[0] = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> a; all[i] = all[i - 1] + a; } if (all[n] % 2 == 1) { cout << 0; return 0; } mid = all[n] / 2; ... |
#include <bits/stdc++.h> using namespace std; const long double ESP = 1E-8; long double cal(long double x, long double y, long double z) { return log(x) * pow(y, z); } long double ca(long double x, long double y, long double z) { return y * z * log(x); } int main() { const char* result[12] = {... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> g[100005]; int dep[100005], f[20][100005], mrk[100005], ans[100005]; map<pair<int, int>, int> mp; void dfs(int x, int p, int d) { for (int i = 0; i < g[x].size(); i++) if (g[x][i] != p) dfs(g[x][i], f[0][g[x][i]] = x, dep[g[x][i]] = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < 10; i++) { } set<int> s(a.begin(), a.end()); if (s.size() < k) { cout << NO << endl; } else { ... |
#include <bits/stdc++.h> using namespace std; vector<int> vec[100010]; long long a[100010]; long long s; int n; long long dfs(int f, int u, long long val) { int sz = vec[u].size(), v; long long ret = 0, mv = ((long long)1e18), tmp; if (sz == 1 && vec[u][0] == f) return (a[u] = ((val) < (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 fx[] = {1, -1, 0, 0}; int fy[] = {0, 0, 1, -1}; int main() { long long n; cin >> n; if (n == 1) cout << 1; else if (n == 2) cout << 3; else { n += 3; long long a = 0, b = 1; for (int i = 2; i <= n; i++) { ... |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2015.1
// Copyright (C) 2015 Xilinx Inc. All rights reserved.
//
// ==============================================================
`timescale 1ns/1ps
... |
#include <bits/stdc++.h> using namespace std; int n, m = 3, l, c[20000]; char s[500]; int main() { cin >> n; while (c[m] <= n) m++, c[m] = (long long)m * (m - 1) * (m - 2) * (m - 3) / 24; for (int i = m - 1; i >= 1; i--) { while (c[i] >= 1 && n >= c[i]) { s[++l] = a ; n -= c[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 = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const double eps = 1e-12; const double PI = acos(-1.0); const int mod = 998244353; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } long long gcd(long long a, long long b) { r... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2011(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// a... |
// DO NOT EDIT
// This file is automatically generated!
// $ smg.shen rtl/SMG/kseq.smg
//
// https://github.com/sam-falvo/smg
module kseq(
input ram_wait_i,
input cfg,
input t5,
input t4,
input t3,
input t2,
input t1,
input wb_we_i,
input t0,
input wb_cyc_i,
input wb_stb_i,
inp... |
#include <bits/stdc++.h> int main(void) { int matrix[12][12]; memset(matrix, 0, sizeof(matrix)); int i; char s[3]; int col_r, row_r, col_k, row_k; scanf( %s , s); col_r = s[0] - a + 2; row_r = s[1] - 1 + 2; scanf( %s , s); col_k = s[0] - a + 2; row_k = s[1] - 1 + 2;... |
#include <bits/stdc++.h> const int MAXN = 2e6 + 5; using namespace std; pair<int, int> arr[MAXN]; bool cmp(const pair<int, int> a, const pair<int, int> b) { return a.second > b.second; } int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 0; i < m; i++) { int q, w; scanf(... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char ch = getchar(); while (ch - 0 < 0 || ch - 0 > 9) { if (ch == - ) f = -1; ch = getchar(); } while (ch - 0 >= 0 && ch - 0 <= 9) { x = x * 10 + ch - 0 ; ch = getchar(); } retu... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1 << 18; int n, r; double sum = 0; long long c[MAXN + 10]; int main() { scanf( %d%d , &n, &r); for (int i = 0; i < (1 << n); i++) { scanf( %lld , &c[i]); sum += c[i]; } double dv = 1 << n; printf( %.9lf n , sum / ... |
#include <bits/stdc++.h> using namespace std; 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) { return (a / gcd<T>(a, b) * b); } long long pwr(long long base, long long p) { long long ans = 1; while (p) { if (p & 1) ... |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << = << a << endl; err(++it, args...); } const long long MOD = 1e9 + 7; long long modExp(long lo... |
//altiobuf_out CBX_AUTO_BLACKBOX="ALL" CBX_SINGLE_OUTPUT_FILE="ON" DEVICE_FAMILY="Stratix IV" ENABLE_BUS_HOLD="FALSE" NUMBER_OF_CHANNELS=1 OPEN_DRAIN_OUTPUT="FALSE" PSEUDO_DIFFERENTIAL_MODE="TRUE" USE_DIFFERENTIAL_MODE="TRUE" USE_OE="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN1="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN2="FALSE" USE_T... |
#include <bits/stdc++.h> using namespace std; const int N = 605; int dp[N][N]; int l[N], r[N]; string res; void fill(int i, int j, int a, int b) { int k = j - i; if (i > j || a > b) return; if (l[i] <= 2 * k + 1 && 2 * k + 1 <= r[i] && (i == j || dp[i + 1][j])) { res[a] = ( , res[b] = ) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int x, y; cin >> x >> y; int ans = 0; int d = max(abs(x), abs(y)); if (d == 0) { cout << 0 << n ; return 0; } else ans = (d - 1) * 4; if (... |
#include <bits/stdc++.h> using namespace std; string s; int pos[1000]; int n, a, b; int main() { cin >> n; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == x ) a++; else b++; } cout << abs(n / 2 - a) << endl; int t = abs(n / 2 - a); if (a > b)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.