oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

gcd Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

gcd.html

Problem Description

The greatest common divisor of 2 numbers, also known as the highest common factor, is the highest whole number that can divide those 2 numbers without leaving any remainder.

The formula for GCD is as below: [Do note that a > b for all cases]


Input

2 numbers, a and b. It is not guarenteed that a is always greater than b or vice versa. However, both numbers will be below 109

Output

Output a single integer, the greatest common divisor of the 2 numbers.

Sample Input

12 8

Sample Output

4

wiki_gcd.png

wiki_gcd2.png

Tags

Number Theory

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100101s32MBAverage
2011s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o gcd -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.