Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added my LTIME95B answers in Codechef #76

Merged
merged 6 commits into from
Aug 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create Array Rotation.java
  • Loading branch information
Sushank34 committed Aug 23, 2021
commit fcee1ba340b22b4e860890cec30f0587f9fe0670
86 changes: 86 additions & 0 deletions Codechef/LTIME95B/Array Rotation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;

public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}

String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt()
{
return Integer.parseInt(next());
}


long nextLong()
{
return Long.parseLong(next());
}

double nextDouble()
{
return Double.parseDouble(next());
}

String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args) throws java.lang.Exception{
FastReader sc=new FastReader();
int n=sc.nextInt();
long[] arr=new long[n];
long sum=0;
for(int i=0;i<n;i++) {
arr[i]=sc.nextLong();
sum=(sum+arr[i])%1000000007;
}

int q=sc.nextInt(),x;
for(int i=0;i<q;i++) {
x=sc.nextInt();
if(sum<0) {
sum=(((sum*2)%1000000007)+1000000007)%1000000007;
}
else {
sum=(sum*2)%1000000007;
}
System.out.print(sum+"\n");
}
}
}