text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; string to_string(const string& s) { return + s + ; } string to_string(const char* s) { return to_string((string)s); } string to_string(bool b) { return (b ? true : false ); } string to_string(vector<bool> v) { bool first = true; string res = { ;... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, x, m, z, u, v, f, a, b, l, r; cin >> t; while (t--) { cin >> n >> x >> m; a = x; b = x; for (int i = 0; i < m; i++) { cin >> l >> r; if (a >= l && a <= r && b >= l && b <= r) { ... |
#include <bits/stdc++.h> using namespace std; const int nax = 1e5 + 5; vector<int> w[nax]; bool del[nax]; int legs[nax]; void dfs(int a, int par = 0) { if (w[a].size() <= 2) { del[a] = true; for (int i = 0; i < w[a].size(); i++) { int b = w[a][i]; if (b != par) dfs(b, a); ... |
#include <bits/stdc++.h> using namespace std; int N, speed, limit, t6, ans; stack<int> st; int main() { cin >> N; for (int t, i = 1; i <= N; i++) { scanf( %d , &t); if (t == 6) { t6++; } else if (t == 4) { t6 = 0; } else if (t == 2) { ans += t6; t6... |
/*
* 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 main() { long long n; cin >> n; long long a, b, f = 0; long long min = 500, max = 0; string s = ; long long suma = 0, sumb = 0; for (int i = 0; i < n; i++) { cin >> a >> b; if (abs((suma + a) - sumb) <= 500) { s += ... |
//Legal Notice: (C)2020 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 dfs(long long int n, int i, long long int b[]) { int ans = i * (n / b[i]); n = n % b[i]; if (n == 0) return ans; else return (ans + min(i + dfs(b[i] - n, i - 1, b), dfs(n, i - 1, b))); } int main() { long long int a[17], i, n; ... |
#include <bits/stdc++.h> using namespace std; int n; int sum[26]; char str[5002]; char str_list[5002][5002]; int main() { double ans = 0.0; scanf( %s , str), n = strlen(str); for (int i = 0; i < 26; i++) { int cnt = 0; int max_total = 0; for (int j = 0; j < n; j++) if (... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 12/20/2016 07:03:40 PM
// Design Name:
// Module Name: xbar
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revis... |
#include <bits/stdc++.h> using namespace std; template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; int n, m, k; int arr[70][70]; int dp[71][71][36][71]; int func(int s, int e, int cnd, int rem) { if (cnd >= m / 2) { return -1e9; } if (s == n) { if (rem == 0... |
/*
* Copyright (c) 2002 Tom Verbeure
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any ... |
/*
* 8254 timer simplified for Zet SoC
* Copyright (c) 2010 YS <>
*
* This file is part of the Zet processor. This processor is free
* hardware; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software
* Foundation; either version 3, or... |
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; int add(int a, int b) { if ((a += b) >= P) a -= P; return a; } int sub(int a, int b) { if ((a -= b) < 0) a += P; return a; } int mul(int a, int b) { return 1ll * a * b % P; } int kpow(int a, int b) { int r = 1; ... |
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2015.1 (win64) Build Mon Apr 27 19:22:08 MDT 2015
// Date : Tue Mar 22 03:35:29 2016
// Host : DESKTOP-5FTSDRT running 64-bit major releas... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; scanf( %d%d%d , &n, &a, &b); int tmp = abs(b); int x = tmp % n; if (b > 0) { int ans = a + x; while (ans >= n) { ans %= n; } if (ans == 0) printf( %d n , n); else printf(... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b); long long nCr(long long n, long long r); long long pow(long long b, long long n); void read(long long a[], long long n); void solve() { long long n; cin >> n; vector<long long> v; for (long long i = 2; i *... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: dram_pt.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 and/or
//... |
/* Generated by Yosys 0.7 (git sha1 61f6811, gcc 5.4.0-6ubuntu1~16.04.4 -O2 -fstack-protector-strong -fPIC -Os) */
(* top = 1 *)
(* src = "harder2_multi.v:2" *)
module harder2_multi(A, B, C, D, E, F, valid);
wire _00_;
wire _01_;
wire _02_;
wire _03_;
wire _04_;
wire _05_;
wire _06_;
wire _07_;
wir... |
//*****************************************************************************
// (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
// ... |
#include <bits/stdc++.h> using namespace std; const int mx = 2e5 + 10; int main() { int n, arr[mx], temp, z = 0; queue<int> visit; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); if (arr[i] == 0) visit.push(i); } temp = visit.front(); visit.pop(); f... |
#include <bits/stdc++.h> using namespace std; int ar[111]; int in[111]; long long n, s, now, t; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i]; s += ar[i]; in[i] = i; } if (s < n - 1 || ar[0] == 0) { cout << -1; return 0; } for (int ii =... |
#include <bits/stdc++.h> const int bufSize = 1e6; inline char nc() { return getchar(); static char buf[bufSize], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++; } template <typename T> inline T read(T... |
#include <bits/stdc++.h> using namespace std; template <typename A> string to_string(A* ptr) { stringstream ss; ss << 0x << std::setw(16) << std::setfill( 0 ) << std::hex << (uint64_t)(uintptr_t)ptr; return ss.str(); } string to_string(char c) { return ((string) + c) + ; } templa... |
#include <bits/stdc++.h> using namespace std; void imp() { cout << -1; exit(0); } double mn = 0, mx = 2e9; void solve(int x, int vx, int x1, int x2) { if (vx == 0) { if (x1 < x && x < x2) return; imp(); } if (vx < 0) { mn = std::max(mn, (x2 - x) / (double)vx); mx = ... |
/*
Andrew Mattheisen
Zhiyang Ong
EE-577b 2007 fall
VITERBI DECODER
spd module
*/
`include "spdu.v"
`include "demux2to4.v"
`include "selector.v"
module spd (d0, d1, d2, d3, pm0, pm1, pm2, pm3, out, clk, reset);
// outputs
output out;
// inputs
input d0, d1, d2, d3;
input [3:0] pm0, pm1,... |
#include <bits/stdc++.h> using std::cin; using std::cout; const int N = 1e5 + 1; int r, a, b, m, las[N]; int main() { cin >> a >> b >> m >> r; memset(las, -1, sizeof las); las[r] = 0; for (int i = 1;; ++i) { r = (a * r + b) % m; if (~las[r]) { cout << i - las[r]; re... |
module main(CLK,HSYNC,VSYNC,R,G,B,XCLK,PCLK,D,HIN,VIN);
input CLK;
output reg HSYNC;
output reg VSYNC;
output reg R;
output reg G;
output reg B;
output reg XCLK;
input PCLK;
input [7:0] D;
input HIN;
input VIN;
//hsync = 1589
//pulse = 191
//vsync = 834150
//pulse = 3200
reg [15:0] HCNT;
reg [15:0]... |
#include <bits/stdc++.h> using namespace std; long long int base = 639941; char str[1505], bad[30]; set<long long int> s; int main() { int k, n, i, j; scanf( %s , str); scanf( %s , bad); scanf( %d , &k); n = strlen(str); int ans = 0; for (i = 0; i < n; i++) { int b = 0; ... |
// (C) 2001-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 doc... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { long long n; cin >> n; long long tripleIndx = n / 3; if (!(n % 3)) tripleIndx--; stack<long long> st; while (tripleIndx--) { st.push... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, tmp; string s; char c; scanf( %d , &n); c = b ; s = a ; for (i = 1000; i >= 2; i--) { tmp = i * (i - 1) / 2; while (n >= tmp) { n -= tmp; for (j = 0; j < i; j++) s.push_back(c); ... |
#include <bits/stdc++.h> using namespace std; long n, m; vector<string> pref; long mov[500][500]; string temp; string inp[500]; long er, td; long bst[2000]; string tst; long dp[4][500][500]; long nend, t, ncvrd, answ; void ad(long &a, long b) { a += b; if (a >= 1000000009) a -= 100000000... |
#include <bits/stdc++.h> using namespace std; const int dir[8][2] = {{1, 0}, {0, 1}, {1, 1}, {1, -1}, {-1, 0}, {0, -1}, {-1, -1}, {-1, 1}}; int n, m, cnt[1000 + 5][1000 + 5]; char a[1000 + 5][1000 + 5]; void work(int x, int y) { bool flag = true; for (int i = 0; i < 8; i++... |
#include <bits/stdc++.h> using ll = long long; using namespace std; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } template <typename T> void read(T &x) { x = 0; char ch = getchar(); ll f = 1; while (!isdigit(ch)) { if (ch == - ) f *= -1; ch = getchar(); } while (isd... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; long long mn = 1e9, mx = -1e9; long long a[n]; for (int j = 0; j < n; j++) { ... |
/* Copyright (C) 2000 Stephen G. Tell
*
* 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; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the h... |
/**
* 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, M; cin >> N >> M; if (N == 1) { if (M == 2) { cout << 0 << endl; cout << 1 1 << endl << 1 2 << endl << 1 1 << endl; return 0; } cout << 1 << endl; cout << 1 << << M << << 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... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: srffrl_ns.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 and/or
... |
//-----------------------------------------------------------------------------
//
// (c) Copyright 2010-2011 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
... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+10,mod=1e9+7; ll a[N]; #define PII pair<int,int> #define x first #define y second #define PB push_back void solve() { int n; cin>>n; int sum=0; map<ll,int> mp; for(int i=1;i<=n;i++){ ... |
#include <bits/stdc++.h> using namespace std; struct Point { long long x, y; Point(long long x_, long long y_) { x = x_; y = y_; } Point() {} Point operator-(const Point &other) const { return Point(x - other.x, y - other.y); } long long dist(const Point &other) const {... |
// ====================================================================
// 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; inline int read() { int ret = 0, f = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { ret = (ret << 1) + (ret << 3) + ch - 0 ; ch = getchar(); ... |
// (c) Copyright 1995-2016 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 license and does not grant ... |
//#############################################################################
//# Function: 8:1 one hot mux #
//#############################################################################
//# Author: Andreas Olofsson #
/... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2018 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc=0;
reg [63:0] crc;
reg [63:0] sum;
reg rst;
// Two ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int t; cin >> n >> t; if (t == 10 && n == 1) return cout << -1, 0; string s; if (t == 10) s += 10 , n -= 2; else s += (char)(t + 48), n--; while (n--) s += 0 ; cout << s; } |
/* dcomp1.v - this is a fragment of a larger program, which would
* dynamicly compute a more interesting value for the phdelay variable.
*
* It illustrates a problem in verilog-20010721 when computing
* time values for use in behavioral delays.
*/
`timescale 1ps / 1ps
module dcomp;
time phdelay;
paramet... |
///////////////////////////////////////////////////////////////////////////////
//
// 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... |
/**
* This is written by Zhiyang Ong
* and Andrew Mattheisen
*/
module add_compare_select (npm, d, pm1, bm1, pm2, bm2);
/**
* WARNING TO DEVELOPER(S)!!!
*
* CHECK/VERIFY THAT THE WIDTH OF ALL THE PATH METRIC BUSES
* ARE THE SAME
*
* SUCH BUSES INCLUDE npm, pm1, pm2, add1, and add2
*
* THE FOLLOWING... |
#include <bits/stdc++.h> using namespace std; const int mxN = 5e4 + 7; const int inf = 1e5 + 7; const long long mod = 1e5 + 7; const long long infll = 1e18 + 7; long long a[mxN], b[mxN]; map<long long, bool> mp; int n; bool check = false; bool ok(long long x) { for (int i = 1; i <= n; i++) a[i] ... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; using pii = pair<int, int>; using pll = pair<ll, ll>; using maxHeap = priority_queue<int>; using minHeap = priority_queue<int, vector<int>, greater<int>>; int main() { ios::sync_with_stdio(0), cin.tie(0); int t, x; double ... |
/********************************************************************
* TEST BENCH FOR PROTECTION CELLS *
********************************************************************
* Laboratory : Robotics and Embedded System Technology
* Engineer : Hanjara Cahya Adhyatma
* C... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; int main() { long long n; cin >> n; if (n % 2 == 0) { cout << 1ll * n / 2; return 0; } bool flag = true; for (int i = 3; i <= sqrt(n); i += 2) { if (n % i == 0) { cout << 1ll * (n - i) / 2... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], b[n], c = 0, x = 0, y = 0, z = 0, s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1) { x++; } } for (int i = 0; i < n; i++) { cin >> b[i]; if (a[i] != b[i... |
//****************************************************************************
//
// MODULE : parameter_multiply_test
//
// DESCRIPTION : Test module to demonstrate parameter multiplication bug.
//
// AUTHOR : Brendan J Simon ()
//
// DATE : Tuesday 6th January 2001.
//
// NOTES : ... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B, typename C> struct triple { A X; B Y; C Z; triple(A a = 0, B b = 0, C c = 0) : X(a), Y(b), Z(c) {} }; template <typename A, typename B, typename C> triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0) { ret... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; using ll = long long; using ld = long double; template <typename T> using mat = vector<vector<T> >; template <int mod> struct modint { int x; modint() : x(0) {} modint(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % ... |
/**
* The computer player - AI :)
*/
module ai (
CLOCK,
RESET,
POSITION,
BALL_H,
BALL_V
);
input CLOCK, RESET;
input [10:0] BALL_H;
input [10:0] BALL_V;
output [7:0] POSITION;
reg [10:0] paddle;
// Just follow the ball.
always @ (posedge CLOCK or posedg... |
//
// Paul Gao 02/2021
//
// SDR communication endpoint over single source-synchronous channel.
//
// Typical usage: Communication between different hierarchical blocks in
// different clock domains on ASIC. In this way the clock trees can be
// fully independent in different hierarchical blocks.
//
//
// G... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > re; vector<pair<int, int> > e, o; int n, c[404][404], sink, Find, pre[404], flow; bool ch[100009], visit[404]; void init() { for (int i = 2; i * i <= 100000; i++) { if (!ch[i]) { for (int j = i * i; j <= 100000; j += i) ch[... |
#include <bits/stdc++.h> int power(int x, int y) { int res = 1; x = x % 1000000007; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; } return res; } int ncr(int n, int r) { int res = 1; if (r > n - r) r = n - r; for (i... |
// contador de testes a serem feitos
integer testes;
// status dos testes
reg status;
reg [N_TESTES-1:0] status_geral;
// inicializando testes em 0
initial begin
testes = -1;
status = 0;
status_geral = 0;
// inicilizacao dos inputs
init_input();
// inicialize clk
clk_in = 0;
// faca r... |
// (C) 2001-2014 Altera Corporation. All rights reserved.
// Your use of Altera Corporation's design tools, logic functions and other
// software and tools, and its AMPP partner logic functions, and any output
// files any of the foregoing (including device programming or simulation
// files), and any associated doc... |
#include <bits/stdc++.h> using namespace std; const int mo = 998244353; int fac[300005], inv[300005]; void init() { fac[0] = inv[0] = inv[1] = 1; for (int i = (int)(2); i <= (int)(300005 - 1); i++) inv[i] = 1ll * inv[mo % i] * (mo - mo / i) % mo; for (int i = (int)(1); i <= (int)(300005 - 1); ... |
#include <bits/stdc++.h> using namespace std; int n, k; string s; int cnt; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == # ) { cnt++; } else { if (cnt >= k) { ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { s = s * 10 + ch - 0 ; ch = getchar(); } return s * w;... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { long long n; cin >> n; long long a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 1) { cout << 1 1 << endl; cout << 0 << endl; cout << 1 1 << endl; c... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000 * 100 + 10, mod = 1000000007; long long a[maxn]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int t; t = 1; while (t--) { long long n; cin >> n; for (int i = 0; i < n; i++) { cin >... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:128000000 ) using namespace std; const int INF = 1000000000; typedef struct zap { int p; zap *left, *right, *rod; }; char s[100]; zap *top = 0, *temp = 0; int dfs(zap *t) { if (t->p == 0) { printf( int ); return 0; } ... |
#include <bits/stdc++.h> using namespace std; int n, m, ans; int r, c; char mp[201][201]; int ma[201][201]; int mac[201][201]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { char s[101]; scanf( %s , &s); for (int j = 0; j < n; j++) { mp[i][j] = s[j]; ... |
// Code generated by Icestudio 0.8.1w202112300112
`default_nettype none
//---- Top entity
module main (
output ve5dac7,
output v22cf82,
output v2120a4
);
wire w0;
wire w1;
wire w2;
assign ve5dac7 = w0;
assign v22cf82 = w1;
assign v2120a4 = w2;
vfebcfe v7dc4a3 (
.v9fb85f(w1)
);
vfebcfe va834d8 (
.v9fb8... |
#include <bits/stdc++.h> using namespace std; string arr[10] = { 0 , 0 , 2 , 3 , 322 , 5 , 53 , 7 , 7222 , 7332 }; int main() { int x; cin >> x; char a[x]; string s; for (int i = 0; i < x; i++) { cin >> a[i]; if (a[i] != 0 && a[i] != 1 ) s += arr[a[i] - 0 ]; } ... |
//Legal Notice: (C)2021 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; template <class T> void chmax(T &x, T y) { x = x > y ? x : y; } template <class T> void chmin(T &x, T y) { x = x < y ? x : y; } const int maxn = 205; int n, k; int d[maxn], ans[maxn], choice[maxn]; int dp[maxn][maxn]; int dist[maxn][maxn]; ... |
#include <bits/stdc++.h> using namespace std; struct MinTreeNode { int min; int count; }; int n; MinTreeNode tmin[200000]; int tgcd[200000]; int gcd(int a, int b) { if (a == 0) { return b; } if (b == 0) { return a; } if (a == 1 || b == 1) { return 1; } ... |
// (C) 1992-2014 Altera Corporation. All rights reserved.
// Your use of Altera Corporation's design tools, logic functions and other
// software and tools, and its AMPP partner logic functions, and any output
// files any of the foregoing (including device programming or simulati... |
#include <bits/stdc++.h> using namespace std; int a[1000 + 3][1000 + 3]; int used[1000 + 3][1000 + 3]; int n; void dfs(int x, int y) { used[x][y] = 1; for (int i = 0; i <= 1001; i++) { if (!used[x][i] && a[x][i]) dfs(x, i); } for (int i = 0; i <= 1001; i++) { if (!used[i][y] && a[i... |
//
// Copyright (c) 2002 Philip Blundell <>
//
// 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; template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? : ); return os; } template <class T> istream& operator>>(istream& is, vector<T>& v) { for (... |
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } inline void normal(long long int &a) { a %= 1000000007; (a < 0) && (a += 1000000007); } inline long long int modMul(long long int a, long long int b) { a %= 1000000007, b %= 1000000007; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int c, sum; long int ans = 0; cin >> c >> sum; if (c >= sum) ans = sum; else { ans = ((c - sum % c) * (sum / c) * (sum / c)) + ((sum % c) * ((sum / c) + 1... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); ; vector<int> v(n); for (int i = 0; i < n; i++) scanf( %d , &v[i]); ; int diff = 0; int ans = v[0]; for (int i = 0; i < n - 1; i++) { diff += (v[i] - v[i + 1]); if (diff < 0) { ... |
#include <bits/stdc++.h> using namespace std; bool flag = true; const long long int N = 2e5 + 5; const long long int inf = 998244353; void solve() { long long int i = 0, j = 0, ans = 0, x = 0, y = 0, z = 0; long long int n, k = 0, m = 0, mn = LLONG_MAX, mx = LLONG_MIN; cin >> n >> k; vector<lo... |
#include <bits/stdc++.h> using namespace std; const int sz = 15000001; int n; int sieve[sz]; int v[300001]; int cnt[sz]; inline void solve() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &v[i]); } for (int i = 2; i < sz; i++) if (sieve[i] == 0) { for (int... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a = 0, b = 0; cin >> n; char s; while (n--) { cin >> s; if (s == L ) a++; else b++; } cout << a + b + 1 << endl; return 0; } |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 19:23:42 10/30/2011
// Design Name: M_uxa_ps2_busctl
// Module Name: /Users/kc5tja/tmp/kestrel/2/nexys2/uxa/ps2io/T_uxa_ps2_busctl.v
// Project Name: ps2io
// Target... |
#include <bits/stdc++.h> using namespace std; long long md = 1e9 + 7; const int N = 100005; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } ... |
// (C) 1992-2014 Altera Corporation. All rights reserved.
// Your use of Altera Corporation's design tools, logic functions and other
// software and tools, and its AMPP partner logic functions, and any output
// files any of the foregoing (including device programming or simulati... |
#include <bits/stdc++.h> using namespace std; int main() { double x1, y1, x2, y2, x0, y0; while (scanf( %lf%lf%lf%lf%lf%lf , &x0, &y0, &x1, &y1, &x2, &y2) != EOF) { double area = x0 * y1 + x2 * y0 + x1 * y2 - x2 * y1 - x0 * y2 - x1 * y0; if (area == 0) { printf( TOWARDS n ); } else... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3fffffff; const long long oo = 3000000000000000000LL; int tes, n; long long ans[3], mn[4], mx[4], ll[4], rr[4], lt[4], rt[4], ret[3]; bool get(long long s, long long x, long long y, long long z) { if (s <= x) { ret[0] = s; ret[1... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 29.10.2015 13:14:46
// Design Name:
// Module Name: pfd
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:... |
#include <bits/stdc++.h> using namespace std; using ll = int; vector<pair<ll, string>> con[101010]; int main() { ios_base::sync_with_stdio(false); cout.tie(NULL); int n, m; cin >> n >> m; int reg, sc; string name; while (n--) { cin >> name; cin >> reg; cin >> sc; ... |
#include <bits/stdc++.h> using namespace std; int n, p, q, d[110]; void nhap() { memset(d, 0, sizeof(d)); int x; cin >> n >> p; for (int i = 1; i <= p; i++) { cin >> x; d[x] = 1; } cin >> q; for (int i = 1; i <= q; i++) { cin >> x; d[x] = 1; } } void cbi... |
#include <bits/stdc++.h> template <class T> std::string toStr(T t); using namespace std; int main() { int statA[4]; int statB[4]; for (__typeof(4) i = 0; i < 4; i++) { cin >> statA[i]; cin >> statB[i]; } int pos[4][4] = {{0, 1, 2, 3}, {1, 0, 2, 3}, {0, 1, 3, 2}, {1, 0, 3, 2}}; ... |
/**
* 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 s = ; cin >> s; int y = 0; while (s[y] == a && y <= s.length()) ++y; for (int i = y; i < s.length(); ++i) { if (s[i] == a ) break; else --s[i]; } if (y == s.length()) s[s.length() - 1] = z... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.