text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int i, t; double a, b; int main() { cin >> t; for (i = 0; i < t; i++) { cin >> a >> b; if (b == 0) { cout << 1 << endl; continue; } b *= 4; if (a > b) { cout << 1.0 - b / (4.0 * a) << endl; contin...
/* This file is part of JT12. JT12 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 3 of the License, or (at your option) any later version. JT12 program is distributed...
#include <bits/stdc++.h> using namespace std; int main() { int k, n, w; cin >> k >> n >> w; int s = 0; for (int i = 1; i <= w; i++) { s += i * k; } if (n < s) cout << s - n; else cout << 0; 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 law...
#include <bits/stdc++.h> using namespace std; const long long MAX = 2e5 + 9, LG = 35; long long sum, b[MAX], c[MAX], a[MAX], n, k[LG]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> b[i], sum += b[i]; for (int i = 0; i < n; i++) cin >> c[i], sum += c[i]; if (sum % (2 * n) != 0) return...
/* * 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 2013(c) Analog Devices, Inc. // Author: Lars-Peter Clausen <> // // All rights reserved. // // Redistribution and use in source and binary forms, ...
#include <bits/stdc++.h> using namespace std; vector<int> ad[100009]; vector<int> idx; deque<int> vec; int cnt[100009]; int ans[100009]; vector<pair<int, int> > arr, arr2; int val[100009]; set<int> s; int main() { int a, b, c, d, e, i, j, k, l, n, m, x, y, t, p, X; scanf( %d , &t); for (...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using D = double; using uint = unsigned int; const int maxn = 1005; int n; int a[maxn]; int cnt[maxn]; int have[maxn]; int was[maxn]; int ct = 0; inline bool canset(int x) { int wh = lower_bound(a, ...
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == - ) flag = true; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = ...
#include <bits/stdc++.h> using namespace std; #define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR(i,m) for(int i = 0 ;i < m ;i++) #define mem(a ,b) memset(a, (b) , sizeof(a)) #define all(cont) cont.begin(),cont.end() #define mp make_pair #define pb pus...
module jt12_pcm( input rst, input clk, input clk_en /* synthesis direct_enable */, input zero, input signed [8:0] pcm, input pcm_wr, output reg signed [8:0] pcm_resampled ); // reg [2:0] ratesel; // reg [3:0] cnt8; // ...
#include <bits/stdc++.h> using namespace std; const long long Ar[20] = {1, 1, 2, 3, 6, 40, 80, 1260, ...
#include <bits/stdc++.h> using namespace std; int a[2000050]; int b[2000050]; int c[2000050]; struct node { int x, y; node() {} node(int xx, int yy) { x = xx, y = yy; } } q[2000050]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]); for (int ...
#include <bits/stdc++.h> using namespace std; vector<int> a, b; int main() { int n, m; cin >> n >> m; int x = n + m; int mx = 1; while (1LL * mx * (mx + 1) / 2 <= x) mx++; mx--; for (int i = mx; i >= 1; i--) { if (n >= i) { n -= i; a.push_back(i); } else { ...
/* * 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; enum op_t { AND = 0, OR, XOR, VAL }; op_t bin_op_from_string(const string& s) { if (s == AND ) { return AND; } else if (s == OR ) { return OR; } else if (s == XOR ) { return XOR; } else { throw std::runtime_error( Unknown op:...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { string s; cin >> s; string word = ; for (auto x : s) { if (x == _ ) { word = ; } else { word = word + x; } } if (word.s...
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() ...
module multiple_blocking_gate (clk, ctrl, din, sel, dout); input clk; input [4:0] ctrl; input [1:0] din; input [0:0] sel; output reg [31:0] dout; reg [5:0] a; reg [0:0] b; reg [2:0] c; always @(posedge clk) begin a = (ctrl)+(1); b = (sel)-(1); 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...
// A simple OSD implementation. Can be hooked up between a cores // VGA output and the physical VGA pins module osd ( // OSDs pixel clock, should be synchronous to cores pixel clock to // avoid jitter. input pclk, // SPI interface input sck, input ss, input sdi, // VGA signals comi...
// $Id: c_spreader.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 of sou...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; int main() { int flag = 0; long long n, a, b; cin >> n >> a >> b; long long x = a, y = b; if (a > b) { swap(a, b); flag = 1; } if (a * b > 6 * n) { printf( %lld n , a * b); printf( %lld %l...
/** * 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; using std::string; int main() { int n; cin >> n; string s; cin >> s; int f = 0; for (int i = 0; i < s.size() - 1; i++) { if (s[i + 1] < s[i]) { for (int j = i + 1; j < s.size(); j++) s[j - 1] = s[j]; f = 1; break; ...
#include <bits/stdc++.h> using namespace std; int nod, edge; int a[401][401]; int dist[401]; int vis[401]; int bfs(int node) { queue<int> q; q.push(node); vis[node] = 1; while (q.size()) { int cur = q.front(); q.pop(); if (cur == nod) return dist[cur]; for (int i = no...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 ) using namespace std; long long powmod(long long a, long long b, long long mod) { if (b == 0 || a == 1) { if (mod == 1) return 0; else return 1; } if (b % 2 == 0) { long...
//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 documentatio...
#include <bits/stdc++.h> using namespace std; inline int readInt() { static int n, ch; n = 0, ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) n = n * 10 + ch - 0 , ch = getchar(); return n; } const int MAX_N = 500000 + 3; int n, k, a[MAX_N], b[MAX_N]; struct Dat...
#include <bits/stdc++.h> using namespace std; long long xa, xb, ya, yb, xc, yc, t; long long cp(long long x1, long long x2, long long y1, long long y2) { return x1 * y2 - x2 * y1; } int main() { cin >> xa >> ya >> xb >> yb >> xc >> yc; t = cp(xc - xa, xb - xa, yc - ya, yb - ya); if (t == 0) { ...
/******************************************************************************* * 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 ...
#include <bits/stdc++.h> using namespace std; int a[100010], b[100010]; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) { scanf( %1d , &a[i]); b[i] = b[i - 1] + a[i]; } for (int i = 1; i + k - 1 <= n; i++) { int sum = b[i - 1] + b[n] - b[i + k - 1];...
#include <bits/stdc++.h> using namespace std; void task(); int main() { task(); return 0; } const int N = 6400 + 2; const int S = N - 2; const int T = N - 1; struct Rib { int to; int cap; int flow; int back; int cost; }; const int INF = 0x3f3f3f3f; vector<Rib> g[N]; i...
/*--------------------------------------------------------------------------------------------------------------------- -- Author: Peter Hasza, -- -- Create Date: 04/02/2017 -- Module Name: fifo1 -- Project Name: AXI_SPI_IF -- Description: -- One entry depth FIFO module -- ---------...
#include <bits/stdc++.h> using namespace std; vector<int> a, Q; vector<vector<int>> Q2; int n; void help(int x) { int p1, p2, p3, s1, s2, s3, s4; vector<int> A, B, C, D; p3 = find(a.begin(), a.end(), x) - a.begin(); p1 = find(a.begin(), a.end(), x + 1) - a.begin() - 1; p2 = p3; while (...
#include <bits/stdc++.h> using namespace std; const long long mod = 51123987; string s; int n; long long d[50 + 10][50 + 10][150 + 10][3]; int NEXT[150 + 10][5]; inline int nex(int MIN, int c) { return NEXT[MIN][c]; } int main() { ios_base::sync_with_stdio(false); cin >> n >> s; for (int 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 n, i, j, k, p = 1000000007; int A[10], B[10]; int main() { cin >> n; A[0] = 1; for (i = 1; i <= n; i++) { for (j = 0; j <= 3; j++) for (k = 0; k <= 3; k++) { if (j == k) continue; B[j] = (B[j] + A[k]) % p; } ...
module clock_divider( input wire clk, input wire reset, input wire enabled, output reg refresh_clk, output reg sys_clk ); reg [8:0] counter1; reg [8:0] counter2; reg [8:0] clk_divid; always@(posedge clk or negedge reset) begin if( ~reset ) begin refresh_clk <= 1; ...
module overlay_fallback #( parameter DATA_WIDTH = 12 parameter CHARACTER_SIZE = 32 )( input wire i_clk, input wire [DATA_WIDTH-1:0] i_data input wire i_vactive, input wire i_hactive, output wire [DATA_WIDTH-1:0] o_data, output wire o_vactive, output wire o_hactive ); /*-----------...
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<db, db>; using vi = vector<int>; using vl = vector<ll>; using vd = vector<db>; using vs = vector<string>; using vii = vector<pii>; using v...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; struct point { int x, y; point() {} point(int _x, int _y) : x(_x), y(_y) {} point operator-(const point& other) const { return point(other.x - x, other.y - y); } long long operator/(const point& other) const { return x * 1LL * other.y...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003, 2007 Matt Ettus // // 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 of the L...
#include <bits/stdc++.h> using namespace std; int n; int l; int a[1000007]; int minn[1000007], maxn[1000007], cnt; int cmp(int x, int y) { return x > y; } int main() { scanf( %d , &n); long long ans = 0; for (int i = 1; i <= n; i++) { scanf( %d , &l); int flag = 0; for (int j...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. reg r_change; reg [width-1:0] r_test_expr; reg r_state; parameter WIN_CHANGE_START = 1'b0; parameter WIN_CHANGE_CHECK = 1'b1; `ifdef OVL_XCHECK_OFF //Do nothing `else `ifdef OVL_IMPLI...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k; int n, m; double H, L; cin >> H >> L; cout << fixed << setprecision(10) << ((L * L - H * H) / (2 * H)); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { long long s, x1, x2, t1, t2, p, d; cin >> s >> x1 >> x2 >> t1 >> t2 >> p >> d; long long ans = abs(x1 - x2) * t2; long long i = p, t = 0; while (i != x1) { i += d; t += t1; if (i == s) d = -1; else if (i...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `ifdef OVL_ASSERT_ON wire xzcheck_enable; `ifdef OVL_XCHECK_OFF assign xzcheck_enable = 1'b0; `else `ifdef OVL_IMPLICIT_XCHECK_OFF assign xzcheck_enable = 1'b0; `else assign xzcheck_...
/* * 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 gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int n, arr[105]; cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; int an...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, a[500005], tot, s[500005], c[500005], tmp[1500005], num; priority_queue<int> q; bool cmp(int x, int y) { return x > y; } int main() { long long ans = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]), ans += a[i]; sort(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> int query(long long q) { printf( ? %lld n , q); fflush(stdout); int gcd; scanf( %d , &gcd); return gcd; } void printAnswer(int answer) { printf( ! %d n , answer); fflush(stdout); } const int MAX_PRIMES = 617; const int MAX_X = 1000 * 1000 * 1000; const ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : 10....
/* Copyright (c) 2015-2016 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
#include <bits/stdc++.h> const int MAXN = 1100000; char s[MAXN]; int n; bool check(int o) { int p = 0; int mx = 0; bool uni = true; for (int i = 0; i < n; i++) { if (s[i] == L ) p--; else { if (p < o - 1) p++; } if (p < mx) { mx = p; uni =...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 5; int arr[maxn][maxn]; int main() { int m, n, k, p, sum = 0; bool bol = false; cin >> n >> m >> k; if (n % 2 != m % 2) { cout << 0 << endl; return 0; } if (m > n) { bol = true; swap(n, m); ...
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> inline T range(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } inline void setin(string s) { freopen(s.c_str(), r , stdin); } inline void setout(string...
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e18; const int mod = (int)1e9 + 7; const int MAXN = (int)1e5 + 5; long long n; const int bs = 350; int a[MAXN]; int mp[600][MAXN]; vector<int> ls[1000]; void swp(int l, int r) { int size = 0, i = 0; vector<int> t...
#include <bits/stdc++.h> using namespace std; const int maxn = ((int)5e2) + 5; vector<string> str; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { string s; cin >> s; str.push_back(s); } ...
#include <bits/stdc++.h> using namespace std; const int MaxN = 100100; const int Mod = 1e9 + 7; long long N, S; long long p[MaxN]; long long deg[MaxN]; long long pref[MaxN]; long long depth[MaxN]; vector<long long> child[MaxN]; void solve(long long branch) { for (int j = (2); j < (N + 1); j++) {...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const int N = (int)(2e6 + 20); const int L = 1 << 6; const long long int M = (long long int)(1e9 + 7); const double E = 1e-7; int a[N]; int main() { ios_base::sync_with_stdio(0); long long int n, m; cin >> n >> m; ...
////////////////////////////////////////////////////////////////////// //// //// //// Copyright (C) 2014 //// //// //// //// This source file may be used and distributed witho...
#include <bits/stdc++.h> using namespace std; int pre[5005][5005]; int main() { int n, k; bool flag = true; scanf( %d%d , &n, &k); map<int, int> m; for (int i = 1; i <= n; i++) { int yy; scanf( %d , &yy); m[yy]++; pre[yy][m[yy]] = i; if (m[yy] > k) flag = false; ...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const int inf = 1000000009; int i, j, k, l, m, n, q; int ans; int a[4][1000][1000], h[4][1000][1000], W[4], H[4]; void prec(int k, int i) { for (int j = 0; j < H[k]; j++) { if (h[k][i][j] == 0) a[k][i][j] = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; n--; k--; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int count = 0; int flag = 0; while (count <= k) { if (count == k) { flag = 1; break; } count += a...
#include <bits/stdc++.h> using namespace std; const int inf = (int)1.01e9; const double eps = 1e-9; const int maxn = (int)2e5 + 10; set<int> S; int main() { int n, k, a; scanf( %d%d%d , &n, &k, &a); int cur = (n + 1) / (a + 1); assert(cur >= k); int m; scanf( %d , &m); for (int i...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Montvydas Klumbys // // Create Date: // Design Name: // Module Name: PixCounter // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Rev...
#include <bits/stdc++.h> using namespace std; struct node { int x, y, id; }; node A[1000100]; int ans[1000100]; vector<int> P[1200]; int cmp1(node a, node b) { return a.x < b.x; } int cmp2(int a, int b) { return A[a].y < A[b].y; } const int Base = 1000; int main() { int n; scanf( %d , &n...
/** * 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 n, k, t; int a[25][25]; int vis[25]; int dfs(int x, int sum, int limit) { if (sum > limit) return 0; if (x == n + 1) return 1; int ans = dfs(x + 1, sum, limit); for (int i = 1; i <= n; i++) if (vis[i] == 0 && a[x][i]) vis[i] = 1, ...
#include <bits/stdc++.h> using namespace std; struct node { double x, y, r; }; double dis(node a, node b) { double dx = a.x - b.x, dy = a.y - b.y; return sqrt(dx * dx + dy * dy); } double R, d; node origin = {0, 0}; bool check(node a) { double distance = dis(a, origin); if (distance ...
/** * 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; bool boy[1000], girl[1000]; int n, m, b, g, x, y, q[1000][2], h, t; int main() { memset(boy, false, sizeof(boy)); scanf( %d%d%d , &n, &m, &b); for (int i = 1; i <= b; i++) { scanf( %d , &x); boy[x] = true; } memset(girl, false, sizeof...
/* * 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)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 N; string S[100001]; int cnt[26]; int from[26]; int find(int ind, char C) { for (int i = 0; i < S[ind].length(); i++) if (S[ind][i] == C) return i; return -1; } void merge(int I, int J, char C) { int indI = find(I, C); int indJ = fi...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; int qtd[200007]; int vogal(char ch) { return ch == a || ch == e || ch == i || ch == o || ch == u || ch == A || ch == E || ch == I || ch == O || ch == U ; } map<int, int> prim; int main() { string s; cin >> s; int res...
/** * 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...
//---------------------------------------------------------------------------- //-- Asynchronous serial transmitter Unit //------------------------------------------ //-- (C) BQ. December 2015. Written by Juan Gonzalez (Obijuan) //-- GPL license //------------------------------------------------------------------------...
#include <bits/stdc++.h> using namespace std; long long re() { long long x; scanf( %lld , &x); return x; } int main() { long long y1 = re(), x1 = re(), y2 = re(), x2 = re(); long long h = (x2 - x1) / 2 + 1; cout << h * (((y2 - y1 + 1) + 1) / 2) + (h - 1) * ((y2 - y1 + 1) / 2) << endl; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<float> coordinates; for (int i = 0; i < (int)(n); ++i) { float a, b; cin >> a >> b; coordinates.push_back(a); coordinates.push_back(b); } float sum = 0; std::cout << fixed; ...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int n, q; set<pair<int, int> > st; set<int> unread[N]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n >> q; int cnt = 0; while (q--) { int type, x; cin >> type; i...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int MAX = 30; long long x, num; long long a[40]; bool check(long long x) { for (int i = 1; i < MAX; ++i) { if (a[i] == x) return 1; } return 0; } vector<int> ans; int main() { long long x = 1; for (in...
/** * 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 N = 500500; long long i, j, k, n, sum, ch, t, ans, num; long long a[N], b[N], c[N]; void R(long long &x) { x = 0; ch = getchar(); while (ch < 0 || 9 < ch) ch = getchar(); while ( 0 <= ch && ch <= 9 ) x = x * 10 + ch - 0 , ch ...
#include <bits/stdc++.h> using namespace std; using LL = long long; namespace _buff { const size_t BUFF = 1 << 19; char ibuf[BUFF], *ib = ibuf, *ie = ibuf; char getc() { if (ib == ie) { ib = ibuf; ie = ibuf + fread(ibuf, 1, BUFF, stdin); } return ib == ie ? -1 : *ib++; } } // na...
#include <bits/stdc++.h> using namespace std; int n, a[101], piller; int main() { cin >> n; for (auto i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (auto i = 0; i < n; i++) { if (piller * a[i] + piller <= i) piller++; } cout << piller; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1000010, mod = 1e9 + 7; int i, j, k, n, m, y, e; long long ans = 1, a[maxn]; int main() { a[0] = 1; a[1] = 1; cin >> n; for (i = 2; i <= n; i++) a[i] = (a[i - 2] * (i - 1) + a[i - 1]) % mod; for (i = 1; i <= n; i++) { int...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo_mixed_widths // ============================================================ // File Name: Sdram_WR_FIFO.v // Megafunction Name(s): // dcfifo_mixed_widths // // Simulation Library Files(s): // altera_mf // ===============...
#include <bits/stdc++.h> using namespace std; double eps = 1e-7; int main() { int t; double a, b, ans; scanf( %d , &t); while (t--) { scanf( %lf%lf , &a, &b); ans = 0.50000000; if (b < eps) { printf( %lf n , 1.0); continue; } if (a < eps) { pri...
#include <bits/stdc++.h> using namespace std; bool compare(string &s1, string &s2) { return s1.size() < s2.size(); } void solve() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i]; sort(s.begin(), s.end(), compare); for (int i = 0; i < n - 1; i++) if (s[...
/* * Copyright (c) 2002 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) * ...
/* Copyright (C) 2016 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 http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distribute...
#include <bits/stdc++.h> using namespace std; template <typename U, typename V> void Min(U &a, const V &b) { if (a > b) a = b; } template <typename U, typename V> void Max(U &a, const V &b) { if (a < b) a = b; } template <typename U, typename V> void add(U &a, const V &b) { a = (a + b) % 1...