Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | //Original Code:
//#include <self/utility>
//#include <self/debug>
//using namespace std;
//const int U=(1<<20)-1;
//int n,q;
//int inv[(1<<20)];
//
//struct Node
//{
// Node *l=0,*r=0;
// int sz;
// int ed;
// int swp=0;
// int hasl=0,hasr=0;
// Node(int _v):sz(_v),ed(_v){}
// void pushup()
// {
// sz=(l?l->sz:0)+(r?... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | /*
author: Maksim1744
created: 06.05.2021 16:01:27
*/
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
template<int H>
struct MergeTree {
array<MergeTree<H-1>*, 2> ch;
array<int, H+1> branch_cou;
// (01 -> no change), (00 -> set 0), (11 -> set 1), (10 -> flip)
uint s0 = 0, s1 = -1;
uint size = 0;
MergeTree() : branch_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
const int maxlog=19;
const int maxnode=(1<<21)+((maxlog+5)<<1);
int rt,tag[maxnode][2],frk[maxnode],ch[maxnode][2],sz[maxnode],sta[maxnode],top,tot; // 0000->tag[0] 1111->tag[1] frk:can merge
// time complexity: potetion:#nodes, ~delta*log
inline int newnode() { return ((to... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
const int N=1234568,B=(1<<20)-1; bool fl[N]; int op,l,r,x;
int n,m,ql,qr,rt,ans,A,q[N],fa[N],s1[N],s2[N],ch[N][2],dep[N],f1[N],f2[N],f3[N],qt[N],qc[N];
inline bool get(int u){
return (ch[fa[u]][1]==u);
}
inline void upd(int u){
if(dep[u]==-1) return;
if(!ch[u][1]) f1[u]=f... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | /*
author: Maksim1744
created: 06.05.2021 16:01:27
*/
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
const int M = 4000003, all = (1<<20)-1;
template<typename T>
void read(T &x){
int ch = getchar(); x = 0; bool f = false;
for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-';
for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
if(f) x = -x;
}
int n, q,... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <cstdio>
#include <iostream>
using namespace std;
const int M = 10000005;
int read()
{
int x=0,f=1;char c;
while((c=getchar())<'0' || c>'9') {if(c=='-') f=-1;}
while(c>='0' && c<='9') {x=(x<<3)+(x<<1)+(c^48);c=getchar();}
return x*f;
}
int n,k,q,rt,cnt,now,ls[M],rs[M],res[M],la[M],v[M],vk[M];
void up(int x... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | /*
author: Maksim1744
created: 06.05.2021 16:01:27
*/
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<stdio.h>
const int maxn=200005,maxk=maxn*50;
int n,q,k,rt,cnt;
int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk];
inline void swp(int &a,int &b){
a+=b,b=a-b,a-=b;
}
inline void pushup(int now){
Vand[now]=Vand[lc[now]]|Vand[rc[now]];
Vor[now]=Vor[lc[now]]|Vor[rc[now]];
res[now]=res[lc[now]]+re... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=4444444,mod=998244353,A1=(1<<20)-1;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
constexpr int LV = 20, M = (1 << LV) - 1;
int n, q;
struct D {
D* c[2] = {nullptr, nullptr};
// bx: bits that differ, by: not in bx, the same bit
int bx = 0, by = 0, num = 0, lz = 0;
void down(int lv) {
if (lv < 0) return;
if (lz >> lv & ... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
char c=getchar();bool f=0;x=0;
while(!isdigit(c)) f|=c=='-',c=getchar();
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
if(f) x=-x;return x;
}
template<class t> inline void write(t x){
if(x<0) putchar('-'),wr... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;
template <typename T>
inline void read(T &f) {
f = 0; T fu = 1; char c = getchar();... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD;
struct modint {
private:
int v;
static int minv(int a, int m) {
a %= m;
assert(a);
return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
}
public:
modint() : v(0) {}
modint(ll v_) : v(int(v_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
const int N=200005,f=(1<<20)-1;
int n,q,u,m,lc[N<<6],rc[N<<6],tr[N<<6],t0[N<<6],t1[N<<6],t[N<<6];
void pt(int u,int p,int x)
{
if(!u)
return;
if(x>>(p-1)&1)
swap(lc[u],rc[u]);
int v0=(t0[u]&(~x))|(t1[u]&x),v1=(t1[u]&(~x))|(t0[u]&x);
t0[u]=v0,t1[u]=v1,t[u]^=x;
}
void ... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | /*
author: Maksim1744
created: 06.05.2021 16:01:27
*/
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
const int LG = 20, U = (1 << LG) - 1;
struct Node {
int all0, all1;
int sz;
Node() : all0(U), all1(U), sz(0) {}
Node(int a0, int a1, int _sz) : all0(a0), all1(a1), sz(_sz) {}
};
Node operator+(const Node &a, const Node &b) {
return Node(a.all0 & b.all0, a.all1 & b.all1, a.sz + b.sz);
}... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<stdio.h>
const int maxn=200005,maxk=maxn*40;
int n,q,k,rt,cnt;
int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk];
inline void swp(int &a,int &b){
a+=b,b=a-b,a-=b;
}
inline void pushup(int now){
Vand[now]=Vand[lc[now]]|Vand[rc[now]];
Vor[now]=Vor[lc[now]]|Vor[rc[now]];
res[now]=res[lc[now]]+re... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
#define lson ls[x],l,mid
#define rson rs[x],mid+1,r
using namespace std;const int N=2e5+7,M=N*50;
int rt,rt1,x,n,m,i,j,l,r,t,tk[M],ls[M],rs[M],ts[M],ts0[M],ts1[M],U,tag[M],sz;
void ud(int x){ts[x]=ts[ls[x]]+ts[rs[x]];ts0[x]=ts0[ls[x]]|ts0[rs[x]];ts1[x]=ts1[ls[x]]|ts1[rs[x]];}
int newnode(int k){... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 200005;
const int maxd = 19;
const int S = (1 << (maxd + 1)) - 1;
const int maxp = 10000005;
int ch[maxp][2], sz[maxp], sta[maxp][2];
inline void pushup(int x) {
sz[x] = sz[ch[x][0]] + sz[ch[x][1]];
for(int i = 0; i <= 1; i++)
sta[x]... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
const int maxb=20;
const int maxs=1<<maxb;
int n,q,tot,top,rt;
int st[maxs<<1],ls[maxs<<1],rs[maxs<<1],tag0[maxs<<1],tag1[maxs<<1],tagx[maxs<<1],sdep[maxs<<1],cnt[maxs<<1];
vector<pair<pair<int,int>,int> >todo;
void apply0(int cur,int mask){
tag1[cur]&=~mask;
tagx[cur]&=... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
T t=0;
char k;
bool vis=0;
do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
return vis?-t:t;
}
# define fre(k... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD;
struct modint {
private:
int v;
static int minv(int a, int m) {
a %= m;
assert(a);
return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
}
public:
modint() : v(0) {}
modint(ll v_) : v(int(v_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <stdio.h>
#include <stdlib.h>
#define N 200000
#define Q 100000
#define N_ ((N + Q * 2) * (LG + 1))
#define LG 20
#define B (1 << LG)
int ll[1 + N_], rr[1 + N_], sz[1 + N_], msk0[1 + N_], msk1[1 + N_], lz[1 + N_], _ = 1;
void put(int u, int lg, int x) {int tmp, x0, x1;if (u == 0)return;if ((x & 1 << lg - 1) !=... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | /* https://codeforces.com/blog/entry/90236 (segment tree beats) */
#include <stdio.h>
#include <stdlib.h>
#define N 200000
#define Q 100000
#define N_ ((N + Q * 2) * (LG + 1))
#define LG 20
#define B (1 << LG)
int ll[1 + N_], rr[1 + N_], sz[1 + N_], msk0[1 + N_], msk1[1 + N_], lz[1 + N_], _ = 1;
void put(int u, int ... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<stdio.h>
const int maxn=200005,maxk=maxn*50;
int n,q,k,rt,cnt;
int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk];
inline void swp(int &a,int &b){
a+=b,b=a-b,a-=b;
}
inline void pushup(int now){
Vand[now]=Vand[lc[now]]|Vand[rc[now]];
Vor[now]=Vor[lc[now]]|Vor[rc[now]];
res[now]=res[lc[now]]+re... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
const int B=20;
int n,q,rt=1,cnt=1;
int t0[15000000],t1[15000000],sz[15000000],s[2][15000000],lz[15000000];
void pushup(int id,int d){
sz[id]=sz[s[0][id]]+sz[s[1][id]];
t0[id]=t0[s[0][id]]|t0[s[1][id]];
t1[id]=t1[s[0][id]]|t1[s[1][id]];
if(s[0][id])t0[id]|=(1<<d);
if(s... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
#define ll long long
#define N 200015
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define lowbit(i) ((i)&(-i))
#define VI vector<i... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <cstdio>
#include <cassert>
#include <utility>
#include <functional>
//numbers up to 2^MAXLOGX-1
const int MAXLOGX=20;
template<int k>
struct Trie{
Trie<k-1>* chd[2];
int cnt;
int lazy;
int has[2];
int get_cnt(){
assert(this!=NULL);
return cnt;
}
int get_has(int d){
assert(this!=NUL... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | //因为,已经我不想写代码了啊
#include<stdio.h>
const int maxn=200005,maxk=maxn*40;
int n,q,k,rt,cnt;
int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk];
inline void swp(int &a,int &b){
a+=b,b=a-b,a-=b;
}
inline void pushup(int now){
Vand[now]=Vand[lc[now]]|Vand[rc[now]];
Vor[now]=Vor[lc[now]]|Vor[rc[now]];
res[now]... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<stdio.h>
const int maxn=200005,maxk=maxn*40;
int n,q,k,rt,cnt;
int lc[maxk],rc[maxk],lazy[maxk],Vand[maxk],Vor[maxk],res[maxk];
inline void swp(int &a,int &b){
a+=b,b=a-b,a-=b;
}
inline void pushup(int now){
Vand[now]=Vand[lc[now]]|Vand[rc[now]];
Vor[now]=Vor[lc[now]]|Vor[rc[now]];
res[now]=res[lc[now]]+re... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
const int M = 2111111, all = (1<<20)-1;
template<typename T>
void read(T &x){
int ch = getchar(); x = 0; bool f = false;
for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-';
for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
if(f) x = -x;
}
int n, q,... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
struct Node {
int cnt;
int type;
int tag;
int both;
int d;
Node *lc, *rc;
};
Node *null = new Node();
Node *newNode(int d) {
Node *t = new Node();
*t = *null;
t->d = d;
return t;
}
Node *merge(Node *, Node *);
void maintain(Node *);
void pull(Node *t) {
if (t->d ... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 5, K = 20, W = 1 << K;
int n, q, tot;
int ls[N], rs[N], sum[N], or0[N], or1[N], tag[N], dep[N];
void pushup(int p) {
sum[p] = sum[ls[p]] + sum[rs[p]];
or0[p] = or0[ls[p]] | or0[rs[p]];
or1[p] = or1[ls[p]] | or1[rs[p]];
}
void Tag(int p, int k) ... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <list>
#include <cassert>
#include <climits>
#inclu... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); i++)
#define R(i, j, k) for(int i = (j); i >= (k); i--)
#define ll long long
#define sz(a) a.size()
#define vi vector<int>
using namespace std;
const int N = 2e5 + 7, M = N * 80, rk = 20, mx = (1 << rk) - 1;
int n, q, a[N];
int ch[M][2], to0[M], to... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <cstdio>
#include <cassert>
#include <algorithm>
int n,q;
int rt,cnt;
int ch[2][8000001],size[8000001],diff[8000001],val[8000001],lazy[8000001];
bool vis[8000001];
void pushup(int x){
if(vis[x])return;
if(!size[ch[0][x]]){
size[x]=size[ch[1][x]];
diff[x]=diff[ch[1][x]];
val[x]=val[ch[1][x]];
}
else ... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1048576,C=20;
int Ri(){
int x=0;
char c=getchar();
for (;c<'0'||c>'9';c=getchar());
for (;c<='9'&&c>='0';c=getchar()) x=x*10+c-'0';
return x;
}
int n,cq;
struct tree{
int s[2],cnt,all[2],rev;
}tr[N*2+9];
int sta[N*2+9],cst;
i... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD;
struct modint {
private:
int v;
static int minv(int a, int m) {
a %= m;
assert(a);
return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
}
public:
modint() : v(0) {}
modint(ll v_) : v(int(v_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
const int N = 8e6 + 5, K = 20, M = 1 << K;
int n, q, tot, ls[N], rs[N], tk[N], t0[N], t1[N], ts[N], tt[N];
inline void pushup(int p) {
ts[p] = ts[ls[p]] + ts[rs[p]];
t0[p] = t0[ls[p]] | t0[rs[p]];
t1[p] = t1[ls[p]] | t1[rs[p]];
}
inline void tag(int p, int t) {
if (!p) return; tt[p] ^=... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | /*
{
######################
# Author #
# Gary #
# 2021 #
######################
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
typedef long long i64;
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using namespace std;
const int xn = 8e6, xk = 20, xs = 1 << xk;
int n = 1, ls[xn], rs[xn], h... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
//#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b secon... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printA... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
t=0; char ch=getchar(); int f=1;
while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e7)+10;
int n,q,a[200010];
int rt,tot,N;
int ls[m... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=200010,D=20,M=N*D,Mx=(1<<D)-1;
int n,m;
namespace trie{
int val[M],ls[M],rs[M],tot,tag[M];
int h0[M],h1[M];
void setg(int u,int v,int d=D-1)
{
if(!u || d<0) return;
if(v>>d&1) swap(ls[u],rs[u]);
... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <cstdio>
#include <algorithm>
const int Maxn=200000;
const int Maxv=(1<<20);
const int Maxk=20;
int n,q;
int a[Maxn+5];
int Root,id_tot;
struct Trie_Node{
int ch[2];
int val_0,val_1;
int sum;
int lazy;
}seg[Maxn*Maxk+5];
int st[Maxn*Maxk+5],st_top;
int new_node(){
int u;
if(st_top>0){
u=st[st_top--];
... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD;
struct modint {
private:
int v;
static int minv(int a, int m) {
a %= m;
assert(a);
return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
}
public:
modint() : v(0) {}
modint(ll v_) : v(int(v_... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define debug(...) //ignore
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long double ld;
const int LEV = 22;
const int M1 =... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | #include <cstdio>
#include <cassert>
#include <utility>
#include <functional>
#define X first
#define Y second
const int mod = 998244353;
template<int k>
struct node{
node <k-1>* chd[2];
int cnt;
int lazy;
int has[2];
int get_cnt(){
assert(this!=NULL);
return cnt;
}
int get_has(int d){
assert(... | CPP |
1515_H. Phoenix and Bits | Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries:
1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x;
2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x;
3. replac... | 2 | 14 | // Author: wlzhouzhuan
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fir first
#define sec second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = ... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.util.Scanner;
/**
*
* @author Acer
*/
public class ExcitingBets {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
while(T-- > 0){
long a = sc.nextLong();
long b = sc.nextLong();
if(a=... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import io,os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import math
t=int(input())
while(t>0):
t-=1
a,b=sorted(list(map(int,input().split())))
if(a==0):
print(str(b)+" 0")
continue
if(a==b):
print("0 0")
continue
if((b-a)==1):
print("1 0")
... | PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw=new PrintWriter(System.out);
int t=Integer.parseInt(br.readLine());
while(t-->0)
{
... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define M 1000000007
#define read(arr) for(int i=0;i<n;i++) cin>>arr[i];
#define print(arr) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<endl;
#define vl vector<ll>
bool sortcoll(vector<ll> &v1, vector<ll> &v2)
{
return v1[1]>v2[1];
}
bool i... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include <bits/stdc++.h>
typedef long long int ll;
const unsigned int MOD = 1000000007;
using namespace std;
int main()
{
int t;
cin >> t;
for (int tt = 0; tt < t; tt++)
{
ll a,b;
cin>>a>>b;
if(a>b)
swap(a,b);
if(a==b)
cout<<"0 0\n";
else
{
ll x=abs(a-b);
... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
c=0
a,b=list(map(int,input().split()))
if a==b:
print(0,0)
else:
g=abs(a-b)
print(g,min(a%g,g-a%g))
| PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | T = int(input())
for _ in range(T):
a, b = map(int, input().split(' '))
if a < b:
a, b = b, a
if a == b:
print("0 0")
else:
d = a - b
steps = min(b % d, d - b % d)
print("{} {}".format(d, steps))
| PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.util.*;
import java.lang.Math;
public class yoo
{
public static void main(String args[])
{
int t;
long n1,n2,a1,b1;
Scanner sc=new Scanner(System.in);
... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.io.*;
import java.math.BigInteger;
import java.util.*;
/*long startTime = System.currentTimeMillis(); //获取开始时间
* long endTime = System.currentTimeMillis(); //获取结束时间
* System.out.println("程序运行时间:" + (endTime - startTime) + "ms"); //输出程序运行时间
*/
public class Main{
static final int n=998... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import sys
import os
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
f = sys.stdin
line = lambda: f.readline().strip('\r\n').split()
def solve():
d = abs(A-B)
if d == 0:
return "0 0"
r = A%d
b = A-r
t = b+d
if A-b <= t-A:
s = A-b
else... | PYTHON |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.util.Scanner;
public class excitingbets {
static int gcd(int n1, int n2) {
if (n2 == 0) {
return n1;
}
return gcd(n2, n1 % n2);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 |
// Written by xiongjx751 in 2021/7/7
import java.io.*;
import java.util.Scanner;
public class Main {
private static final boolean MULTI_CASE = true;
private static int __T__;
// private static InputReader in;
private static PrintWriter out;
private static Scanner sc = new Scanner(System.in);
... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #!/usr/bin/env python3
# from typing import *
import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq
def input():
return sys.stdin.readline()[:-1]
# sys.setrecursionlimit(1000000)
# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)
T0 ... | PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | """
// Author : snape_here - Susanta Mukherjee
"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def ii(): return int(inp... | PYTHON |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 |
//@ikung
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define f(i, k) for (int i = 0; i < k; i++)
#define F first
#define S second
#define endl "\n"
#define rep(i, n) for (int i = 1; i <= n; i++)
#define rew(... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | from __future__ import division,print_function
from heapq import*
import sys
le = sys.__stdin__.read().split("\n")[::-1]
af=[]
for zorg in range(int(le.pop())):
a,b= list(map(int,le.pop().split()))
if a==b:
af.append("0 0")
else:
d=max(a,b)-min(a,b)
af.append(str(d)+" "+str(min(a%d,(... | PYTHON |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define DBG(x) \
(void)(cout << "L" << __LINE__ \
... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | n = int(input())
for i in range(n):
a, b = map(int, input().split())
if a < b:
a, b = b, a
ans = a - b
if ans == 0:
print(0, 0)
continue
# if b > ans:
ans2 = min(ans - b % ans, b % ans)
# else:
# ans2 = ans - b
print(ans, ans2)
| PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.io.*;
import java.util.*;
public class Codeforces {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cases = Integer.parseInt(br.readLine());
while(cases-- > 0) {
String[] str = br.readLine().split(" ");
... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include<bits/stdc++.h>
#define ll long long
#define str string
#define ch char
#define sz 200005
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll a,b,x;
cin>>a>>b;
if(a==b)
{
cout<<0<<' '<<0<<endl;
}
else
... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.io.*;
import java.util.*;
public class A {
static void swap(long a, long b) {
long t = a;
a = b;
b = t;
}
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
if (System.getProperty("ONLINE_JUDGE") == null) {
try {
System.setOut(new PrintS... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sum(a) (accumulate((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_element((a).begin(), (a).end()))
#define maxe(a) (*max_element((a).begin(), (a).end()))
#define mini(a) (min_element((a).... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.util.*;
import java.io.*;
public class hello{
public static void main(String [] args){
Scanner input = new Scanner(System.in);
int t = input.nextInt();
while(t-->0){
long a = input.nextLong();
long b = input.nextLong();
if(a==b ){
... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | t=int(input())
for i in range(t):
a,b=map(int,input().split())
if a==b:
e=0
m=0
print(e,m,sep=" ")
else:
e=abs(a-b)
if a%e>=e/2:
m=abs(e-a%e)
elif a%e<e/2:
m=abs(a%e)
m=min(m,b)
print(e,m,sep=" ") | PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
public class A implements Runnable {
public static void main(String[] args) throws Exception {
new Th... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import math
def main():
t=int(input())
while(t>0):
t-=1
a,b=map(int, input().split())
dif=abs(a-b)
if a==b:
print("0 0")
continue
i=0
aux=max(a, b)/dif
sig=(int(aux)+1)*dif if aux-int(aux)>0.5 else int(aux)*dif
print(f'{dif... | PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
int32_t mod = 1e9 + 7;
void solveCase()
{
int a = 0, b = 0;
cin >> a >> b;
int mx = abs(a - b);
if (mx == 0)
{
cout << "0 0\n";
return;
}
int moves = (a % mx ? min(a % mx, mx - a %... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import math
for i in range(int(input())):
f,g=map(int,input().split())
a=max(f,g)
b=min(f,g)
if math.gcd(a,b)==abs(a-b):
print(abs(a-b),0)
continue
if a==b:
print(0,0)
continue
if b==0:
print(a-b,0)
continue
... | PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include<iostream>
using namespace std;
#include<bits/stdc++.h>
#include<string.h>
#include <iomanip>
#include <ctype.h>
#define ll long long int
#define test cout<<"Nevil\n";
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.14159265359
#define precise(x) fixed << setprecision(x)
ll md=1e9+7;
... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define setval(arr,v) memset(arr,v,sizeof(arr));
#define int long long int
#define mod 1000000007
#define v vector
#define umap unordered_map
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define fi first
#define se second
#define INF 1000... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 |
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0)
{
long a=sc.nextLong();
long b=sc.nextLong();
if(a==b)
{
Sy... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int t;
int main() {
cin >> t;
while(t--) {
ll a,b;
cin >> a >> b;
if(a==b) {
cout << "0 0" << endl;
continue;
}
ll num=abs(a-b);
cout << num << " " << mi... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.util.*;
public class exitement
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
long t,a,b;
t=sc.nextLong();
while(t-->0)
{
a=sc.nextLong();
b=sc.nextLong();
if(a==b)
{
System.out.println(0+" "+0);
}
else
{
System.ou... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 |
import java.util.*;
import java.io.*;
import javafx.util.Pair;
public class One {
static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder out = new StringBuilder();
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
static ... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 |
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
public class ExcitingBets {
private static String solve(long a, long b) {
long gcd = Math.abs((a - b));
if (gcd == 0)
return "0 0";
long d=a/gcd;
long lb= d*gcd;
long ub... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include<bits/stdc++.h>
using namespace std;
///typedef
typedef long long ll;
typedef pair<int, int> pii;
///define constant
const ll mxn = 200005;
const int mod = 1000000007;//1e9+7;
///faster io
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
///debug
#define watch(x) cout << __LINE__ << "... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
#define read(x) freopen(x, "r", stdin);
#define write(x) freopen(x, "w", stdout);
#define ll long long
#define lli long long int
#define FOR(n) for(int i=0; i<(int)(n); ++i)
#define mod 1073741824
#define MAX 100001
#define gcd(a, b) __gcd(a, b)
int m... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.util.*;
import java.io.*;
public class AiseHi {
static Scanner sc = new Scanner(System.in);
static int mod = (int)(1e9+7);
static int n;
public static void main (String[] args) {
int t = 1;
t = sc.nextInt();
z : while(t-->0) {
long a = sc.nextLong();
long b = sc.nextLong();
if(... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | /*
author: rohit_03012002
*/
import java.util.*;
import java.io.*;
import java.math.*;
import java.io.FileWriter;
import java.io.IOException;
public class cf{
static class Pair{
int u;
int v;
Pair(int a,int b){
u=a;
v=b;
}
public boolean equa... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.util.Scanner;
public class ExcitingBets {
public static void solve(long a, long b) {
long exc = Math.abs(a-b);
if (exc == 0) {
System.out.println("0 0");
return;
}
System.out.println(exc + " " + Math.min((a % exc), (exc - (a % exc))));
}
public static void main(String[] args) {
... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | t = int(input())
for i in range(t):
[a,b] = input().split()
a=int(a)
b=int(b)
c=max(a,b)
d=min(a,b)
if(c==d):
print("0 0")
else:
temp1 = c-d
temp2 = min(c%(c-d),(c-d)-(c%(c-d)))
print(f"{temp1} {temp2}")
| PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long a,b;
cin>>a>>b;
if (a==b)
cout<<0<<" "<<0<<endl;
else
{
long long d= abs(a-b);
long long s= 0;
if( a==0 || b==0)
... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | import java.io.*;
import java.util.*;
public class excitingBets {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
public FastReader(Strin... | JAVA |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | # import sys
# sys.stdout = open('ot.txt', 'w')
# sys.stdin = open('in.txt', 'r')
from math import cos, pi, ceil, pi,tan, floor, gcd, sqrt, log2, factorial, log10
from collections import Counter
from copy import deepcopy
from string import ascii_lowercase,ascii_uppercase
alpha = ascii_lowercase
beta=ascii_uppercase
for... | PYTHON3 |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | #include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin>>T;
while(T--)
{
long long a,b;
cin>>a>>b;
if(a==b)
cout<<0<<" "<<0<<"\n";
else
{
long long g = abs(a-b);
long long d = min(a%g,g-a%g);
cout<<g<<" "<<d<<"\n";
}
... | CPP |
1543_A. Exciting Bets | Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]... | 2 | 7 | t=int(input())
while(t):
a,b=input().split()
a=int(a)
b=int(b)
if(a==b):
print(0,0)
elif(a<b):
a,b=b,a
c=a-b
print(a-b)
print(min(c-a%c,a%c))
print('\n')
else:
c=a-b
print(a-b)
print(min(c-a%c,a%c))
... | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.