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 |
|---|---|---|---|---|---|
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <bitset>
using namespace std;
int main() {
unsigned int a, b;
cin >> a >> b;
cout << bitset<32>(a&b) << endl;
cout << bitset<32>(a|b) << endl;
cout << bitset<32>(a^b) << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}
// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';
/*
string s = "abcdefg"
s.sub... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
string to_bin_string(ll n){
stringstream ss;
ss << bitset<32>(n);
string s = ss.str();
return s;
}
int ma... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using names... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | import java.util.*;
import java.io.*;
public class Main {
static StringBuilder sb;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
sb = new StringBuilder();
long a = sc.nextLong();
long b = sc.nextLong();
sb.append(to32BitBinaryString(a &... | JAVA |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bitset>
#include <iostream>
int main(int argc, char *argv[]) {
long a, b;
std::cin >> a >> b;
std::bitset<32> abs(a), bbs(b);
std::cout << (abs & bbs) << std::endl
<< (abs | bbs) << std::endl
<< (abs ^ bbs) << std::endl;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
long long mod = 1000000007;
long long div(long long a, long long b, long long c){
return b / c - (a - 1) / c;
}
void print_binary(long long a) {
for (int i... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a, b;
cin >> a >> b;
bitset <32> bita(a), bitb(b);
cout << (bita & bitb) << endl;
cout << (bita | bitb) << endl;
cout << (bita ^ bitb) << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | a,b=map(int,input().split())
print(format(a&b,'032b'))
print(format(a|b,'032b'))
print(format(a^b,'032b'))
| PYTHON3 |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> us... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
long long x, k;
bool y[32], m[32], a[32];
int main() {
cin >> x >> k;
for (int i=0; i<32; i++) {
y[31-i] = x%2;
x/=2;
}
for (int i=0; i<32; i++) {
m[31-i] = k%2;
k/=2;
}
for (int i=0; i<32; i++) a[i] = y[i] & m[i];
... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
signed main(){
bitset<32> a(in()),b(in());
cout<< (a&b) <<endl;
cout<< (a|b) <<endl;
cout<< (a^b) <<endl;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
long a, b;
cin >> a >> b;
bitset<32> x(a), y(b);
cout << (x & y) << "\n";
cout << (x | y) << "\n";
cout << (x ^ y) << "\n";
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<iostream>
#include<bitset>
using namespace std;
int main()
{
long long int n, m;
cin >> m >> n;
typedef bitset<32> bbl;
bbl a(m), b(n);
cout << (a&b) << endl;
cout << (a | b) << endl;
cout << (a^b) << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <bitset>
using namespace std;
int main()
{
long a, b;
cin >> a >> b;
cout << std::bitset<32>(a & b) << endl;
cout << std::bitset<32>(a | b) << endl;
cout << std::bitset<32>(a ^ b) << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int long a,b;
cin >> a >> b;
auto x = bitset<32>(a);
auto y = bitset<32>(b);
cout << (x&y) << endl;
cout << (x|y) << endl;
cout << (x^y) << endl;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | a,b=map(int,input().split())
print(f'{a&b:032b}\n{a|b:032b}\n{a^b:032b}')
| PYTHON3 |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <bitset>
using namespace std;
int main()
{
unsigned int x, y;
cin >> x >> y;
bitset<32> a(x), b(y);
cout << (a & b) << endl;
cout << (a | b) << endl;
cout << (a ^ b... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
long long x,y;cin>>x>>y;
bitset<32> a(x),b(y);
cout<<(a & b)<<endl;
... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | def out(n):
mask = 2**32 -1
print(format(n&mask,"032b"))
a,b = map(int,input().split())
out(a&b)
out(a|b)
out(a^b)
| PYTHON3 |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
#define MAX 100005
#define INF 1001001001
int main(int, char**)
{
ull x, y; cin >> x >> y;
bitset<32> a(x), b(y);
cout << (a&b) << endl;
cout <... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
signed main() {
int n, m;
cin >> n >> m;
bitset<32>bita(n), bitb(m);
cout << (bita & bitb) << endl;
cout << (bita | bitb) << endl;
cout << (bita ^ bitb) << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define RE... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
int a, b, p; string s;
cin >> a >> b;
p = a & b;
for (int i = 0; i < 32; i++) {
s = (p % 2 ? '1' : '0') + s;
p /= 2;
}
cout << s << endl; s.clear();
p = a | b;
for (int i =... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include "bits/stdc++.h"
using namespace std;
//------------------------------- Libraries --------------------------------//
//------------------------------- Type Names -------------------------------//
using i64 = int_fast64_t;
using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kiz... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
unsigned int a, b;
cin >> a >> b;
bitset<32> bsta(a), bstb(b);
cout << (bsta & bstb) << endl;
cout << (bsta | bstb) << endl;
cout << (bsta ^ bstb) << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<iostream>
#include<bitset>
using namespace std;
int main() {
long long p, q;
cin >> p >> q;
bitset<32> a(p), b(q);
cout << (a&b) << endl;
cout << (a|b) << endl;
cout << (a^b) << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <bitset>
using namespace std;
typedef bitset<32> b8;
int main(){
unsigned int n,m;
cin>>n>>m;
b8 b(n),c(m);
cout<<(b&c)<<endl;
cout<<(b|c)<<endl;
cout<<(b^c)<<endl;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<iostream>
using namespace std;
void print( int* a );
void AND( int* a, int* b );
void OR( int* a, int* b );
void XOR( int* a, int* b );
int main()
{
long long x, y; //整数の範囲を間違えない
int bitx[32], bity[32];
for( int i = 0; i < 32; i++ )
{
bitx[i] = 0;
bity[i] =... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
long x=in.nextLong(),y=in.nextLong();
printBin(fillZero(Long.toBinaryString(x & y)));
printBin(fillZero(Long.toBinaryString(x | y)));
printBin(fillZero(Long.toBinaryString(x ^ y)));
}
s... | JAVA |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;
void coutbits(unsigned n) {
for (int i = 31; i >= 0; i--) {
cout << (((n >> i) & 1) ? 1 : 0);
}
}
void solve() {
unsigned a, b; cin >> a >> b;
coutb... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
long long hoge,hoge2;
cin>>hoge>>hoge2;
bitset<32> a(hoge),b(hoge2);
cout<<(a&b)<<endl<<(a|b)<<endl<<(a^b)<<endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <bitset>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
unsigned int n[5];
cin >> n[0] >> n[1];
// AND
n[2] = n[0] & n[1];
// OR
n[3] = n[0] | n[1];
// XOR
n[4] = n[0] ^ n[1];
for(int i = 2;i < 5;++i){
... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | import java.util.*;
import java.io.*;
public class Main {
void solve (FastScanner in, PrintWriter out, Methods ms) {
long a = in.nextLong(), b = in.nextLong();
long[] ar = new long[3];
ar[0] = a & b;
ar[1] = a | b;
ar[2] = a ^ b;
for (int i=0; i<3; i++) {
... | JAVA |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | // file name: 逻辑操作2: 两个数按位与,或,非
// Written by: by_sknight
// Date: 2019/6/13
#include <bits/stdc++.h>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(0);
unsigned int a, b; cin >> a >> b;
bitset<32> bs_a(a), bs_b(b), bs;
bs = bs_a & bs_b;
cout << bs << endl;
bs = bs_a | bs_b;
cout ... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) co... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#in... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<iostream>
#include<bitset>
using namespace std;
int main(){
unsigned int a, b;
cin >> a >> b;
bitset<32> x(a), y(b);
cout << (x&y) << endl << (x|y) << endl << (x^y) << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#in... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | x, y = map(int, input().split())
bin_x = format(x & y, '032b')
bin_x1 = format(x | y, '032b')
bin_x2 = format(x ^ y, '032b')
print(bin_x)
print(bin_x1)
print(bin_x2)
| PYTHON3 |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)
template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
unsigned int a, b;
cin >> a >> b;
bitset<32> A = a, B = b;
cout << (A & B) << endl;
cout << (A | B) << endl;
cout << (A ^ B) << endl;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)
using Pi = pair<int, int>;
using Tapris = tuple<int, int,... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | import java.util.Scanner;
public class Main {
static Scanner scan = new Scanner(System.in);
//0埋め
static String zeroLine(String a) {
String zero = "";
if(a.length() < 32) {
for(int i=0; i<32-a.length(); i++) {
zero += "0";
}
}
return zero + a;
}
//文字列の出力
static void printStr(String a) {
... | JAVA |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecll = vector<long long>;
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int main()
{
ll a, b;
cin >> a >> b;
cout << bitset<32>(a & b) << endl;
cout << bitset<32>(a | b) ... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bitset>
#include <iostream>
using namespace std;
int main(){
bitset<32> a,b;
long long int n;
cin>>n;
a=n;
cin>>n;
b=n;
cout<<(a&b)<<endl<<(a|b)<<endl<<(a^b)<<endl;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, ... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include "bits/stdc++.h"
using namespace std;
#define long int64_t
struct Solver {
void solve() {
uint32_t a, b;
cin >> a >> b;
bitset<32> bt( a ), bt2( b );
cout << (bt & bt2) << '\n'
<< (bt | bt2) << '\n'
<< (bt ^ bt2) << endl;
}
};
int main() {
ios::sync_with_stdio( false );
cout << fixed << set... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | import java.util.*;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long b = sc.nextLong();
System.out.println(toString(a & b));
System.out.println(toString(a | b));
System.out.println(toString(a ^ b));
}
static String toString... | JAVA |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bitset>
#include <iostream>
using namespace std;
int main() {
long a, b;
cin >> a >> b;
bitset<32> c = a, d = b;
cout << (c & d) << endl << (c | d) << endl << (c ^ d) << endl;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitse... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <stack>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
void printarray(int n, int a[])
{
for (int i = 0; i < n; i++)
{
cout << a[i];
/*if (i != n - 1)
cout << " ";*/
... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #!/usr/bin/env python3
# Bitset 1 - Bit Operation 2
def run():
a, b = [int(i) for i in input().split()]
fmt = "{:032b}"
mask = ~(1 << 32)
print(fmt.format((a & b) & mask))
print(fmt.format((a | b) & mask))
print(fmt.format((a ^ b) & mask))
if __name__ == '__main__':
run()
| PYTHON3 |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
void outPut(int value){
stack<int> S;
for(int loop = 0; loop < 32; loop++){
if(value & (1 << lo... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | a, b = map(int, input().split())
print('{:032b}'.format(a & b))
print('{:032b}'.format(a | b))
print('{:032b}'.format(a ^ b))
| PYTHON3 |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | #include <iostream>
#include <bitset>
using namespace std;
int main(){
unsigned int a,b;
cin >> a;
cin >> b;
bitset<32> a1(a),a2(a),a3(a),b1(b);
a1 &= b1;
a2 |= b1;
a3 ^= b1;
cout << a1 << endl;
cout << a2 << endl;
cout << a3 << endl;
return 0;
}
| CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | //#define NDEBUG
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <random>
#ifdef _MSC_VER
#include <ppl.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/ration... | CPP |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | import java.util.*;
class Main{
static final int nbits = 32;
static BitSet bs;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long b = sc.nextLong();
BitSet bsa = new BitSet(nbits);
BitSet bsb = new BitSet(nbits);
for(int i = 0; i < nbits; i++){
i... | JAVA |
p02424 Bit Operation II | Given two non-negative decimal integers $a$ and $b$, calculate their AND (logical conjunction), OR (logical disjunction) and XOR (exclusive disjunction) and print them in binary representation of 32 bits.
Constraints
* $0 \leq a, b \leq 2^{32} - 1$
Input
The input is given in the following format.
$a \; b$
Outp... | 7 | 0 | a, b = map(int, input().split())
print("{:032b}".format(a & b))
print("{:032b}".format(a | b))
print("{:032b}".format(a ^ b))
| PYTHON3 |
aba14a | Ramkumar loves to solve riddles one day SpojSathyagave him a riddle to solve.
Sathya will give him pair of integers a and b. Ramkumar has to find the largest
number in the range [a,b] inclusive which can be represented as product of atleast two prime numbers. But ramkumar is busy in watching "Arrow" he is asking your ... | 1 | 6 | def isprime(n):
if n == 2 or n == 3: return 0
if n < 2 or n%2 == 0: return 1
if n < 9: return 0
if n%3 == 0: return 1
r = int(n**0.5)
f = 5
while f <= r:
if n%f == 0: return 1
if n%(f+2) == 0: return 1
f +=6
return 0
def main():
t=raw_input()
for j in xrange(int(t)):
b,c... | PYTHON |
chefbro | Chef's younger brother is in town. He's a big football fan and has a very important match to watch tonight. But the Chef wants to watch the season finale of MasterChef which will be aired at the same time. Now they don't want to fight over it like they used to when they were little kids. They want to decide it in a fai... | 1 | 2 | for t in xrange(int(raw_input())):
x=0
for c in xrange(int(raw_input())):
n,m=map(int,raw_input().split())
g=(m+n-2)%3
x=x^g
if x:
print "MasterChef"
else:
print "Football" | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | # code chef - easy - digit rotation
def left(s):
return str(int(s[-1]+s[:-1]))
def right(s):
return str(int(s[1:]+s[0]))
nCases = int(raw_input())
for iter in range(nCases):
number = raw_input()
if len(number)==1:
print number
continue
best = max(int(left(right(number))), int(... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def left_rotate(s):
s = s[-1]+s[:-1]
s = s.lstrip('0')
return s
def right_rotate(s):
s = s[1:]+s[0]
s = s.lstrip('0')
return s
t = int(raw_input())
while t :
t=t-1
n = raw_input()
ans = max(int(left_rotate(right_rotate(n))),int(right_rotate(left_rotate(n))))
temp = n[:]
f... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | from sys import stdin
from math import log10 as log
def leftrotate(N):
p=int(log(N))
return (N%(10**p))*10+(N/10**p)
def rightrotate(N):
p=int(log(N))
return 10**p*(N%10) + N/10
for trial in xrange(int(stdin.readline())):
N = int(stdin.readline())
lenN=int(log(N))
best = max(leftrotate(ri... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def l(s):
s = s[-1]+s[:-1]
s = s.lstrip('0')
return s
def r(s):
s = s[1:]+s[0]
s = s.lstrip('0')
return s
t = int(raw_input())
while t :
t=t-1
n = raw_input()
ans = max(int(l(r(n))),int(r(l(n))))
temp = n[:]
for i in range(len(n)) :
temp = l(temp)
ans = ma... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def left(inp):
inp=inp[1:]+inp[0]
return int(inp)
def right(inp):
inp=inp[-1]+inp[:-1]
return int(inp)
t=int(raw_input().strip())
while t:
t-=1
max=0
num=raw_input().strip()
leng=len(num)
if(leng==1):
max=int(num)
elif (leng==2):
max=left(num)
temp=left(... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | from sys import stdin
from math import log10 as log
def leftrotate(N):
s = str(N)
return int(s[1:] + s[0])
def rightrotate(N):
s = str(N)
return int(s[-1] + s[:-1])
for trial in xrange(int(stdin.readline())):
N = int(stdin.readline())
lenN = int(log(N))
best = max(leftrotate(rightrotate(N... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def left(s):
s = s[-1]+s[:-1]
s = s.lstrip('0')
return s
def right(s):
s = s[1:]+s[0]
s = s.lstrip('0')
return s
num = int(raw_input())
while num:
n = raw_input()
maximum = max(int(left(right(n))),int(right(left(n))))
tmp = n
for j in range(len(n)):
tmp = left(tmp)
maximum = max(int(tmp),maximum)
tm... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def left(n):
n=n[-1]+n[:-1]
n=n.lstrip('0')
return n
def right(n):
n=n[1:]+n[0]
n=n.lstrip('0')
return n
ch=input()
while ch:
s=raw_input()
ans=max(int(left(right(s))),int(right(left(s))))
temp=s
for i in range(len(s)):
temp=left(temp)
ans=max(ans,int(temp))
temp=s
for i in range(len(s)):
temp=righ... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def LR(N) :
max = -1
num = str(N)
if len(num) == 1 :
return N
else :
for i in range(len(num)) :
num = num[1:] + num[0]
if max < int(num) :
max = int(num)
num = str(int(num))
return max
def RR(N) :
max = -1
num = str(N)
if len(num) == 1 :
return max
else :
... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def rs(x):
p=x[0]
for i in range(len(x)-1):
x[i]=x[i+1]
x[len(x)-1]=p
return(x)
def ls(x):
p=x[-1]
for i in range(len(x)-1,0,-1):
x[i]=x[i-1]
x[0]=p
return(x)
def number(x):
num=0
for i in range(len(x)):
num+=x[len(x)-1-i]*10**i
return(num)
def ld(n)... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def no_of_digits(n):
digits=0
while n>0:
n/=10
digits+=1
return digits
def right_rot(n):
if(n>9):
res=n%10
tmp=str(n/10)
for x in tmp:
res=res*10+int(x)
return res
else:
return n
def left_rot(n):
if(n>9):
tmpstr=str(n)
... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | from sys import stdin
from math import log10 as log
def leftrotate(N):
p=int(log(N))
return (N%(10**p))*10+(N/10**p)
def rightrotate(N):
p=int(log(N))
return 10**p*(N%10) + N/10
for trial in xrange(int(stdin.readline())):
N = int(stdin.readline())
lenN=int(log(N))
best = max(leftrotate(ri... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def left(s):
s = s[-1]+s[:-1]
s = s.lstrip('0')
return s
def right(s):
s = s[1:]+s[0]
s = s.lstrip('0')
return s
ntc = int(raw_input())
while ntc :
n = raw_input()
maxVal = max(int(left(right(n))),int(right(left(n))))
tmp = n[:]
for i in range(len(n)) :
tmp = left(tmp)
maxVal = max(maxVal,int(tmp))
tm... | PYTHON |
digrot | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 1 | 6 | def left_rotation(str):
length = len(str)
str1=""
for i in range (1,length):
str1 += str[i]
str1 += str[0]
return str1.lstrip('0')
def right_rotation(str):
length = len(str)
str1=str[length-1]
for i in range (length-1):
str1 += str[i]
return str1.lstrip('0')
def left_right(str):
str1= left_rotation(str)
... | PYTHON |
insoma5 | The planet of XANDOR was famous in the intergalactic empire for being home to the Carden - a race of super-intelligent computer scientists that were held in high regard for their achievements in the Intergalactic Mind Game Olympiads. The Carden decided to build a huge computer to answer questions related to Life, the U... | 1 | 6 | #!/usr/bin/python
s=raw_input()
dp = [ [ 0 for j in xrange(20)] for i in xrange(20) ]
op = [ '_' for i in xrange(20) ]
n = len(s)
m = 0
f = [0, 1]
for i in xrange(2,20):
f.append(0)
for j in xrange(1,i):
f[i] += f[j] * f[i-j]
for i in xrange(n):
if i%2 == 0 and s[i] == 'T':
dp[i/2][1] = 1
... | PYTHON |
nf03 | Given a string of letters in the input, return a string in the output with each words written in reverse order. Spaces and punctuations must not change their position. Numbers may be present in a string. The end of the string will have a "." without the quotes.
Input
Input string
Output
Output String
Example
Inp... | 1 | 6 | ans=[]
while True:
try:
s=raw_input()
l=[]
l=s.split()
for i in l:
i=i[::-1]
ans.append(i)
except EOFError:
break
for i in ans:
if i[0]==".":
i=i.replace(".","")
print i+".",
else:
print i, | PYTHON |
nf03 | Given a string of letters in the input, return a string in the output with each words written in reverse order. Spaces and punctuations must not change their position. Numbers may be present in a string. The end of the string will have a "." without the quotes.
Input
Input string
Output
Output String
Example
Inp... | 1 | 6 | st = str(raw_input())[:-1]
L = st.split()
for x in range(0,len(L)-1):
print reduce(lambda x,y: x+y, [(L[x])[i] for i in range(len(L[x])-1,-1,-1)]),
print reduce(lambda x,y: x+y, [(L[len(L)-1])[i] for i in range(len(L[len(L)-1])-1,-1,-1)])+"." | PYTHON |
nf03 | Given a string of letters in the input, return a string in the output with each words written in reverse order. Spaces and punctuations must not change their position. Numbers may be present in a string. The end of the string will have a "." without the quotes.
Input
Input string
Output
Output String
Example
Inp... | 1 | 6 | #!/usr/bin/env python
ALPHA = ''.join(map(lambda x: chr(65 + x), range(26)))
ALPHA += ALPHA.lower()
ALPHA += ''.join(map(str, range(10)))
def main():
while True:
try:
S = raw_input()
except:
break
W = ''
R = ''
for c in S:
if c in ALPHA... | PYTHON |
nf03 | Given a string of letters in the input, return a string in the output with each words written in reverse order. Spaces and punctuations must not change their position. Numbers may be present in a string. The end of the string will have a "." without the quotes.
Input
Input string
Output
Output String
Example
Inp... | 1 | 6 | def rev(St):
return St[::-1]
s=raw_input()
words=map(rev,s.split(" "))
c=words[-1]
words.pop()
c=c.replace(".","")
words.append(c+".")
print " ".join(words) | PYTHON |
nf03 | Given a string of letters in the input, return a string in the output with each words written in reverse order. Spaces and punctuations must not change their position. Numbers may be present in a string. The end of the string will have a "." without the quotes.
Input
Input string
Output
Output String
Example
Inp... | 1 | 6 | s=raw_input().split()
a=s[:len(s)-1]
for i in a:
print i[::-1],
x=s[-1]
x=x.replace('.','')
x=x[::-1]+'.'
print x | PYTHON |
nf03 | Given a string of letters in the input, return a string in the output with each words written in reverse order. Spaces and punctuations must not change their position. Numbers may be present in a string. The end of the string will have a "." without the quotes.
Input
Input string
Output
Output String
Example
Inp... | 1 | 6 | x=raw_input()
a=[]
a=x.split()
s=""
for i in a:
i=i[::-1]
if i[0]==".":
i=i.replace(".","")
s=s+i+"."+" "
else:
s=s+i+" "
print s | PYTHON |
sanskar | Alok-nath is man of equality. He needs your help to divide his “sanskars” evenly amongst all his followers. By doing this, Alok-nath can create equality amongst his followers and he'll be called a true “sanskari”.
Alok-nath has N sanskars, and K followers. Each sanskar is given a numerical value which shows its intensi... | 1 | 2 | def possible(A, e, n):
def rec(i, r):
if r == 0:
return True
if i == n:
return False
if A[i] > 0 and r >= A[i]:
p = rec(i + 1, r - A[i])
if p:
A[i] = 0
return True
p = rec(i + 1, r)
if p:
... | PYTHON |
sanskar | Alok-nath is man of equality. He needs your help to divide his “sanskars” evenly amongst all his followers. By doing this, Alok-nath can create equality amongst his followers and he'll be called a true “sanskari”.
Alok-nath has N sanskars, and K followers. Each sanskar is given a numerical value which shows its intensi... | 1 | 2 | import sys
x = lambda : [int(n) for n in sys.stdin.readline().rstrip().split()]
t = int(sys.stdin.readline().rstrip())
def f(a, n, s):
if s==0:
return 1
if n==0 and s != 0:
return 0
if a[n-1] > s or a[n-1] == 0:
return f(a, n-1, s)
if f(a, n-1, s - a[n-1]):
a[n-1] = 0
... | PYTHON |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author dipankar12
*/
import java.io.*;
import java.util.*;
public class r46b {
public static void main(String args[])
... | JAVA |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 |
import java.util.Scanner;
public class Lamp {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
int n=in.nextInt();int m=in.nextInt();
int[]a=new int[n+2];
a[n+1]=m;
for(int i=1;i<n+1;i++)
a[i]=in.nextInt();
int seg=0;int max=0;int t=... | JAVA |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | n,M=map(int,input().split())
s=[int(x) for x in input().split()]
ss=[s[0]]
so=[]
se=[]
for i in range(n-1):
ss.append(s[i+1]-s[i])
ss.append(M-s[n-1])
if (n+1)%2==1:
for i in range(int(n/2)):
so.append(ss[2*i])
se.append(ss[2*i+1])
so.append(ss[n])
sss=sum(so)
a=0
b=sum(se)
... | PYTHON3 |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long int n, m;
cin >> n >> m;
long long int i, j = 0, k = 0, a[n], d = 1, t = -1;
bool f =... | CPP |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | n, M = [int(x) for x in input().split()]
line = [0] + [int(x) for x in input().split()] + [M]
def get_line(line):
l = []
for i in range(len(line)-1):
l.append(line[i+1]-line[i])
return l
def get_time(line):
s = 1
ans = 0
for i in line:
if s == 1:
ans += i
s *= -1
return ans
run = True
l = get_line(li... | PYTHON3 |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | n,m=map(int,input().split(" "))
ope=[0]*n
s=input().split(" ")
for i in range(n):
ope[i]=int(s[i])
ope.append(m)
on=[ope[0]]
off=[]
i=0
light=False
while i<n:
if light:
on.append(ope[i+1]-ope[i])
else:
off.append(ope[i+1]-ope[i])
i+=1
light=not light
a,b=len(on)-1,len(off)-1
onsum=0
... | PYTHON3 |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, M;
cin >> n >> M;
int prev = 0;
vector<pair<int, bool>> all;
all.push_back({0, true});
bool lit = false;
int time{0};
vector<int> times;
times.push_back(0);
for (int i = 0; i <= n; i++) {
if (i != n) {
int t;
cin >> t;... | CPP |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long ans;
long long p[N], q[N], a[N];
void solve() {
long long n, m;
cin >> n >> m;
a[0] = 0;
a[n + 1] = m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n + 1; i++) {
p[i] = p[i - 1];
if (i % 2) p[i] += (a[i] ... | CPP |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int n, m, x, sol, r, s;
int c[MAXN];
vector<int> p;
int main() {
cin >> n >> m;
p.push_back(0);
for (int i = 0; i < n; i++) {
cin >> x;
p.push_back(x);
}
p.push_back(m);
c[0] = 0;
for (int i = 1; i < p.size(); i++) {
if (i ... | CPP |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | JAVA |
1000_B. Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunately, ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int maxi = 211111;
map<long long, int> mp, hoise;
long long a[maxi];
int n, m;
long long odds = 0, evens = 0;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
a[0] = 0;
a[n +... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.