text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, N = 510; int n, m, a[N], st[N][12], g[N][12], dp[N][N]; int solve(int l, int r) { if (dp[l][r]) return dp[l][r]; if (l > r) return 1; long long r1 = 0, r2 = 0; int pos, lo = log2(r - l + 1); if (st[l][lo] < st[r - (1 <<... |
/*
*
*12bit PWM analog output module.
*Interface bit width is 16bit stereo.
*Input source require dcfifo altera megafunction.
*Clock input 196.608MHz, Output Sampling Frequency 48kHz.
*
*/
module pwm_out(
input wire clk,
input wire reset_n,
output reg fifo_rdreq,
input wire fifo_empty,
i... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, a; while (cin >> s >> n) { a = s.length(); if (a % n != 0) cout << NO << endl; else { int b, c = 0; b = a / n; for (int i = 0; i < a; i += b) { for (int j = 0; j < b ... |
#include <bits/stdc++.h> using namespace std; vector<long long> v; bitset<101> usado; long long dfs(long long nodo) { if (usado[nodo]) return 0; usado.set(nodo); return 1 + dfs(v[nodo]); } long long calcmcd(long long a, long long b) { if (a % b == 0) return b; return calcmcd(b, a % b); ... |
#include <bits/stdc++.h> using namespace std; bool cmp(pair<long long, long long> a, pair<long long, long long> b) { if (a.first != b.first) { return a.first < b.first; } return a.second > b.second; } const int maxn = (int)1e7; struct vt { int ed[2]; bool term; vt() { ed[0]... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; template <typename T, typename TT> inline ostream &operator<<(ostream &os, const pair<T, TT> &t) { return os << t.first << << t.second; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &t) { ... |
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; int ans = 0; if (n % 2 == 0) { ans = 3 * (n / 2); } else { ans = 3 * (n / 2) + 1; } cout << ans << endl; for (int i = 1; i <= n; i++) { if (!(i % 2)) cout << i << ; } for (int i = 1... |
#include <bits/stdc++.h> using namespace std; map<string, int> m; int dis(string s1, string s2) { return (m[s2] - m[s1] + 12) % 12; } int main() { string s1, s2, s3; m[ C ] = 0; m[ C# ] = 1; m[ D ] = 2; m[ D# ] = 3; m[ E ] = 4; m[ F ] = 5; m[ F# ] = 6; m[ G ] = 7; m[ G# ]... |
#include <bits/stdc++.h> using namespace std; int n; int m; int a[1 << 7]; int min_k, max_k; bool ok(int ask) { int need = 0; for (int i = 0; i < n; i++) { if (a[i] > ask) { return false; } if (ask > a[i]) { need += ask - a[i]; } } if (need >= m) { ... |
// 4-Digit Seven Segment Display, Addressed by Digit Index, Individual Enable / Digit.
module digits(
mclk,
enable,
values,
seg,
digit
);
// Input
input wire mclk;
input wire[3:0] enable;
input wire[15:0] values;
// Output
output reg[6:0] seg = 8'b1111111;
output reg[3:0] digit = 4'b1111;
// State
reg[14:0]... |
#include <bits/stdc++.h> using namespace std; const int n0 = 1503, inf = 1e9; int n, s, m, k, a[n0], b[n0], p[n0], L[n0]; int dp[2][n0], mx[n0], best[n0]; int num(int pos) { for (int i = 1; i <= n; i++) { p[i] = p[i - 1] + (a[i] <= b[pos]); } memset(&dp, -0x3f, sizeof(dp)); int res = 0; ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long t; cin >> t; while (t--) { long long n; cin >> n; cout << n / 2 << n ; } return 0; } |
#include<bits/stdc++.h> using namespace std; int main() { long long int t; cin>>t; while(t--) { long long int i,j,k,l,m,n,c1=0,c2=0,ans=0,res=0; map<long long int,long long int>mp,mp1; vector<long long int>v,v1,v2; set<long long int>st,st1; ... |
#include <bits/stdc++.h> using namespace std; typedef vector<vector<long long> > vvl; long long x, y, z, j, i, t, n, k, input, ans, flag, maxi, mini, a, b; int main() { cin >> n >> x; ans = 0; for (long long i = 1; i <= n; i++) { if (x % i == 0 && x / i <= n) ans++; } cout << ans << ... |
/*
* 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: 19:36:33 04/17/2016
// Design Name:
// Module Name: control_digitos_2
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependenci... |
module mux_32(
add,
i_0 ,
i_1 ,
i_2 ,
i_3 ,
i_4 ,
i_5 ,
i_6 ,
i_7 ,
i_8 ,
i_9 ,
i_10,
i_11,
i_12,
i_13,
i_14,
i_15,
i_16,
i_17,
... |
//CSA6:2 Compressor
//#############################################################################
//# Function: Carry Save Adder (6:2) #
//#############################################################################
//# Author: Andreas Olofsson ... |
module top;
reg pass = 1'b1;
integer count;
reg [2:0] icount;
reg clk = 0;
real in = 0.0;
real result = -1.0;
always #10 clk = ~clk;
always #20 in = in + 1.0;
initial begin
count = 3;
result <= repeat(count) @(posedge clk) in;
if ($simtime != 0 || result != -1.0) begin
$display("F... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: jorge Sequeira
//
// Create Date: 08/25/2016 09:12:30 AM
// Design Name:
// Module Name: Testbench_
// Project Name:
// Target Devices:
// Tool Versions:
// Description: Prueba de un mu... |
#include <bits/stdc++.h> using namespace std; inline int rit() { int f = 0, key = 1; char ch; do { ch = getchar(); if (ch == - ) key = -1; } while (ch < 0 || ch > 9 ); do { f = f * 10 + ch - 0 ; ch = getchar(); } while (ch >= 0 && ch <= 9 ); return f * key... |
#include <bits/stdc++.h> using namespace std; int a[200], ans[200]; int v[1000001]; int main() { int T, n; cin >> T; while (T--) { memset(v, 0, sizeof v); scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); for (int i = 1; i <= n; i... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 19.02.2017 01:26:40
// Design Name:
// Module Name: seg_disp
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revi... |
#include <bits/stdc++.h> const int MAXN = 2e5 + 10; using namespace std; 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 * 10 + ch - 0 , ch = getchar(); return f * x; } ... |
module DM9000A_IF( // HOST Side
// Signals fro Avalon-MM slave port "s1"
avs_s1_writedata_iDATA,
avs_s1_readdata_oDATA,
avs_s1_address_iCMD,
avs_s1_read_n_iRD_N,
avs_s1_write_n_iWR_N,
avs_s1_chipselect_n_iCS_N,
avs_s1_reset_n_iRST_N,
avs_s1_clk_iCLK,
avs_s1_ir... |
#include <bits/stdc++.h> using namespace std; long long n; long long calcCards(long long x) { return x * (x + 1) + (x - 1) * x / 2; } bool P(int x) { return calcCards(x) <= n; } long long bs(long long l = 0, long long h = n) { long long m; while (l < h) { m = (l + h + 1) / 2; if (P(m)) ... |
#include <bits/stdc++.h> using namespace std; inline char nc() { static char buf[1000000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++; } template <typename T> inline void read(T& sum) { char ch = ... |
#include <bits/stdc++.h> const uint64_t MAX_NUM = 1000000000000000001ul; uint64_t get_iteration_simple(const int n, const uint64_t k, std::vector<uint64_t>& a) { int iterations = 0; while (true) { ++iterations; for (int i = 1; i < n; ++i) { a[i] += a[i - 1... |
/*
* 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; struct T { int p, n; }; bool operator<(T x, T y) { return x.p < y.p; } T m[100100]; int main() { int i, n, j; for (scanf( %d , &n), i = 0; i < n; scanf( %d%d , &m[i].p, &m[i].n), i++) ; sort(m, m + n); j = m[n - 1].n; for (i = 0; i ... |
// File: comm_fpga_fx2_v2.v
// Generated by MyHDL 0.9dev
// Date: Sat Jul 13 22:29:39 2013
`timescale 1ns/10ps
module comm_fpga_fx2_v2 (
clk_in,
reset_in,
fx2FifoSel_out,
fx2Data_in,
fx2Data_out,
fx2Data_sel,
fx2Read_out,
fx2GotData_in,
fx2Write_out,
fx2GotRoom_in,
fx2PktE... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long d[3]; cin >> d[0] >> d[1] >> d[2]; sort(d, d + 3); if (d[2] >= d[0] + d[1]) cout << d[0] + d[1] << endl; else { cout << d[2] + (d[1] + d[0] - d[2]) / 2 << end... |
module pong16 (sys_clk,
rst_n,
dm_sel,
ramadr,
ramwe,
ramre,
dbus_in,
vid_sync_o,
vid_o,
audio_o
);
//INPUTS
input logic sys_clk;
input logic rst_n;
input wire... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int n, k; bool d[1001]; long long dp[1001][2][1001]; int cnt[10001]; long long DP(int i, bool f, int j) { if (i == n) return cnt[j] == k; if (dp[i][f][j] != -1) return dp[i][f][j]; long long ret = 0; if (d[i] =... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; const int mod = 998244353; int up(int x, int y) { return x + y >= mod ? x + y - mod : x + y; } int a[1010], dp[1010][1010], pos[100010], n, k; int cal(int x) { for (int i = 0; i <= k; ++i) for (int j = 0; j <= n; ++j) dp[i][j] =... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> static inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> static inline void amax(T &x, U y) { if (y > x) x = y; } const long long inf = (long long)1e18 + 17; const long long iinf =... |
#include <bits/stdc++.h> using namespace std; struct point { long long x, a; } p[100]; int n; long long key[100][100]; long long k[100]; long long s[3], ans; long long v; void getb(long long ab, long long b, int cur) { if (ab < b * b) return; if (cur > n + 1) return; if (cur == n + 1) ... |
#include <bits/stdc++.h> using namespace std; double mod(double a, double b) { long long int val = a / b; return a - val * b; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); double a, b, m, vx, vy, vz; cin >> a >> b >> m >> vx >> vy >> vz; double sx, sy, sz, t, x0... |
/*
Copyright (c) 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, distribute,... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; if (n % 2 == 0) cout << 2; else cout << 1; } |
#include <bits/stdc++.h> using namespace std; int n, m, l, r, cnt; long long ans; char s[101][10005]; int dfs(int x, int y, int d) { if (x == n - 1) return 1; if (s[x + 1][y] == . ) { l = y; r = y; ans++; cnt = 0; return dfs(x + 1, y, d); } if (s[x][y + d] == . ... |
#include <bits/stdc++.h> using namespace std; long long n; inline bool check2(long long x, long long y3) { return (x * x + y3 * y3 * 3 <= n * n); } inline bool check(long long x, long long y3) { return check2(x - 2, y3) & check2(x - 1, y3 - 1) & check2(x + 1, y3 - 1) & check2(x + 2, y3) & c... |
#include <bits/stdc++.h> using namespace std; int main() { string s, s5; cin >> s; int c = 0; string s3 = , s4 = ; s3 += s[0]; s3 += s[1]; s4 += s[3]; s4 += s[4]; int a = atoi(s3.c_str()); int b = atoi(s4.c_str()); while (1) { if (b == 59) { if (a == 23)... |
/**
* 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... |
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
//
// Revision Control Information
//
// $RCSfile: altera_tse_gxb_gige_inst.v,v $
// $Source: /ipbu/cvs/sio/projects/TriSpeedEthernet/src/RTL/Top_level_modules/... |
//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; const string YES = Yes ; const string NO = No ; string solve() { int N; cin >> N; vector<int> p(N); for (int i = 0; i < (N); ++i) { cin >> p[i]; } for (int i = 0; i < (N - 1); ++i) { if (p[i] + 1 == p[i + 1]) { continue;... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cin.sync_with_stdio(0); cout.tie(0); string s, t, b; int n; vector<pair<char, char>> v; set<char> z; bool fine = false; char a[26]; for (int i = 0; i < 26; i++) a[i] = @ ; cin >> s >> t; for (int ... |
#include <bits/stdc++.h> using namespace std; long long n, len, i, j, a[300009]; int main() { while (scanf( %I64d , &n) == 1) { for (i = 0; i < n; i++) { scanf( %I64d , &a[i]); } sort(a, a + n); if (n % 2 != 0) { printf( %I64d n , a[n / 2]); } else { print... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: scfifo
// ============================================================
// File Name: fifo_64_32.v
// Megafunction Name(s):
// scfifo
//
// Simulation Library Files(s):
// altera_mf
// ================================... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int MM[500], FF[500]; int main() { ios::sync_with_stdio(0); int N; cin >> N; for (int i = 0; i < N; i++) { char g; int from, to; cin >> g >> from >> to; int *v; if (g == M ) for (i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1010; const int INF = 100000000; string str[maxn]; int dp[maxn][maxn]; int n, m, ans; int flag[maxn][maxn]; int dir[4][2] = {0, -1, 0, 1, 1, 0, -1, 0}; char ch[5] = { D , I , M , A }; vector<pair<int, int> > q; bool Ok(int ki, int k... |
#include <bits/stdc++.h> using namespace std; int main() { int ans[30], tans[30], flot[30]; memset(flot, 0, sizeof(flot)); memset(ans, 0x3f3f3f3f, sizeof(ans)); int n, num[55], top = 0, m; string s, s1; cin >> n; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == * ) ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> w[200000 + 20]; int a[200000 + 20][3]; vector<pair<int, pair<int, int> > > to_compress; int n; void maximize(int &a, int b) { if (a < b) a = b; } struct Fenwick_tree { int bit[1000000 + 50]; void update(int x, int v) { for (;... |
// file: clk_gen.v
//
// (c) Copyright 2008 - 2013 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
// laws.
//
// DISCLAIMER
// This disclaimer is not a li... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const int MAXN = 200010; const double EPS = 1e-7; inline int read() { char c = getchar(); int x = 0, f = 1; while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1005; map<pair<int, int>, int> mapa; int main() { int n, h, m; scanf( %d , &n); int c = 0; for (int i = 0; i < n; i++) { scanf( %d%d , &h, &m); int x = ++mapa[make_pair(h, m)]; if (x > c) c = x; } printf( %d ... |
#include <bits/stdc++.h> using namespace std; vector<int> knapsack(long long lim, vector<int> allItems) { vector<bool> mark; int mx = 0; for (auto it : allItems) mx += it; mx = min((long long)mx, lim); mark.assign(mx + 1, 0); mark[0] = true; for (auto it : allItems) { for (int i = ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; cin >> t; while (t--) { long long n; cin >> n; long long a, b, c; cin >> a >> b >> c; string s; cin >> s; long... |
#include <bits/stdc++.h> using namespace std; 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; } namespace Sa { struct Node { double x, y; Node() {... |
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/verunilibs/data/unisims/XORCY.v,v 1.6 2007/05/23 21:43:44 patrickp Exp $
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995/2004 Xilinx, Inc.
// All Right Reserved.
/////////////////////////////////////////////////... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a[110][110], i, j, maxi, f, maxid[110], c = 0, poi; scanf( %d%d , &n, &m); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) scanf( %d , &a[i][j]); } for (i = 0; i < m; i++) { maxi = a[i][0]; maxid[i] = 0; ... |
#include <bits/stdc++.h> using namespace std; bool arng(pair<long long, long long> p, pair<long long, long long> q) { if (p.first > q.first) return true; if (p.first == q.first) { return (p.second < q.second); } return false; } void solve() { long long n, m; cin >> n; long long... |
#include <bits/stdc++.h> using namespace std; int p, n, a[100100], b[100100]; bool ok(double t) { double charging = t * p; for (int i = 0; i < n; ++i) { double x = b[i] - a[i] * t; if (x >= 0) continue; else charging += x; if (charging < 0) return 0; } retur... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; int ar[n], e = 0, o = 0; for (int i = 0; i < n; i++) cin >> ar[i]; for (int i = 0; i < n; i++) { if (ar[i] % 2 == 0) e = e + 1; else o = o + ... |
// Accellera Standard V2.3 Open Verification Library (OVL).
// Accellera Copyright (c) 2005-2008. All rights reserved.
`include "std_ovl_defines.h"
`module ovl_decrement (clock, reset, enable, test_expr, fire);
parameter severity_level = `OVL_SEVERITY_DEFAULT;
parameter width = 1;
parameter value ... |
///////////////////////////////////////////////////////////////////////////////
//
// 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... |
//-----------------------------------------------------------------
// USB CDC Device
// V0.1
// Ultra-Embedded.com
// Copyright 2014-2019
//
// Email:
//
// License: LGPL
//----------------... |
#include <bits/stdc++.h> using namespace std; const int N = 3001; const int mod = 1000000007; char s[N][N]; int f[N][N]; int calc(int sr, int sc, int tr, int tc) { if (tr < sr || tc < sc) return 0; int n = tr - sr + 1, m = tc - sc + 1; f[0][0] = (s[sr][sc] != # ); for (int 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 law... |
//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... |
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2012 Claire Xenia Wolf <>
* 2019 Eddie Hung <>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this per... |
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f; const double eps = 1e-6; const long long mod = 998244353; inline string getstr(string &s, long long l, long long r) { string ret = ; for (long long i = l; i <= r; i++) ret.push_back(s[i]); return ret; } long long... |
#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 ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f;... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 7; const long long INF = 1LL << 60; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a =... |
#include <bits/stdc++.h> using namespace std; using Long = long long; constexpr Long MOD = 998244353; template <typename T> using V = vector<T>; template <typename T> using Vv = V<V<T>>; using Vb = V<bool>; using Vvb = V<Vb>; using Vi = V<int>; using Vvi = V<Vi>; using Vl = V<Long>; using Vvl ... |
/***********************************************************************************************************************
* Copyright (C) 2016 Andrew Zonenberg and contributors *
* ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e3 + 7; long long read() { long long res = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1, c = getchar(); while (isdigit(c)) res = (res << 1) + (res << 3) + c - 48, c = getchar();... |
#include <bits/stdc++.h> using namespace std; template <class T> void max_self(T &a, const T &b) { if (a < b) a = b; } template <class T> void min_self(T &a, const T &b) { if (a > b) a = b; } const int INF = 1e9 + 7; const double PI = acos(-1.0); const double EPS = (1e-9); int main() { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, m; int a[MAXN]; int w[MAXN], h[MAXN]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); scanf( %d , &m); for (int i = 1; i <= m; i++) { scanf( %d%d , &w[i], &h[i]); } long... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; long long count = 0; while (a != b) { if (a == 0 || b == 0) break; if (a < b) { count += b / a; b = b % a; } else { count += a / b; a = 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 law... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2020 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
`define checks(gotv,expv) do if ((gotv) != (expv)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `... |
// This file ONLY is placed into the Public Domain, for any use,
// Author: Yu-Sheng Lin
module t (/*AUTOARG*/
// Outputs
state,
// Inputs
clk
);
input clk;
int cyc;
reg rstn;
output [4:0] state;
parameter real fst_gparam_real = 1.23;
localparam real fst_lparam_real = 4.56;
... |
#include <bits/stdc++.h> using namespace std; int n, numone, numtwo, sum, tmp; char nlong; string nameone, nametwo; string read; struct node { string name; int goal, moregoal, score; int q; } wxy[100]; bool check(int t) { for (int i = 0; i < tmp; i++) if (wxy[t].name[i] != nameone[... |
#include <bits/stdc++.h> using namespace std; int bit[200050]; int n; int lowbit(int x) { return x & (-x); } int sum(int x) { int sum = 0; while (x > 0) { sum += bit[x]; x -= lowbit(x); } return sum; } void push(int pos, int num) { while (pos <= n) { bit[pos] += num; ... |
/**
* 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 (C) 1991-2013 Altera Corporation
// 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 from any of the foregoing
// (including device programming or simulation files), and any
// associated d... |
#include <bits/stdc++.h> using namespace std; const long long mx = 10000007; using pii = pair<long long, long long>; const long long mod = 1e9 + 7; const double pi = acos(-1); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long t; cin >> t; while (t--) { l... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; pair<int, int> p[n]; for (int i = 0; i < n; i++) { cin >> p[i].first >> p[i].second; } bool check = true; for (int i = 0; i < n; i++) { if ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> vec(n); for (int i = 0; i < n; i++) { cin >> vec[i]; } if (n == 1) { if (vec[0] == 15) cout << DOWN << endl; else if (vec[0] == 0) cout << UP << endl; else ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, a[1000], d; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); d = 0; for (int i = 1; i < n; i++) { if (a[i] - a[i - 1] <= 1) { d... |
/**
* 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; int main() { int l, b, M, N; cin >> M; cin >> N; l = std::max(M, N); b = std::min(M, N); if (b >= 2) { cout << (b * (l / 2) + (b / 2) * (l % 2)); } else cout << (b * (l / 2)); return 0; } |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; set<int> ab[MAXN][2]; int N, M, Q; struct segTree { int f, t, mini, maxi; bool ans; segTree *L, *R; segTree(int _f, int _t) : f(_f), t(_t) { ans = false; mini = INT_MAX; maxi = INT_MIN; if (f != t) {... |
#include <bits/stdc++.h> using namespace std; string A; bool isPalindrome(int left, int right) { while (left < right) { if (A[left] != A[right]) return false; left++, right--; } return true; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int arr[51][51] = {0}, visit[51][51] = {0}; vector<pair<int, pair<int, int> > > v; int dfs(int a, int b, int count); void make_land(int i, int j); int main() { int i, j, sum = 0; char ch; cin >> n >> m >> k; for (i = 0; i < n; i++)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.