From c787af8fc1ea6c56c68c1d6b6f2c0568bebc709a Mon Sep 17 00:00:00 2001 From: Manya Kalra Date: Fri, 10 Oct 2025 17:47:54 +0530 Subject: [PATCH] add solution for A. Rational Resistance problem 343A --- Number_Theory/A. Rational Resistance.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Number_Theory/A. Rational Resistance.cpp diff --git a/Number_Theory/A. Rational Resistance.cpp b/Number_Theory/A. Rational Resistance.cpp new file mode 100644 index 0000000..9f923a8 --- /dev/null +++ b/Number_Theory/A. Rational Resistance.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; +#define int long long +signed main(){ + ios_base::sync_with_stdio(false); + cin.tie(0); + cout.tie(0); + int a, b; + cin>>a>>b; + int ans=0; + while(a&&b){ + if(a>b){ + ans+=a/b; + a%=b; + }else{ + ans+=b/a; + b%=a; + } + } + cout<