-
Notifications
You must be signed in to change notification settings - Fork 62
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
EXPTREE (JULY 17) [CPP] #197
base: master
Are you sure you want to change the base?
Changes from 7 commits
cbd1add
29e4183
9b2c098
3538411
00a5807
972d4c1
2a7e472
e288bf6
51409be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,6 @@ | |
*.class | ||
*.pyc | ||
*.html | ||
.idea/ | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ using namespace std; | |
|
||
int main() { | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo this change, as it is not part of your PR. |
||
std::ios::sync_with_stdio(false); | ||
int testCases; | ||
cin >> testCases; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// BY: _nishant0208_ | ||
|
||
#include <bits/stdc++.h> | ||
#include <algorithm> | ||
using namespace std; | ||
typedef long long ll; | ||
|
||
#define MAX1 1000000007 | ||
|
||
#define MAX2 1000000009 | ||
|
||
#define MAX 100001 | ||
|
||
ll MOD; | ||
ll exponent(ll, ll); | ||
ll modinverse(ll); | ||
|
||
int main(){ | ||
ll t; | ||
cin >> t; | ||
while(t--){ | ||
ll n; | ||
cin >> n; | ||
n--; | ||
ll x, y, temp1, temp2; | ||
MOD = MAX1; | ||
x = ((n % MOD) * ((n + 1) % MOD)) % MOD; | ||
y = (2 * ((2 * n - 1) % MOD)) % MOD; | ||
if(x % 2 == 0 && y % 2 == 0){ | ||
x /= 2; | ||
y /= 2; | ||
} | ||
if(x % 3 == 0 && y % 3 == 0){ | ||
x /= 3; | ||
y /= 3; | ||
} | ||
temp1 = ((x % MOD) * (modinverse(y))) % MOD; | ||
MOD = MAX2; | ||
x = ((n % MOD) * ((n + 1) % MOD)) % MOD; | ||
y = (2 * ((2 * n - 1) % MOD)) % MOD; | ||
if(x % 2 == 0 && y % 2 == 0){ | ||
x /= 2; | ||
y /= 2; | ||
} | ||
if(x % 3 == 0 && y % 3 == 0){ | ||
x /= 3; | ||
y /= 3; | ||
} | ||
temp2 = ((x % MOD) * (modinverse(y))) % MOD; | ||
cout << temp1 << " " << temp2 << "\n"; | ||
} | ||
return 0; | ||
} | ||
|
||
ll exponent(ll a, ll b) { | ||
if(b == 0) | ||
return 1; | ||
ll temp = (exponent(a, b / 2)) % MOD; | ||
temp = (temp * temp) % MOD; | ||
return (b % 2 == 0) ? temp : ((a % MOD) * temp) % MOD; | ||
} | ||
|
||
ll modinverse(ll val) { | ||
return exponent(val, MOD - 2); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a new line at end. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After which line number? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at the end of file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather simply delete the .idea files for now and in another PR you can do this 😉