From 160f1f07004124efa1aca91b26739390480f909a Mon Sep 17 00:00:00 2001 From: Shashwat Garg Date: Wed, 17 Oct 2018 22:21:00 +0530 Subject: [PATCH 1/2] Modular GCD Link to problem : https://www.codechef.com/problems/GCDMOD #1 --- Codechef/GCDMOD.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Codechef/GCDMOD.py diff --git a/Codechef/GCDMOD.py b/Codechef/GCDMOD.py new file mode 100644 index 00000000..0911d96c --- /dev/null +++ b/Codechef/GCDMOD.py @@ -0,0 +1,23 @@ +/* + * Shashwat Garg + * B16034 + * IIT Mandi + */ + +def gcd(a,b): + if(b==0): + return a + return gcd(b,a%b) +t=input(); +for i in range(t): + a,b,n=map(int,raw_input().split()) + if(a==b): + res=pow(a,n,1000000007) + res=res+pow(b,n,1000000007) + res=res%(1000000007) + print res + continue + res=pow(a,n,a-b) + res=res+pow(b,n,a-b) + res=res%(a-b) + print gcd(a-b,res) \ No newline at end of file From 70c409952ef005c48338d409f309ab8c986fca9e Mon Sep 17 00:00:00 2001 From: Shashwat Garg Date: Fri, 19 Oct 2018 09:16:15 +0530 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 818f9f87..0fc3eedb 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ In this repository, you can find the solutions (as source code) for the problems | [Anubhav Gupta](https://github.com/theanubhava)
| India | Java, | | [Inzemam Ul-Haq](https://github.com/Virusthegreat)
| India | C++ | | [Bertram Truong](https://github.com/bt)
| Australia | | - +| [Shashwat Garg](https://github.com/Shashwat-Garg)
| India | Python | ### License