text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int arr[MAXN]; int main() { int N, ans = 0; cin >> N; for (int i = 0; i < N; i++) cin >> arr[i]; sort(arr, arr + N); for (int i = 0, j = 1; i < N; i++) { while (arr[i] >= arr[j] && j <= N - 1) j++; if (j == ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int P; cin >> P; cout << 2 << << P - 1 << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { map<int, bool> hash; int p, n; bool has = false; cin >> p >> n; for (int i = 0; i < n; i++) { int x; cin >> x; x %= p; if (hash.count(x) && !has) { cout << i + 1 << endl; has = true; } else {... |
`define IDX(x) (((x)+1)*(32)-1):((x)*(32))
`define E0(x) ( {{x}[1:0],{x}[31:2]} ^ {{x}[12:0],{x}[31:13]} ^ {{x}[21:0],{x}[31:22]} )
`define E1(x) ( {{x}[5:0],{x}[31:6]} ^ {{x}[10:0],{x}[31:11]} ^ {{x}[24:0],{x}[31:25]} )
`define CH(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) )
`define MAJ(x,y,z) ( ((x) & (y)) | ((z) & ((x) | (... |
#include <bits/stdc++.h> using namespace std; int t, ans, tot, pus, a, b, c, d; int main() { register int i; scanf( %d , &t); while (t--) { scanf( %d%d%d%d , &a, &b, &c, &d); ans = a * (b - d - 1); ans = ((ans) > (a * d) ? (ans) : (a * d)); ans = ((ans) > (b * (a - c - 1)) ? (a... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const int MAXN = 200010; char str[MAXN + 1], S[MAXN... |
/* -----------------------------------------------------------------------
*
* Copyright 2008 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 Foundation, In... |
// The four D flip-flops (DFFs) in a Cyclone V/10GX Adaptive Logic Module (ALM)
// act as one-bit memory cells that can be placed very flexibly (wherever there's
// an ALM); each flop is represented by a MISTRAL_FF cell.
//
// The flops in these chips are rather flexible in some ways, but in practice
// quite crippled ... |
#include <bits/stdc++.h> using namespace std; inline int read() { static int r, sign; static char c; r = 0, sign = 1; do c = getchar(); while (c != - && (c < 0 || c > 9 )); if (c == - ) sign = -1, c = getchar(); while (c >= 0 && c <= 9 ) r = r * 10 + (int)(c - 0 ), c = getchar(... |
/*
* Copyright (c) 2017 Cory Perry
*
* 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, distr... |
#include <bits/stdc++.h> using namespace std; int N, i; double H, K, x, y, xp, yp; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K >> x >> y; for (i = 1; i < N; i++) { cin >> xp >> yp; H += sqrt((xp - x) * (xp - x) + (yp - y) * (yp - y)) * K / 50... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; void test_case() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; vector<int> l(n), r(n); l[0] = 1; for (int i = 1; i < n; i++) { if... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; if (n == 12) { string hour = ; hour += s[0]; hour += s[1]; string min = ; min += s[3]; min += s[4]; if (hour == 00 ) s[0] = 1 ; if (stoi(hour) > 1... |
//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 associated do... |
module DSpm(input clk,
input [11:0] io_core_addr,
input io_core_enable,
output[31:0] io_core_data_out,
input io_core_byte_write_3,
input io_core_byte_write_2,
input io_core_byte_write_1,
input io_core_byte_write_0,
input [31:0] io_core_data_in,
input [11:0] io_bus_addr,
inp... |
/**
* 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 the toplevel module for the clock generator. The clock generator
// internally contains a bsg_tag node, a ring oscillator, and a clock
// downsampler as well as a external clock pass through. The ring oscillator
// also has its own bsg_tag node.
// To select between
// the ring oscillator, the downsampled r... |
//------------------------------------------------------------------------------
// (c) Copyright 2013-2015 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 pr... |
/*
* 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; void solve() { long long n, m, ans = 0; cin >> n; long long boy[n]; for (long long i = 0; i < n; i++) cin >> boy[i]; cin >> m; long long girl[m]; for (long long i = 0; i < m; i++) cin >> girl[i]; sort(boy, boy + n); sort(girl, girl + ... |
#include <bits/stdc++.h> using namespace std; int n, m; int s, t, ds, dt; struct edge { int u, v; } E[400005]; vector<int> vecr[200005]; int pre[200005]; int find(int x) { if (x != pre[x]) pre[x] = find(pre[x]); return pre[x]; } void Union(int x, int y) { pre[find(x)] = find(y); } int ... |
module SSEG_Driver( clk, reset, data, sseg, an );
input wire clk;
input wire reset;
input wire[15:0] data;
output reg[6:0] sseg;
output reg[3:0] an;
wire[3:0] hex3,hex2,hex1,hex0;
assign hex3 = data[15:12];
assign hex2 = data[11:8];
assign hex1 = data[7:4];
assign hex0 = data[3:0];
localparam N =... |
// -*- Mode: Verilog -*-
// Filename : wb_dsp_top.v
// Description : Top level module for wishbone DSP
// Author : Philip Tracton
// Created On : Wed Dec 2 12:53:51 2015
// Last Modified By: Philip Tracton
// Last Modified On: Wed Dec 2 12:53:51 2015
// Update Cou... |
/**
* 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; std::vector<long long> factorial; void precompute_factorial(int ma) { factorial.push_back(1); for (int i = 1; i <= ma; i++) factorial.push_back((factorial.back() * i) % MOD); } long long power(long long base, int e) { l... |
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; int n, root = 0; vector<vector<int>> adj; vector<int> d; void dfs() { d.assign(n, INF); d[root] = 0; queue<int> q; q.push(root); while (!q.empty()) { int cur = q.front(); q.pop(); for (auto nxt : adj... |
#include <bits/stdc++.h> const int N = 1000005; using namespace std; long long n, k, sum, q, res, m, val, ans; long long x, y; double p; long long xx[] = {1, 0, -1, 0}; long long yy[] = {0, 1, 0, -1}; void solve(long long no) { cin >> n; long long res = 0; vector<long long> v[64]; for (i... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 1e6 + 5; const int K = (1 << 17) + 10; const long long int INF = 2e18 + 500; const int inf = 0x7fffffff; const int SQRT = 500; const int lgN = 20; int main(int argc, char const *argv[]) { cin.sync_with_stdio(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; char s[2000006]; char t[1000006]; int len[100005], pos[100005]; vector<pair<int, int>> e; int main() { int n; scanf( %d , &n); int tp = 0; for (int i = 0; i < n; i++) { scanf( %s , t + tp); len[i] = strlen(t + tp); pos[i] = tp; ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n; scanf( %d , &n); vector<int> f(n + 1, -1); vector<int> g(n + 1, -1); vector<int> h(1); int m = 0; vector<bool> b(n + 1, false); for (int i = 1; i <= n; i++) { scanf( %d , &f[i]); if (f[... |
// $Id: vcr_vc_alloc_mac.v 1534 2009-09-16 16:10:23Z dub $
/*
Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions ... |
#include<bits/stdc++.h> using namespace std; #define N 1500009 #define INF 5e8 #define mymin(x,y) (x>=y?y:x) #define mymax(x,y) (x>=y?x:y) typedef long long int LL; map<LL, int> mp[3]; int a[4][N]; struct din{ int ap, id; }dn[4][N]; bool cmp(din af, din bf){ return af.ap < bf.ap; } ... |
#include <bits/stdc++.h> using namespace std; long long n, x, freq[100123], pairs = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n >> x; long long v[n]; for (long long i = 0; i < n; i++) { cin >> v[i]; freq[v[i]]++; } for (long long i = 0; i < 100123;... |
#include <bits/stdc++.h> using namespace std; bool vis[205][205]; int cnt; vector<int> ans; void dfs(int x, int y) { if (x % 2 == 0 && y % 2 == 0) cnt++; vis[x][y] = 1; if (!vis[x + 1][y]) dfs(x + 1, y); if (!vis[x][y + 1]) dfs(x, y + 1); if (!vis[x - 1][y] && (x - 1 >= 0)) dfs(x - 1, y); ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; int a[N], sum[N], f[N], ans[N]; int n, r, c; char ch[N * 6]; int main() { scanf( %d%d%d , &n, &r, &c); for (int i = 1; i <= n; i++) { scanf( %s , ch + sum[i - 1] + 2); a[i] = strlen(ch + sum[i - 1] + 2); sum[i] = ... |
#include <bits/stdc++.h> using namespace std; long long bigmod(long long b, long long p, long long md) { if (p == 0) return 1; if (p % 2 == 1) { return ((b % md) * bigmod(b, p - 1, md)) % md; } else { long long y = bigmod(b, p / 2, md); return (y * y) % md; } } set<int> vis; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char c = getchar(); bool f = 0; while (c < 48) f |= c == - , c = getchar(); while (c > 47) x = x * 10 + (c ^ 48), c = getchar(); return f ? -x : x; } int n, k; struct node { int sz, mn[10], mx[10]; bo... |
`default_nettype none
module main (input clk,
input sw1,
input sw2,
output c0,
output c1,
output c2,
output c3,
output c4,
output c5,
output c6,
output c7);
//-- Configure the pull-up resi... |
#include <bits/stdc++.h> using namespace std; int a, n, i, k, l, r, d, kol1, kol2, ans; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (i = 1; i <= n; i++) { cin >> a; if (a < k) kol1++; else if (a > k) kol2++; } l = n; r = n * 3;... |
#include <bits/stdc++.h> using namespace std; long long int N; set<int> P; void setP(long long int n, int x, int y) { if (n > N) return; if (n != 0) P.insert(n); if (n != 0 || x != 0) setP(n * 10 + x, x, y); if (n != 0 || y != 0) setP(n * 10 + y, x, y); } int main() { cin >> N; for (... |
#include <bits/stdc++.h> using namespace std; using namespace chrono; const int infinity = (int)1e9 + 42; const int64_t llInfinity = (int64_t)1e18 + 256; const int module = (int)1e9 + 7; const long double eps = 1e-8; mt19937_64 randGen(system_clock().now().time_since_epoch().count()); inline void raiseE... |
#include <bits/stdc++.h> using namespace std; const int N = 10004; long long a[N], b[N], c, sa = 0, mb = 0, M; int n; bool ok1(long long x) { long long s = 0; for (int i = 1; i <= n; i++) { if (a[i] > 0 && x / b[i] > c / a[i]) return 0; s += a[i] * x / b[i] + 1; if (s >= c) return 0;... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-15; const double pi = acos(-1.0); const long long Mod = 1000000007; const int N = 1e3 + 5; int ks = 0; int n, m, s, t; long long dis[N], cost[N * 10], L; int used[N], deleted[N * 10]; pair<int, int> parent[N]; vector<pair<int, int... |
#include <bits/stdc++.h> using namespace std; long long fact[200001], inv_fact[200001], dp[2010][26]; bool cmp(pair<int, int> a, pair<int, int> b) { return a.first + a.second < b.first + b.second; } long long ModExp(int a, int n) { long long x = a % 1000000007, y = 1 % 1000000007; while (n > 0) { ... |
// Author: Hugues CREUSY
// February 2004
// Verilog model
// project: M25P40 25 MHz,
// release: 1.1
// These Verilog HDL models are provided "as is" without warranty
// of any kind, included but not limited to, implied warranty
// of merchantability and fitness for a particular purpose.
`times... |
//Legal Notice: (C)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 do... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(NULL); int tc; cin >> tc; while (tc--) { int n; cin >> n; int sum = (n % 10 - 1) * 10; if (1 <= n) sum += 1; if (10 <= n) sum += 2; if (100 <= n) sum += 3; if (10... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) using namespace std; using ll = long long; using db = long double; using ii = pair<int, int>; const int N = 5e5 + 5, LG = 19, MOD = 1e9 + 7; const int SQ = 225; const long double EPS = 1e-7; string s; int32_t ... |
/*
* 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 n, m, i, ii, c; long long xa, xb, xc, xd, mask, a[100100], b[100100]; int main() { scanf( %d%d , &n, &m); for (i = 0; i < n; i++) { scanf( %I64d.%I64d.%I64d.%I64d , &xa, &xb, &xc, &xd); a[i] = (xa << 24) + (xb << 16) + (xc << 8) + xd; } ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 09/10/2017 10:38:46 AM
// Design Name:
// Module Name: MAIN_TB
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Re... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int block_size = 360; const int maxn = 100010; const long long mod = 1e9 + 7; const long double eps = 1e-9; template <typename T> int sign(const T& a) { if (a < 0) { return -1; } i... |
`include "../lib/mux_16to1.v"
module test;
reg [3:0] s;
reg i15, i14, i13, i12, i11, i10, i9, i8, i7, i6, i5, i4, i3, i2, i1, i0;
wire z;
mux_16to1 mux(
.s (s ),
.i15(i15),
.i14(i14),
.i13(i13),
.i12(i12),
.i11(i11),
.i10(i10),
.i9 (i9 ),
.i8 (i8 ),
.i7 (i7 ),
... |
`include "mor1kx-defines.v"
`define OR1K_OPCODE_POS 31:26
`define OR1K_J_BR_IMM_POS 25:0
`define OR1K_RD_POS 25:21
`define OR1K_RA_POS 20:16
`define OR1K_RB_POS 15:11
`define OR1K_ALU_OP_POS 3:0
`define OR1K_SF_OP 25:21
`define OR1K_XSYNC_OP_POS 25:21
module mor1kx_traceport_monitor(/*AUTOARG*/
// Outputs
finis... |
#include <bits/stdc++.h> using namespace std; long long h[1000005]; long long dp[1000005][2]; const int mod = 1e9 + 7; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %I64d , &h[i]), h[i]--; for (int i = 1; i <= n; i++) { dp[i][0] = (dp[i - 1][0] + dp[i - 1][1] *... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: AGH
// Engineer: Krzysztof Kapusta/Mateusz Furdyna
//
// Create Date: 17:11:37 11/01/2014
// Design Name: UART_memory
// Module Name: UART_memory
// Project Name: UART_memory
// Targ... |
#include <bits/stdc++.h> int main() { long long int n, b, c, i; float a, d; scanf( %I64d , &n); a = sqrt(n); b = floor(a); for (i = b; i > 0; i--) { d = n % i; if (d == 0) break; else continue; } c = n / i; printf( %I64d %I64d , i, c); } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); priority_queue<int, vector<int>, greater<int>> pq; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { int x; cin >> x; pq.push(x); } int ans = 0; for (int i ... |
//==========================================
// Function : Asynchronous FIFO (w/ 2 asynchronous clocks).
// Coder : Alex Claros F.
// Date : 15/May/2005.
// Notes : This implementation is based on the article
// 'Asynchronous FIFO in Virtex-II FPGAs'
// writen by Peter Alfke. This TechX... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, i, p; cin >> t; while (t--) { cin >> n; p = (n + 3) / 4; for (i = 1; i <= n - p; i++) { cout << 9 ; } for (i = 1; i <= p; i++) { cout << 8 ; } cout << endl; } } |
#include <bits/stdc++.h> const int md = 1e9 + 7; int n, k, m, M, c; struct mat { int A[256][256]; inline mat() { memset(A, 0, sizeof A); } inline int* operator[](const int& x) { return A[x]; } inline mat operator*(const mat& b) const { mat c; for (int i = 0; i <= M; ++i) for (i... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; const int maxn = 55; int st[maxn]; struct E { int u, v, w, cost; int nxt; } edge[500009]; int gtot = 0, head[maxn * 100]; void addedge(int u, int v, int w, int cost) { edge[gtot].v = v; e... |
//
// 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)
// ... |
#include <bits/stdc++.h> using namespace std; int a[100010]; char b[100010]; int main() { int n, ansl = -1e9, ansr = 1e9, l1 = -1e9, l2 = -1e9; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } scanf( %s , b + 1); for (int i = 5; i <= n; i++) { if (b[i] ==... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 100010; int n, m, k; map<int, vector<pair<int, int> > > a, b; int s = 0; void deal(map<int, vector<pair<int, int> > > &a, int n, int m) { if ((m + 1 - a.size()) % 2) s ^= n; for (map<int, vector<pair<int, int> > >::iterator it = a.begin(... |
#include <bits/stdc++.h> using namespace std; int spend(int x) { int b, total, cash_back, left; cash_back = x / 10; b = cash_back * 10; left = x - b + cash_back; if (cash_back < 1) { return left; } return b + spend(left); } int main() { int testcase; cin >> testcase; ... |
`timescale 1ns / 1ps
module jt12_test;
reg rst;
reg clk;
reg flag_A, flag_B;
wire s1_enters, s2_enters, s3_enters, s4_enters;
`include "../common/dump.vh"
initial begin
clk = 0;
forever #10 clk=~clk;
end
initial begin
rst = 0;
flag_A = 0;
flag_B = 0;
#5 rst = 1;
#20 rst = 0;
//$finish;
end
/*... |
/*
* @Author: tmh
* @Date: 2017-07-25 16:23:55
* @File Name: RegFileWriteControl.v
*/
`include "define.v"
module RegFileWriteControl (
input [ `EX_STATE_BITS-1:0] executeState , // Execute State
input [ `ALU_DATA_WIDTH-1:0] aluResultIn , // ALU Result in
input [ `DATA_WIDTH-1:0] wRIn ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; struct DSU { int n; vector<int> link, sz; DSU(int n) : n(n), link(n), sz(n) { for (int i = 0; i < n; i++) { link[i] = i; sz[i] = 1; } } int first(int x) { return (x == link[x] ? x : link[x] = f... |
#include <bits/stdc++.h> using namespace std; bool flag; const double eps = 1e-12; double sqr(double x) { return x * x; } void read(complex<double> &A) { double x, y; cin >> x >> y; A = complex<double>(x, y); } bool tri(complex<double> A, double ra, complex<double> B, double rb) { double 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 la... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1010; const int base = 31337; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const int logo = 20; const int off = 1 << logo; const int treesiz = off << 1; int n, m, k; vector<int> graph[maxn]; int a[maxn], ss[maxn], cs[maxn]; b... |
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cout.tie(nullptr); std::cin.tie(nullptr); std::cerr.tie(nullptr); int64_t n, k; std::cin >> n >> k; if (k == 1) std::cout << 1 n ; if (k == 2) { int64_t res = (n * (n - 1)) / 2 + 1; std::cout... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<char> a; char x; for (int i = 0; i < n; i++) { cin >> x; a.push_back(x); } for (int i = 0; i < a.size(); i++) { if (a[i] == U && a[i + 1] == R ) { a.erase(a.begin() + i); ... |
#include <bits/stdc++.h> using namespace std; int points[11] = {0, 25, 18, 15, 12, 10, 8, 6, 4, 2, 1}; struct T { vector<int> a; string name; T() { for (int i = (1); i <= (55); i++) a.push_back(0); } bool operator<(const T &b) const { return a > b.a; } } ma[1100]; int n, games; map... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 1, LOGN = 20; vector<pair<int, long long> > adj[N]; long long a[N], dis[N]; int lca[N][LOGN]; int upd[N]; void dfs1(int u, long long d = 0, int par = 0) { dis[u] = d; lca[u][0] = par; for (int i = 1; i < LOGN; i++) lca[u][i] = l... |
#include <bits/stdc++.h> using namespace std; int N, good; bool prime[100010]; vector<int> fact, num, lis; int main() { memset(prime, true, sizeof(prime)); for (int i = 2; i * i <= 100000; i++) if (prime[i]) for (int j = 2; i * j <= 100000; j++) prime[i * j] = false; for (int i = 2; ... |
// DEFINES
`define BITS0 9 // Bit width of the operands
`define BITS1 8 // Bit width of the operands
`define BITS2 18 // Bit width of the operands
`define BITS3 36 // Bit width of the operands
// sees if the softaware matches simple primitives
module bm_match5_str_arch(clock,
reset... |
module PLLE2_ADV #(
parameter BANDWIDTH = "OPTIMIZED",
parameter integer CLKFBOUT_MULT = 5,
parameter real CLKFBOUT_PHASE = 0.000,
parameter real CLKIN1_PERIOD = 0.000,
parameter real CLKIN2_PERIOD = 0.000,
parameter integer CLKOUT0_DIVIDE = 1,
parameter real CLKOUT0_DUTY_CYCLE = 0.500,
parameter real... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: sctag_scbufrep.v
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
//
// The above named program is free software; you can redistribute it an... |
`include "defines.v"
module mem_wb(
input wire clk,
input wire rst,
//input
//WB
input wire writeReg_i,
input wire[4:0] writeRegAddr_i,
input wire[31:0] writeData_i,
input wire[31:0] writeDataHi_i,
input wire[31:0] writeDataLo_i,
input wire writeRegHiLo_i,
//PC
in... |
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, k, m; cin >> n >> k >> m; int64_t ans = 0; vector<vector<int64_t>> dp(n + 1, vector<int64_t>(k + 1)); vector<int64_t> u(n + 1); vector<int64_t> g(n + 1); dp[0][0] = 1; u[1] = 1; for (int64_t i = 2; i <= n; i++)... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, , ); ... |
#include <bits/stdc++.h> using namespace std; bool flag; vector<vector<int> > g; map<int, bool> used; void dfs(int x, int last) { used[x] = true; for (auto to : g[x]) { if (!used[to]) { dfs(to, x); } else { if (last != to) { flag = false; return; ... |
`timescale 1ns/1ps
module tb_cocotb #(
parameter DATA_WIDTH = 32,
parameter FIFO_WIDTH = 8
)(
input rst,
input [31:0] test_id,
//write side
input WR_CLK,
output [1:0] WR_RDY,
input ... |
#include <bits/stdc++.h> using namespace std; long long powm(long long base, long long exp, long long mod = 1000000007) { long long ans = 1; while (exp) { if (exp & 1) ans = (ans * base) % mod; exp >>= 1, base = (base * base) % mod; } return ans; } long long ctl(char x, char an = a ... |
#include <bits/stdc++.h> using namespace std; struct Point { double x; double y; Point(double _x = 0, double _y = 0) : x(_x), y(_y) {} double length() const { return sqrt(x * x + y * y); } double distance(const Point& other) const { return Point(x - other.x, y - other.y).length(); } ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 24.04.2017 13:28:22
// Design Name:
// Module Name: dragster_configurator
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:... |
#include <bits/stdc++.h> using namespace std; long long mn = (long long)(1e9); long long n, ans, k, a[311111], near[2111111], x; bool mark[2111111]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; mark[a[i]] = 1; ... |
#include <bits/stdc++.h> using namespace std; struct Tpoint { double x, y; } v[200], pg[200]; struct Tline { Tpoint a, b; } ls[200]; int n, tot, q[200], ord[200]; double at2[200]; double getdouble() { double d = 0, d2, d3; char ch = ; bool flag = false; while (!isdigit(ch = ge... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int inf = 1e9; int mod = 1e9 + 7; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; int L[n], R[n]; for (int i = 0; i < n; i++) cin >> L[i] >> R[i]; map<int... |
/*
* 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
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 13:25:20 11/19/2015
// Design Name:
// Module Name: MEM_WB
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, inp; cin >> n; for (int i = 0; i < n; i++) { cin >> inp; sum += inp; } cout << (float)sum / (float)n; return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using namespace std; long long n, m; long long a[((long long)(2e6 + 600))]; int main() { cin >> n >> m; long long l = 0; long long pas = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (i && a[i] == a[i - 1... |
// ============================================================================
// Copyright (c) 2010
// ============================================================================
//
// Permission:
//
//
//
// Disclaimer:
//
// This VHDL/Verilog or C/C++ source code is intended as a design reference
... |
#include <bits/stdc++.h> using namespace std; template <class T> using VV = vector<vector<T>>; template <class T> inline T SMIN(T& a, const T b) { return a = (a > b) ? b : a; } template <class T> inline T SMAX(T& a, const T b) { return a = (a < b) ? b : a; } template <class Iter> void __ku... |
#include <bits/stdc++.h> using namespace std; void rd(long long &x) { scanf( %lld , &x); } void rd(long long &x, long long &y) { scanf( %lld%lld , &x, &y); } void rd(long long &x, long long &y, long long &z) { scanf( %lld%lld%lld , &x, &y, &z); } void rd(long long &x, long long &y, long long &z, long lo... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: scfifo
// ============================================================
// File Name: fifo32_256.v
// Megafunction Name(s):
// scfifo
//
// Simulation Library Files(s):
// altera_mf
// ============================================... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.