description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... |
n,q=map(int,input().split())
st=input()
sum_st=[0]
add=0
for i in st:
if i=='1':
add+=1
sum_st.append(add)
count=0
M=10**9+7
ans=[]
for i in range(q):
l,r=map(int,input().split())
x=sum_st[r]-sum_st[l-1]
y=r-l-x+1
rs=(pow(2,x,M)-1)%M
ss=(rs*pow(2,y,M))%M
ans.append(ss)
for i in ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | from sys import *
ans = []
n , q = map(int,stdin.readline().split())
s = stdin.readline()
MOD = 1000000007
t = [0 for i in range(n+1)]
t[0] = 0
for i in range(1,n+1):
t[i] = t[i-1]+1 if s[i-1]=="1" else t[i-1]
# print(t)
for i in range(q):
l , r = map(int,stdin.readline().split())
_sum = r-l+1
zero = _s... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... |
/**
* Date: 14 Nov, 2018
* Link:
*
* @author Prasad-Chaudhari
* @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
* @git: https://github.com/Prasad-Chaudhari
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.io.*;
import java.math.*;
public class Main2
{
static class Reader
{
private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
public int read() {if (n... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CodeforcesFun {
public static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, -1, 1};
long long sub(long long a, long long b, long long p = 1000000007) {
return ((a % p) - (b % p) + p) % p;
}
long long mult(long long a, long long b, long long p = 1000000007) {
return ((a % p) * (b % p)) % p;... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | from sys import stdin
from collections import deque
mod = 10**9 + 7
import sys
sys.setrecursionlimit(10**5)
from queue import PriorityQueue
# def rl():
# return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math imp... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long N, Q, S[(int)1e5 + 5], i, L, R, p1, p2;
long long Putere(long long p1, long long ex) {
long long i, sol = 1;
for (i = 0; (1 << i) <= ex; i++) {
if (((1 << i) & ex) > 0) sol = (sol * p1) % 1000000007;
p1 = (p1 * p1) % 1000000007;
}
return sol;
}
str... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
import io, os
input = sys.stdin.readline
def main():
n, q = map(int, input().split())
A = str(input().rstrip())
A = [int(a) for a in A]
from itertools import accumulate
C = [0]+A
C = list(accumulate(C))
N = 10**5+50
mod = 10**9+7
table = [0]*N
table[0] = 1
for i ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | M=1000000007
R=lambda:map(int,raw_input().split())
n,q=R()
a=[0]+map(int,raw_input())
for i in range(n):
a[i+1]+=a[i]
v=[]
for _ in range(q):
l,r=R()
o=a[r]-a[l-1]
z=r-l+1-o
x=pow(2,o+z,M)-pow(2,z,M)
v+=x+M*(x<0),
print '\n'.join(map(str,v))
|
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C {
static int mod = (int)1e9 + 7;
public static void main(String[] args) {
MyScanner sc = new MyScanner();
PrintWriter pw = n... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
void no() { cout << "NO\n"; }
void yes() { cout << "YES\n"; }
long long int pow_(long long int a, long long int n) {
if (n == 0) return 1;
if (n == 1) return a;
if (n % 2 == 0)
return ((pow_(a, n / 2) % 1000000007) * (pow_(a, n / 2) % 1000000007)) %
100... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
char a[100001];
int len[100001];
long long quick_pow(long long a, int b) {
long long ans = 1;
while (b) {
if (b & 1) ans = (ans * a) % 1000000007;
a = (a * a) % 1000000007;
b >>= 1;
}
return ans;
}
int main() {
int n, q;
while (scanf("%d%d", &n, &q) ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> &a, pair<long long, long long> &b) {
if (a.first == b.first) return (a.second < b.second);
return a.first < b.first;
}
long long nCr(long long n, long long r) {
long long res = 1;
for (int i = n; i > max(r, n - r); i--) res *= i, ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.*;
import java.util.*;
public class Main {
static long[] degs;
public static void main(String[] args) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
String[] line = reader.readLine().split(" ");
int n = Integer.parseInt(... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int A[100005][2];
char s[100005];
long long pow_mod(long long x, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
int main() {
int n, q;
memset(A, 0, sizeof(A))... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.io.*;
public class cfc {
static final int MOD=(int)(1e9+7);
public static void main(String[] args) {
FastScanner scan=new FastScanner();
PrintWriter out=new PrintWriter(System.out);
int n=scan.nextInt(), q=scan.nextInt();
exp=new long[n+1];
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int A[100005];
char Num[100005];
long long Pow(long long a, long long b) {
long long ans = 1;
while (b) {
if (b & 1) ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans;
}
int main() {
int n, q;
scanf("%d... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.*;
import java.util.*;
public class yuy {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n=sc.nextInt();
int q=sc.nextInt();
String h=sc.nextLine();
int[] pow2 = new int[1000000];
p... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | //package que_b;
import java.io.*;
import java.util.*;
import java.math.*;
public class utkarsh {
InputStream is;
PrintWriter out;
long mod = (long) (1e9 + 7), inf = (long) (3e18);
void solve() {
int n = ni(), q = ni();
char[] s = ns(n);
int a[] = new int[n+1];
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, q, cum[N], mod = 1e9 + 7;
char a[N];
string s;
vector<long long> v;
int main() {
scanf("%d%d%s", &n, &q, &a);
s += '#';
s += a;
int p = 1;
for (int i = 0; i <= 100000; i++) {
if (i == 0)
v.push_back(p);
else
v.push_... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | //https://www.hackerearth.com/submission/5284067/
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
public static int n, m;
public static ArrayList<Integer>[] adj, idx;
public static ArrayList<Long> num[];
public static int chainNo, ptr;
public static int[]... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long me(long long a, long long b) {
if (b == 0) return 1;
if (b % 2 == 0) return me((a * a) % 1000000007, b / 2);
if (b % 2 == 1) return (a * me((a * a) % 1000000007, b / 2)) % 1000000007;
}
void solve() {
long long n, q;
cin >> n >> q;
string s;
cin >> s... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitS... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
input = sys.stdin.readline
n, q = map(int, input().split())
MOD = 10**9+7
l = list(input())
acc = [0]
for li in l:
acc.append(acc[-1]+(1 if li=='1' else 0))
for _ in range(q):
l, r = map(int, input().split())
a = acc[r]-acc[l-1]
b = r-l+1-a
print(pow(2, b, MOD)*(pow(2, a, MOD)-1)%... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #------------------------template--------------------------#
import os
import sys
# from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | n, q = map(int, input().split())
s = input()
c0 = [0]
for i in s:
c0.append(c0[-1] + (i == '0'))
M = 10 ** 9 + 7
ans = []
for i in range(q):
l, r = map(int, input().split())
z = c0[r] - c0[l - 1]
on = (r - l + 1) - z
ans.append((pow(2, on, M) - 1) * pow(2, z, M) % M)
print('\n'.join(list(map(str, an... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int bp(int x, int n) {
int res = 1;
while (n) {
if (n & 1) res = (long long)res * x % mod;
x = (long long)x * x % mod;
n >>= 1;
}
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.util.regex.*;
public class Codeforces{
static class MyScanner{
BufferedReader br;
StringTokenizer st;
MyScanner(FileReader fileReader){
br = new BufferedReader(fileReader);
}
MyScanner(){
br = new BufferedReader(new... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | /* In_The_Name_Of_Allah_The_Merciful */
import java.util.*;
import java.io.*;
public class Main
{
PrintWriter out;
FastReader sc;
long[] m1= {(long)(1e9+7),998244353};
long mod=m1[0];
long maxlong=Long.MAX_VALUE;
long minlong=Long.MIN_VALUE;
S... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
public class Main
{
public static void main(String[] args) throws Exception
{
long startTime = System.nanoTime();
int n = in.nextInt();
int q = in.nextInt();
int [] zeroes = new int [n];
int [] ones = new int [n]... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
int ones[100005], zeros[100005];
int dt[100005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q >> s;
for (int i = 0; i < n; ++i) {
if (i > 0) {
zeros[i + 1] += zeros[i];
ones[i + 1] += ones[i];
}
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
char s[maxn];
int siz[maxn];
long long sum[maxn];
int main() {
int i, j, k, n, m, q, l, r, x, y;
long long num;
scanf("%d%d", &n, &q);
sum[0] = 0;
num = 1;
for (i = 1; i <= n; i++) {
sum[i] = (sum[i - 1] + n... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int SIZEN = 100010;
const long long mod = 1000000007;
int n, q;
int a[SIZEN] = {0};
long long qpow(long long x, long long len) {
long long ret = 1;
for (; len; len >>= 1) {
if (len & 1) ret = ret * x % mod;
x = x * x % mod;
}
return ret;
}
int main() {... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.io.*;
public class algo_603
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n=Integer.parseInt(st.next... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, q;
long long mod = 1e9 + 7;
cin >> n >> q;
vector<long long> p(n + 1), dg(n + 1, 1);
for (long long i = 0; i < n; i++) dg[i + 1] = dg[i] * 2 % mod;
for (long long i = 0; i... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 6;
string s;
long long pp[N];
int pref[N];
const int mod = 1e9 + 7;
long long int fpower(long long int x, long long int y) {
long long int res = 1;
while (y > 0) {
if (y & 1) res = (res * x) % mod;
y = y >> 1;
x = (x * x) % mod;
}
ret... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.io.*;
//import javafx.util.Pair;
public class Solution implements Runnable
{
class Pair implements Comparable <Pair>
{
int x;
long y;
Pair(int x,long y)
{
this.x=x;
this.y=y;
}
public int compareTo(P... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
* Created by Katushka on 31.01.2020.
*/
public class BahnMi {
private static long fastPow2(int y) {
if (y == 0) {
return 1;
}... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... |
import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.lang.*;
public class Main {
static class sort implements Comparator<List<Integer>>
{
public int compare(List<Integer> a,List<Integer> b)
{
return (a.size() - b.size());
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.*;
public class C {
private String readLine() {
StringBuilder sb = new StringBuilder();
int b = 0;
while (b != '\n' && b >= 0) {
try {
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
long long int powers(long long int a, long long int b) {
long long int ans = 1;
a %= mod;
while (b > 0) {
if (b % 2 == 1) ans = ((ans % mod) * (a % mod)) % mod;
b /= 2;
a = ((a % mod) * (a % mod)) % mod;
}
return a... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long power(long long x, unsigned long long y) {
int res = 1;
x = x % 1000000007;
while (y > 0) {
if (y & 1) res = (res * x) % 1000000007;
y = y >> 1;
x = (x * x) % 1000000007;
}
return res;
}
int main() {
int n, q;
vector<int> one(100005, 0), ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long int max2 = 1000000007;
long long int power(long long int base, long long int exp) {
long long int ans = 1;
while (exp) {
if (exp % 2 == 1) {
ans *= base;
ans %= max2;
}
exp /= 2;
base *= base;
base %= max2;
}
return ans;
}
i... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
vector<long long> p;
int main() {
int n, q;
cin >> n >> q;
string s;
cin >> s;
p.resize(1e5 + 1);
p[0] = 1;
for (int i = 1; i <= 1e5; i++) {
p[i] = (p[i - 1] * 2) % MOD;
}
vector<long long> kum(n + 1);
kum[0] = 0;
for... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
PrintWriter out = new PrintWriter(System.out);
int MAX = (int)1e5 + 10, MOD = (int)1e9 + 7;
int sum_powers[] = new int[MAX];
int... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | n,q =map(int,input().split())
delish = list(map(int,list(input())))
mod=10**9+7
sums = [0]+delish[:]
for i in range(n):
sums[i+1]+=sums[i]
op=[]
for _ in range(q):
l,r=map(int,input().split())
a=sums[r]-sums[l-1]
b = r-l+1-a
op.append((pow(2,a+b,mod)-pow(2,b,mod))%mod)
print('\n'.join(map(str,op))) |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;
public class main {
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public Fas... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.io.Inp... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | n, q = map(int, input().split())
arr = input()
cumulative = [0]
num_ones = 0
for i in range(n):
if arr[i] == '1':
num_ones += 1
cumulative.append(num_ones)
mod = 10**9+7
res = []
for i in range(q):
a, b = map(int, input().split())
ones = cumulative[b] - cumulative[a-1]
zeros = b-a+1 - ones
res.append... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long calc(long long n) {
if (!n) return 1;
if (n == 1) return 2;
long long u = calc(n / 2);
u = ((u % ((long long)(1e9 + 7))) * (u % ((long long)(1e9 + 7)))) %
((long long)(1e9 + 7));
if (n % 2 == 1) return (2 * u) % ((long long)(1e9 + 7));
return u %... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.Scanner;
public class C {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int q = scan.nextInt();
String S = scan.next();
int[] ones = new int[n+1];
int[] zeros = new int[n+1];
int numOfOnes = 0;
int numOFZeros = 0;
for (int ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | /*
*
* @Author Ajudiya_13(Bhargav Girdharbhai Ajudiya)
* Dhirubhai Ambani Institute of Information And Communication Technology
*
*/
import java.util.*;
import java.io.*;
import java.lang.*;
public class Code62
{
public static void main(String[] args)
{
InputReader in = new InputReader(System.... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int n, q, sl1, l, r;
string s;
long long f[100009], lt[100009], a[100009], so, res, sum[100009];
int main() {
int mod = 1000000007;
cin >> n >> q;
getline(cin, s);
getline(cin, s);
for (int i = 0; i < n; i++) {
if (s[i] == '1') a[i + 1] = 1;
}
for (int i =... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
char c;
int a[101001], n, p, l, r;
const long long mod = 1e9 + 7;
long long num[101010];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> p;
num[0] = 1;
for (int i = 1; i < 100001; i++) num[i] = num[i - 1] * 2 % mod;
for (int i = ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long m0 = 0, m1 = 0;
vector<long long> v0, v1, v2;
int main() {
long long q, n, i, j, cnt = 0, l, r, one = 0, zero = 0, even = 0, odd = 0,
total = 0;
string s;
cin >> n >> q;
cin >> s;
v0.push_back(0);
v1.push_back(0);
long long p ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.regex.*;
public class Myclass{
// public static ArrayList adj[]=new ArrayList[300001];
public static void main(String[] args)
{
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.io.*;
import java.math.*;
// Solution to PCS Problem 89: Banh Mi
// https://pcs.cs.cloud.vt.edu/contests/89/problems/C
// Solution by: jLink23
public class BanhMi {
private static PrintWriter out;
public static final int MOD = 1000000007;
public static void main(String[] args) {... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
long du = 1e9 + 7;
long long muhai[100005];
int main() {
unsigned int n, q;
std::cin >> n >> q;
std::string x;
std::cin >> x;
muhai[0] = 1;
for (int i = 1; i < 100005; i++) {
muhai[i] = muhai[i - 1] * 2;
muhai[i] %= du;
}
int dem[n];
if (x[0] == '0')
dem[0] = 1;
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const long long maxN = 2e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 1;
int n, q, m, h, l, A[maxN];
int acum[maxN];
long long fastPow(long long x, long long n) {
long long ret = 1;
while (n) {
if (n & 1) ret = ret * x % MOD;
n >>= 1, x = x * x % MOD;
}
return ret;
}
i... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | from sys import stdin,stdout
n,q=map(int,stdin.readline().split())
s=stdin.readline()
mod=1000000007
powers=[1 for i in range(n+1)]
for i in range(1,n+1):
powers[i]=(powers[i-1]*2)%mod
cum=[0 for i in range(n+1)]
for i in range(n):
if s[i]=='0':
cum[i+1]=cum[i]+1
else:
cum[i+1]=cum[i]
while ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | /*
* 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.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
*
* @author arvin
*/
public class Banh_mi_food {
pub... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const double PI = acos(-1);
const double ERR = 1e-10;
long long pow_(long long a, long long b) {
long long ans = 1;
wh... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.*;
import java.util.*;
public class Main {
int [] pre;
void solve() throws IOException {
int n =readInt();
int q =readInt();
long mod = 1000_000_007;
long pow2[] = new long[1000_000];
pow2[0]=1;
for(int i =1;i<1000_000;i++){
pow2[i]=2*p... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long OO = (long long)1e9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
long long gcd(long long a, long long b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
void fast... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.math.BigInteger;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Solution {
static long m = (long)1e9+7;
static long modPow(int p){
long res = 1, a = 2;
while(p!=0){
if(p%2==1){
res = res*a;
p--;
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in Actual solution is at the top
*
* @author MaxHeap
*/
public class Main ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... |
import java.io.*;
import java.util.Map;
/**
* Copyright © 2018 Chris. All rights reserved.
*
* @author Chris
* 2018/7/9 15:33
* @see format
*/
public class C {
private static BufferedReader br;
private static StreamTokenizer st;
private static PrintWriter pw;
static final int INF = 1000000007;... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.*;
import java.util.*;
public class Main {
private final static long mod = 1000000007;
private static void printArr(char arr[][]) {
int i, j, n = arr.length, m = arr[0].length;
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
System.out.print(arr[... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
const int maxn = 100100;
const int MOD = 1e9 + 7;
char s[maxn];
int c[maxn], f[maxn];
int main() {
int n, q;
scanf("%d%d", &n, &q);
scanf("%s", s + 1);
f[0] = 1;
for (int i = 1; i <= n; i++) {
c[i] = c[i - 1] + (s[i] == '1');
f[i] = f[i - 1] * 2ll % MOD;
}
for (int k = 1; ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
int s0[100005];
long long qpow(long long x, int n) {
long long res = 1;
while (n) {
if (n & 1) res = res * x % int(1e9 + 7);
x = x * x % int(1e9 + 7);
n /= 2;
}
return res;
}
int main() {
cin >> N >> Q;
cin >> s;
for (int i = 0;... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | out = []
n,q = map(int, raw_input().split())
s = raw_input()
pref = [0]
for i in s:
if i == '0':
pref.append(pref[-1])
else:
pref.append(pref[-1]+1)
MOD = pow(10,9)+7
pow2 = [1]*(1+n)
for i in range(n):
pow2[i+1] = (pow2[i] *2)%MOD
for i in range(q):
l,r = map(int, raw_input().spli... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long int M1 = 1000000007;
const int M2 = 998244353;
const int N = 100005;
int ones[N];
template <typename T>
T modpow(T base, T exp, T modulus) {
base %= modulus;
T result = 1;
while (exp > 0) {
if (exp & 1) result = (result * base) % modulus;
base = (bas... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | init = 1
mod = 10 ** 9 + 7
_2a = []
for i in xrange(100001):
_2a.append(init)
init = init * 2
if init > mod:
init -= mod
#sum_2a = [1]
#for i in xrange(1, 100001):
# sum_2a.append((sum_2a[-1] + _2a[i]) % mod)
n, q = map(int, raw_input().split(" "))
s = raw_input()
sum_s = [1 if s[0] == "1" else ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main implements Runnable {
public static void main (String args[]){
new Thread(null, new Main(), "Main", 1 << 26).start();
// new Main().run();
}
static final int BA... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... |
import java.util.Scanner;
public class C {
static long m(int n) {
if (n == 0) {
return 1;
}
if (n % 2 == 1) {
long t = m(n / 2);
return 2 * t * t % 1000000007;
} else {
long t = m(n / 2);
return t * t % 1000000007;
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long a1[200009];
long long a0[200009];
long long mod = 1e9 + 7;
long long bigmod(long long base, long long pow) {
long long r1, r2;
if (pow <= 0) return 1;
if (pow % 2 != 0) {
r1 = bigmod(2, pow - 1);
r2 = (r1 * 2) % mod;
return r2;
} else if (pow %... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
r = sys.stdin.readlines()
M = 10 ** 9 + 7
n, q = r[0].split()
n = int(n)
q = int(q)
s = r[1]
p = [0]
k = 0
for v in range(n):
d = int(s[v])
k += (1 - d)
p.append(k)
ans = []
for k in range(q):
a, b = r[k + 2].split()
a = int(a)
b = int(b)
l = b - a + 1
zero = p[b] - p[a - 1]
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | from sys import stdin
n,q = map(int,stdin.readline().split())
a = stdin.readline().strip()
pre = [0] * (n+1)
mod = 10**9 + 7
po = [1] * (n+1)
for i in xrange(1,n+1):
po[i] = 2 * po[i-1]
if po[i] >=mod:
po[i]-=mod
for i in xrange(1,n+1):
pre[i] = pre[i-1]
if a[i-1]=='1':
pre[i]+=1
for i i... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L;
static final int INf = 1_000_000_000;
static FastReader reader;
static PrintWriter writer;
public static void main(String[] args) {
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
long long mod_pow(long long x, long long n) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * x % MOD;
x = x * x % MOD;
n >>= 1;
}
return res;
}
signed main() {
long long n, q;
cin >> n >> q;
stri... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long solve(long long good, long long len, vector<long long> &pow) {
long long rest = len - good;
long long ans = pow[good] - 1;
long long help = (ans * (pow[rest] - 1)) % mod;
ans += help;
ans %= mod;
return ans;
}
int main() {
io... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Bahnmi {
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long fenwick[100005];
void update(long long value, long long where, long long n) {
while (where <= n) {
fenwick[where] += value;
where += (where & -where);
}
}
long long query(long long where) {
long long res = 0;
while (where) {
res += fenwick[wher... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
input = sys.stdin.readline
n, q = map(int, input().split())
arr = [int(z) for z in input().rstrip()]
prefsums = [0, arr[0]]
for i in range(1, n):
prefsums.append(prefsums[i] + arr[i])
for query in range(q):
l, r = map(int, input().split())
num1 = prefsums[r] - prefsums[l-1]
num0 = (r... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 100005;
int q, n, l, r, ans;
char c;
long long sum[MAXN], sumPow[MAXN];
void init() {
sumPow[0] = 1;
long long temp = 1;
for (int i = 1; i <= MAXN; i++) {
temp = temp * 2 % MOD;
sumPow[i] = (sumPow[i - 1] % MOD + temp ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int m = (int)1e9 + 7;
int mult(int a, int b) { return (long long)a * b % m; }
void add(int& a, int b) {
a += b;
if (a >= m) {
a -= m;
}
}
int mpow(int a, int b) {
int ret = 1;
while (b) {
if (b & 1) {
ret = mult(ret, a);
}
a = mult(a, a);
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | n,q=map(int,raw_input().split())
s=raw_input()
mod=10**9+7
pre=[0,int(s[0])]
for i in range(1,len(s)):
pre.append(pre[i]+int(s[i]))
#print pre
pow2=[1]
for i in range(1,10**5+15):
pow2.append((pow2[i-1]*2)%mod)
while(q!=0):
q=q-1
l,r=map(int,raw_input().split())
x=pre[r]-pre[l-1]
print (pow2[r-l+1]-pow2[r-l+1-x... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) throws Exception{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int q=sc.nextInt();
String s=sc.next();
int arr[]=new int [n];
for(int i=0;i<n;i++) {
arr[i]=s.charAt(i)-'0';
}
int one[]=new int [... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #########################################################################################################\
#########################################################################################################
###################################The_Apurv_Rathore#####################################################
#... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... |
import sys
if __name__ == '__main__':
n, q = map(int, sys.stdin.readline().split())
arr = sys.stdin.readline()
total = [0]*n
if arr[0] == '1':
total[0] = 1
else:
total[0] = 0
for i in range(1, n):
if arr[i] == '1':
total[i] = total[i-1]+1
else:
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long n, q, a[100005], b[100005], l, r, _2[100005];
char s[100005];
int main() {
_2[0] = 1;
cin >> n >> q;
for (int i = 1; i <= n; i++) _2[i] = _2[i - 1] * 2 % 1000000007;
scanf("%s", s);
a[0] = b[0] = 0;
for (int i = 1; i <= n; i++) {
a[i] = a[i - 1] + ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
r = sys.stdin.readlines()
M = 10 ** 9 + 7
n, q = map(int, r[0].strip().split())
s = list(map(int, r[1].strip()))
p = [0]
for i in range(n):
p.append(p[i] + int(s[i]))
ans = []
for k in range(q):
a, b = map(int, r[k + 2].strip().split())
l = b - a + 1
one = p[b] - p[a - 1]
zero = l - one
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e5 + 10;
const ll inf = 1e18 + 10;
const ll MOD = 1e9 + 7;
ll n, q, cum[N];
ll add(ll x, ll y) { return (x + y) % MOD; }
ll mult(ll a, ll b) {
ll res = a * b;
res = res % MOD;
return res;
}
ll binpow(ll a, ll b, ll m) {
a %= m;
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.*;
public class BanhMi {
public static final long MOD = 1000000007;
public static void main(String[] args) {
FastScanner scanner = new FastScanner();
int N = scann... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | # use this as the main template for python problems
import sys
from collections import Counter
NUM = int(1e9+7)
def compute1(size, tots):
val = 0
ans = 0
for i in range(tots):
delic = val + 1
ans += delic
val = ((val % NUM) + (delic % NUM)) % NUM
print('=--')
for i in ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.text.*;
import java.util.*;
import java.io.*;
public class Main {
static final int mod = 1000000007;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer stk = new StringTokenizer(br.read... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | /* Rajkin Hossain */
import java.io.*;
import java.util.*;
public class C {
//static FastInput k = new FastInput("/home/rajkin/Desktop/input.txt");
static FastInput k = new FastInput(System.in);
static FastOutput z = new FastOutput();
static int n, q;
static char [] y;
static Pair [... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
r = sys.stdin.readlines()
M = 10 ** 9 + 7
n, q = r[0].strip().split()
n = int(n)
q = int(q)
s = r[1]
p = [0]
for v in range(n):
p.append(p[v] + int(s[v]))
ans = []
for k in range(q):
a, b = r[k + 2].strip().split()
a = int(a)
b = int(b)
l = b - a + 1
one = p[b] - p[a - 1]
ans.appe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.