text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> #include<unordered_map> //#pragma GCC optimize(2) #define ll long long #define sc(n) scanf( %d ,&n) #define scl(n) scanf( %lld ,&n) //#define int ll using namespace std; inline int rd() { int x = 0, f = 1; char c = getchar(); while (c != - && c < 48)c = getchar(); if (c == - ... |
/**
* 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... |
/**
* This is written by Zhiyang Ong
* and Andrew Mattheisen
* for EE577b Troy WideWord Processor Project
*/
`timescale 1ns/10ps
/**
* `timescale time_unit base / precision base
*
* -Specifies the time units and precision for delays:
* -time_unit is the amount of time a delay of 1 represents.
* The time uni... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's Write-back Mux ////
//// ////
//// This file is part of the OpenR... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int n, x; cin >> n; int i = 0; while (n--) { cin >> x; if (x > b && x < c) i++; } cout << 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; int bs; int* cnt; int ans; class query { public: int l; int r; int index; }; bool cmp(const query a, const query b) { int s = a.l / bs; int e = b.l / bs; if (s == e) return a.r < b.r; return s < e; } void add(int x) { if ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> m; long long a[n], b[m]; for (long long i = 0; i < n; ++i) { cin >> a[i]; } for (long long i = 0; i... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9; const int len = (int)2e5; int a[len]; int main() { int k, n; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } string s; cin >> s; long long ans = 0; for (int i = 0; i < n; i++) { int ... |
#include <bits/stdc++.h> using namespace std; void qSort(long long **a, int first, int last) { long long i = first, j = last, x = a[(first + last) / 2][0]; do { while (a[i][0] < x) i++; while (a[j][0] > x) j--; if (i <= j) { if (i < j) { long long tmp0, tmp1; tm... |
#include <bits/stdc++.h> using namespace std; const int INF = numeric_limits<int>::max(); const long long LLINF = numeric_limits<long long>::max(); const unsigned long long ULLINF = numeric_limits<unsigned long long>::max(); vector<vector<int>> g; int main() { ios_base::sync_with_stdio(0); cin.tie(0... |
////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014, University of British Columbia (UBC); All rights reserved. //
// //
// Redistribution and use in source and binary forms, w... |
//
// Designed by Qiang Wu
// 16K bytes, 32bit interface
`timescale 1ns/1ps
module lr_old_IPV4(clk, raddr,waddr, data_in, data_out, we, reset);
input clk;
input [13:2] raddr;
input [13:2] waddr;
input [31:0] data_in;
output [31:0] data_out;
input [3:0] we;
input reset;
RAMB16_S4_2_altera localram0... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( avx2 ) #pragma GCC optimize( Os ) using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string str; long long i, j, k, x = 0, y = 0, n, m, t, sum ... |
#include <bits/stdc++.h> using namespace std; const int OO = 1e9; const double EPS = 1e-9; template <class T> void _db(const char* dbStr, T e) { cout << dbStr << = << e << endl; } template <class T, class... L> void _db(const char* dbStr, T e, L... r) { while (*dbStr != , ) cout << *dbStr++... |
#include <bits/stdc++.h> const double eps = (1e-9); using namespace std; int dcmp(long double a, long double b) { return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1; } int getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1; } int setBit1(int num, int idx) { return num | (1 << idx); } lon... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 2e5 + 5; inline int read() { int res = 0, ch, flag = 0; if ((ch = getchar()) == - ) flag = 1; else if (ch >= 0 && ch <= 9 ) res = ch - 0 ; while ((ch = getchar()) >= 0 && ch <= 9 ) res ... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 10; vector<int> tree[N]; int cnt[N]; int n, mx1, mx2; bool centr[N], ans[N]; int dfs(int v, int p = -1) { int u; cnt[v] = 1; for (int i = 0; i < tree[v].size(); i++) { u = tree[v][i]; if (u == p) continue; cnt[... |
#include <bits/stdc++.h> using namespace std; int num[100009]; int main() { int n; while (cin >> n) { for (int i = 0; i < n; ++i) cin >> num[i]; long long sum = n; long long count = 1; for (int i = 1; i < n; ++i) { if (num[i] == num[i - 1]) count++; else {... |
// diseño de una fifo ciclica, para implementar en cada bloque de proyecto
// ferney alberto beltran 2016 electrónica digital 1 universidad Nacional
module fifo
#(
parameter adr_width = 4,
parameter dat_width = 18
)
(
input clk, reset,
input rd, wr,
input [dat_width-1:0] data_in,
outpu... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, h, k, i, j, a[100100], pkp = 0, tmp, p, ans = 0; double d; scanf( %lld %lld %lld , &n, &h, &k); for (i = 0; i < n; i++) scanf( %lld , &a[i]); for (i = 0; i < n; i++) { if (pkp + a[i] <= h) { pkp += a[i]; ... |
#include <bits/stdc++.h> using namespace std; const int M = 105; int l[M], r[M], t[M], c[M], res[M], p[M]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> l[i] >> r[i] >> t[i] >> c[i]; } for (int i = 1; i <= n; ++i) p[i] = INT_MAX; for (int i = 0; i < m; ... |
// ==============================================================
// 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... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1000000000000000; const int mod = 1000000007; int n, m, k; int s[1000010]; long long a[1000010]; bool pos[1000010]; int lst[1000010]; long long get(int l) { int r = 0; int i = -1; long long res = 0; while (r < n) { ... |
///////////////////////////////////////////////////////////////////////////////
//
// 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... |
/*******************************************************************************
* This file is owned and controlled by Xilinx and must be used solely *
* for design, simulation, implementation and creation of design files *
* limited to Xilinx devices or technologies. Use with non-Xilinx ... |
#include <bits/stdc++.h> const long long inf = 0x3f3f3f3f; using namespace std; const long long maxn = 2e5 + 100; long long n, k; long long a[maxn]; int32_t main() { long long q; scanf( %lld , &(q)); while (q--) { scanf( %lld%lld , &(n), &(k)); long long maxx = 0, minn = 0x3f3f3f3f; ... |
#include <bits/stdc++.h> using namespace std; const int maxn(1e5 + 5); struct circle { int a, b; long long h; circle(){}; circle(int x) : a(0), b(x), h(0) {} inline void input() { cin >> a >> b >> h; } bool operator<(const circle &t) const { return b == t.b ? (a < t.a) : b < t.b; ... |
// Copyright (c) 2014 Takashi Toyoshima <>.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
module LEDSpartan3StarterKit(
// Clock Sources
CLK50MHZ,
SOCKET,
// Fast, Asynchronous SRAM
SRAM_A,
SRAM_WE_X,
SRAM_OE_X,... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int hr = s[0] - 0 ; hr = hr * 10 + s[1] - 0 ; if (hr >= 12) hr -= 12; int min = s[3] - 0 ; min = min * 10 + s[4] - 0 ; double b = min * 6; double a = ((double)hr + (double)min / 60) * 30; print... |
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2004 Xilinx, Inc.
// All Rights Reserved
////////////////////////////////////////////////////////////////////////////////
// ____ ____
// / /\/ /
// /___/ \ / Vendor: Xilinx
// \ \ \/ Version: 1.01
// ... |
`default_nettype none
module latch_002_gate (dword, vect, sel, st);
output reg [63:0] dword;
input wire [7:0] vect;
input wire [7:0] sel;
input st;
always @*
case (|(st))
1'b 1:
case ((((8)*(sel)))+(0))
0:
dword[7:0] <= vect[7:0];
1:
... |
#include <bits/stdc++.h> using namespace std; bool flag; long long Max = -1e18, tpMax = -1e18, dep[600005], a[600005]; int n, m, sz[600005], In[600005], TOT, LA[600005], NE[600005 << 1], EN[600005 << 1]; long long LE[600005 << 1]; void Link(int x, int y, int z) { EN[++TOT] = y; LE[TOT] = z; ... |
//Legal Notice: (C)2016 Altera Corporation. All rights reserved. Your
//use of Altera Corporation's design tools, logic functions and other
//software and tools, and its AMPP partner logic functions, and any
//output files any of the foregoing (including device programming or
//simulation files), and any associated do... |
Require Import Iron.Language.SystemF2Data.Exp.
Require Import Iron.Language.SystemF2Data.Step.Step.
(********************************************************************)
(* If we have a well typed case match on a data object then there
is a case alternative corresponding to that data constructor *)
Lemma getAlt_... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 20; int ans, a, m, n; long long ps0[N], ps1[N], arr[N], inf = 1e10 + 100; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> arr[0]; arr[n] = inf; ps0[0] = 0; for (int i = 1; i < n; i++) { cin >> arr[i]; ... |
// timer D
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
module cia_timerd
(
input clk, // clock
input clk7_en,
input wr, // write enable
input reset, ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
module top (
input CLK,
input BTN_N, BTN1, BTN2, BTN3,
output LED1, LED2, LED3, LED4, LED5,
output P1A1, P1A2, P1A3, P1A4, P1A7, P1A8, P1A9, P1A10,
output P1B1, P1B2, P1B3, P1B4, P1B7, P1B8, P1B9, P1B10
);
wire [7:0] ss_top, ss_bot;
reg [7:0] disp_top = 0, disp_bot = 0;
reg [7:0] lap_top = 0, lap_bot = 0;
reg... |
//Legal Notice: (C)2017 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 do... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11:07:08 03/14/2015
// Design Name:
// Module Name: deserializer_gen_test
// Project Name:
// Target Devices:
// Tool versions:
// Description:
... |
/**
* 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> const double eps = 1e-8; const int oo = 0x3f3f3f3f; using namespace std; long long a, b, c, d; bool read() { if (!(cin >> a >> b >> c >> d)) return false; return true; } void process() { cout << b << << c << << c << endl; } int main() { ios_base::sync_with_st... |
/**
* 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 binary_exp(long long int a, long long int n) { long long int i = 1; while (n > 0) { if (n % 2 == 1) i = (i * a) % 1000000007; a = (a * a) % 1000000007; n /= 2; } return i; } long long int IsPrime(long long int n) { ... |
/*
* 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 ... |
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2017.3 (lin64) Build Wed Oct 4 19:58:07 MDT 2017
// Date : Tue Oct 17 19:49:26 2017
// Host : TacitMonolith running 64-bit Ubuntu 16.04.3... |
#include <bits/stdc++.h> int main() { long long int a, b, c, d, x; int t; scanf( %d , &t); while (t--) { scanf( %lld%lld%lld%lld , &a, &b, &c, &d); x = a / d + (((a / d) / b) * c); printf( %lld n , x); } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> even_bag, odd_bag; int n, all, x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; all += x; if (x & 1) odd_bag.push_back(x); else even_bag.push_back(x); } cout << ((all & 1) ? odd... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 02/13/2016 08:15:39 PM
// Design Name:
// Module Name: CLA_Adder
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 305; vector<pair<int, int> > e; vector<int> b; int a[MAXN]; bool mark[MAXN], x[MAXN][MAXN]; int n, k, m, cnt; void add(int u, int v) { if (x[u][v]) return; cnt++; e.push_back(pair<int, int>(u, v)); x[u][v] = x[v][u] = true; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a[6]; for (int i = 0; i < 6; i++) cin >> a[i]; a[5]++; int mn = 100000; for (int i = 0; i < 6; i++) { if (i == 4) continue; if (mn > a[i]) mn = a[i]; } cout << (mn > a[4] ? mn - a[4] : 0) << endl; return 0; ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; reverse(b.begin(), b.end()); cout << atoi(a.c_str()) + atoi(b.c_str()) << endl; } |
module jtflipfloptb;
wire q, qbar;
reg clk,rst;
reg t;
jtflipflop jtff(q,qbar,clk,rst,t);
always #5 clk = ~clk;
initial
begin
clk = 1'b0;
rst = 1; # 10; rst = 0; #10;
$display("RSLT\tt\tq\tqbar");
t = 0; # 10; // Another value
if ( q === 1'b0 ) // Test for i... |
module top (
input wire clk,
input wire sw,
output wire led
);
wire O_LOCKED;
wire RST;
wire clk0;
wire clk1;
wire clk_out;
wire clk_fb_i;
wire clk_fb_o;
reg [25:0] cnt;
assign RST = 1'b0;
BUFG bufg0 (
.I(clk_fb_i),
.O(clk_fb_o)
);
wire c... |
#include <bits/stdc++.h> using namespace std; char s[1000002]; int o = 0, len; int main() { cin >> s; if ((s[0] == 1 ) && (strlen(s) == 1)) { cout << 0; return 0; } for (int i = strlen(s); i >= 0; i--) { s[i + 1] = s[i]; } s[0] = 0 ; int i = strlen(s) - 1; whi... |
#include <bits/stdc++.h> using namespace std; list<int> adjList[200002]; int depth[200002]; int sz[200002]; class LCA_binary { int logn, timer; vector<int> tin, tout; vector<vector<int>> up; public: void innerdfs(int v, int p) { tin[v] = ++timer; up[v][0] = p; for (int ... |
//////////////////////////////////////////////////////////////////////
//// ////
//// Generic Single-Port Synchronous RAM ////
//// ////
//// This file is part of memory li... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int ans = 0; while (n % 3 == 0 || n % 6 == 0) { if (n % 6 == 0) { n /= 6; ans++; } else if (n % 3 == 0) { n /= 3; ans += 2; } } if (n != 1) { cout << -1 << en... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
//*****************************************************************************
// (c) Copyright 2008 - 2010 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
/... |
/*
* 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> inline long long pow(long long a, long long b, long long mod) { long long ans = 1; a %= mod; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } struct Node { int L, R; mutable long long val; Node(int L, int R = -1, long long... |
#include <bits/stdc++.h> using namespace std; bool comparator(string a, string b) { if (a.size() == b.size()) { return a > b; } return a.size() > b.size(); } int main() { int n, m; cin >> n >> m; string mat[n]; for (int i = 0; i < n; i++) { cin >> mat[i]; } vector... |
#include <bits/stdc++.h> using namespace std; inline int Read() { int x(0); char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + c - 0 , c = getchar(); return x; } const int maxn = 1e5 + 9, mod = 998244353, maxm = 409; int n,... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (n - 1) * 2 + 1 << << 2 << endl; cout << 1 << << 2 << endl; } |
`timescale 1ns / 1ps
//ALU para numeros de 32 bits con signo.
/*
* Números de 32 bits donde, si a es número, entonces:
* a[31] : signo de a.
* a[30:10] : parte entera de a.
* a[9:0] : parte decimal de a.
*/
module ALU(
input wire [31:0] a,
input wire [31:0] b,
input wire [3:0] s,
output reg [31:0] Z... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; long long ar[n]; for (int i = 0; i < n; i++) cin >> ar[i]; int maxi = -1000000001; long long sum = 0; for (int i = 0; i < n; i++) { if (ar[i] > max... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::pair<T, U> operator+(const std::pair<T, U>& l, const std::pair<T, U>& r) { return {l.first + r.first, l.second + r.second}; } typedef void (*callback_function)(void); const long long ZERO = 0LL; const long long INF64 ... |
// This part should pass OK
module t_lint_pragma_protected;
`pragma protect begin_protected
`pragma protect version=1
`pragma protect encrypt_agent="XXXXX"
`pragma protect encrypt_agent_info="YYYYY"
`pragma protect data_method="AES128-CBC"
`pragma protect key_keyowner="BIG3#1"
`pragma protect key_keyname="AAAAAA"
`pr... |
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2015.4 (lin64) Build Wed Nov 18 09:44:32 MST 2015
// Date : Thu Apr 14 23:40:55 2016
// Host : Dries007-Arch running 64-bit unknown
// Com... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 14:09:37 08/01/2014
// Design Name:
// Module Name: main
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependenci... |
#include <bits/stdc++.h> using namespace std; long long N, Q, S[(int)1e5 + 5], i, L, R, p1, p2; long long Putere(long long p1, long long ex) { long long i, sol = 1; for (i = 0; (1 << i) <= ex; i++) { if (((1 << i) & ex) > 0) sol = (sol * p1) % 1000000007; p1 = (p1 * p1) % 1000000007; } ... |
#include <bits/stdc++.h> using namespace std; char s[200005]; int n, k; int main() { scanf( %d%d , &n, &k); scanf( %s , s); if (n == 1) { if (k == 0) printf( %c n , s[0]); else printf( 0 n ); } else { if (k == 0) printf( %s n , s); else { i... |
#include <bits/stdc++.h> using namespace std; const int N = 2005; char s[N]; int main() { int T; scanf( %d , &T); while (T--) { int n, k; scanf( %d%d , &n, &k); scanf( %s , s); getchar(); vector<int> cnt(27, 0); for (int i = 0; i < n; ++i) ++cnt[s[i] - a ]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; double t = 0; cin >> n; int i, a[n], b[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < n; i++) { b[i] = a[n - 1 - i]; } for (i = n - 1; i >= 0; i--) { if (i % 2 == 0) t ... |
module LCD_Driver(
input LCLK, //LCD CLK
input RST_n,
output reg HS,
output reg VS,
output DE,
output reg [9:0] Column,
output reg [9:0] Row,
output reg SPENA,
output reg SPDA_OUT,
input SPDA_IN,
output reg WrEn,
output reg SPCK,
input [7:0] Brightness,
input [7:0] Contrast
);
reg... |
/**
* 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, a, b, i, j, k, sum = 0; scanf( %d%d%d , &n, &a, &b); int arr[n]; for (i = 0; i < n; i++) scanf( %d , &arr[i]); for (i = 0, j = n - 1; i <= j; i++, j--) { if (i != j && arr[i] != arr[j] && arr[i] != 2 && arr[j] != 2) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; double x, cx; cin >> n >> x; cx = x; double a[n + 1], b[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == 1) { cout << -1; return 0; } } for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 300010; long long n, a[N], t; map<long long, bool> vis; int solve() { scanf( %lld , &t); while (t--) { scanf( %lld , &n); vis.clear(); bool imp = 0; for (int i = 1; i <= n; i++) { scanf( %lld , &a[i]); ... |
#include <bits/stdc++.h> using namespace std; template <class T> void miz(T &a, T b) { if (b < a) a = b; } template <class T> void maz(T &a, T b) { if (b > a) a = b; } template <class T> void clear(T &x) { T t; x.swap(t); } template <class T> T gcd(T a, T b) { while (b) { ... |
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Robert Armstrong
*
* 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... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; int flag = 0; vector<char> arr(26, . ); for (int i = 0; i < s.length(); i++) { int a = int(s[i]); int b = int(t[i]); if (arr[a - 97] == t[i] || arr[a - 97] == . ) { arr[a - 97] = t[... |
// File: FramerCtrl.v
// Generated by MyHDL 0.8dev
// Date: Fri Dec 21 15:02:39 2012
`timescale 1ns/10ps
module FramerCtrl (
SOF,
state,
syncFlag,
clk,
reset_n
);
// Framing control FSM.
//
// SOF -- start-of-frame output bit
// state -- FramerState output
// syncFlag -- sync pattern found indic... |
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const int N = 300010; int n, m, ans, ansx, ansy, s1, s2, max1; struct aa { int x, y, w; } a[N], b[N << 1]; multiset<int> q1, q2; void Init(int &x) { char y; while ((y = getchar()) < 0 || y > 9 ) ; x = y - ... |
#include <bits/stdc++.h> using namespace std; int b[255]; int main() { string a; cin >> a; for (int i = 0; i < a.size(); i++) { b[a[i]]++; } int u = b[ a ] - 1 + b[ a ]; int u2 = a.size(); cout << min(u, u2); return 0; } |
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <limits> #include <queue> #include <set> #include <sstream> #include <stack> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef vector<int... |
#include <bits/stdc++.h> using namespace std; template <typename T> void chkMax(T &x, T y) { if (y > x) x = y; } template <typename T> void chkMin(T &x, T y) { if (y < x) x = y; } template <typename T> void inline read(T &x) { int f = 1; x = 0; char s = getchar(); while (s < 0... |
// Copyright (c) 2000 Stephen Williams ()
//
// This source code is free software; you can redistribute it
// and/or modify it in source code form under the terms of the GNU
// General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option)
// ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int dot = -1; for (int i = 0; i < (int)(s).size(); ++i) { if (s[i] == . ) { dot = i; } } int deg = 0; if (dot == -1) { deg = (int)(s).size(); string t = 0. + s; s = t; ... |
//////////////////////////////////////////////////////////////////////
//// ////
//// eth_transmitcontrol.v ////
//// ////
//// This file is part of the Ether... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 19:51:58 06/19/2016
// Design Name:
// Module Name: BM_dut
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependen... |
#include <bits/stdc++.h> using namespace std; int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[9] = {0, 1, 0, -1, 1, -1, 1, -1}; struct edge { int st, ed; char col; edge() { this->st = 0; this->ed = 0; this->col = 0; } edge(int st, int ed, char col) { this->st = st; ... |
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1e9 + 7; const long long int MAXN = 100010; long long int par[MAXN], nxt[MAXN]; int find_root(int a) { if (par[a] == a) { return a; } int f = par[a]; par[a] = find_root(par[a]); nxt[a] = (nxt[a] + nxt[f]) % MOD; ... |
#include <bits/stdc++.h> using namespace std; long long ans = 0; long long mod = 1e9 + 7; int cnt[100005], Tcnt[100005], arr[100005]; vector<int> pri; void era() { pri.push_back(2); for (int i = 3; i <= 100000; i += 2) { if (!arr[i]) for (long long j = (long long)i * i; j <= 100000; j ... |
//Legal Notice: (C)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 associate... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e8; const int N = 300100; int n, m, ans, nans; string mat[N], ansmat[N], nmat[N]; void upd() { if (nans >= ans) return; ans = nans; for (int i = 0; i < n; ++i) ansmat[i] = nmat[i]; } int main() { cin.tie(NULL); ios_base::... |
#include <bits/stdc++.h> using namespace std; char s[1000010]; int c[20]; int main() { int k; scanf( %d , &k); scanf( %s , s + 1); int n = strlen(s + 1); int sum = 0; int i; memset(c, 0, sizeof c); int ans = 0; for (i = 1; i <= n; i++) { c[s[i] - 0 ]++; sum += s[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.