From 1b8f7c9d4eb8b767d32dbbbfd96662b73c037627 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Wed, 29 Jun 2022 15:57:29 +0200 Subject: Solved some problem from codechef and codeforces --- codechef/jogging/inp | 0 codechef/jogging/main | Bin 0 -> 22608 bytes codechef/jogging/main.cpp | 31 +++++++++++++++++++++++++++++++ codechef/jogging/main.py | 11 +++++++++++ codechef/jogging/main_input0.txt | 4 ++++ codechef/jogging/main_output0.txt | 3 +++ 6 files changed, 49 insertions(+) create mode 100644 codechef/jogging/inp create mode 100755 codechef/jogging/main create mode 100644 codechef/jogging/main.cpp create mode 100644 codechef/jogging/main.py create mode 100644 codechef/jogging/main_input0.txt create mode 100644 codechef/jogging/main_output0.txt (limited to 'codechef/jogging') diff --git a/codechef/jogging/inp b/codechef/jogging/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/jogging/main b/codechef/jogging/main new file mode 100755 index 0000000..6d83dfd Binary files /dev/null and b/codechef/jogging/main differ diff --git a/codechef/jogging/main.cpp b/codechef/jogging/main.cpp new file mode 100644 index 0000000..e28bc48 --- /dev/null +++ b/codechef/jogging/main.cpp @@ -0,0 +1,31 @@ +#include + + +using namespace std; + +#define MOD 1000000007 + +long long power(long long b, int p) { + long long res = 1; + while(p) { + if(p % 2) res = (res * b) % MOD; + b = (b * b) % MOD; + p /= 2; + } + return res; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + int x; + cin >> n >> x; + long long y = power(2 ,n - 1); + long long ans = (x * y) % MOD; + cout << ans << endl; + } +} diff --git a/codechef/jogging/main.py b/codechef/jogging/main.py new file mode 100644 index 0000000..d6982e8 --- /dev/null +++ b/codechef/jogging/main.py @@ -0,0 +1,11 @@ +t = int(input()) + +for i in range(t): + n, x = input().split() + n = int(n) + x = int(x) + if n != 1: + print(((x * 2) ** (n - 1)) % 1000000007) + else: + print(x) + diff --git a/codechef/jogging/main_input0.txt b/codechef/jogging/main_input0.txt new file mode 100644 index 0000000..03d2aa8 --- /dev/null +++ b/codechef/jogging/main_input0.txt @@ -0,0 +1,4 @@ +3 +1 2 +2 1 +12548 1 diff --git a/codechef/jogging/main_output0.txt b/codechef/jogging/main_output0.txt new file mode 100644 index 0000000..cefdfa2 --- /dev/null +++ b/codechef/jogging/main_output0.txt @@ -0,0 +1,3 @@ +2 +2 +588809226 -- cgit v1.2.3