結果
| 問題 |
No.1113 二つの整数 / Two Integers
|
| コンテスト | |
| ユーザー |
Ogtsn99
|
| 提出日時 | 2020-07-17 21:35:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 885 bytes |
| コンパイル時間 | 2,110 ms |
| コンパイル使用メモリ | 191,504 KB |
| 最終ジャッジ日時 | 2025-01-11 22:20:02 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 15 |
ソースコード
// C++ implementation of program
#include<bits/stdc++.h>
using namespace std;
// Function to calculate gcd of two numbers
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b%a, a);
}
// Function to calculate all common divisors
// of two given numbers
// a, b --> input integer numbers
int commDiv(int a,int b)
{
// find gcd of a,b
int n = gcd(a, b);
// Count divisors of n.
int result = 0;
for (int i=1; i<=sqrt(n); i++)
{
// if 'i' is factor of n
if (n%i==0)
{
// check if divisors are equal
if (n/i == i)
result += 1;
else
result += 2;
}
}
return result;
}
// Driver program to run the case
int main()
{
int a = 12, b = 24;
cout << commDiv(a, b)<<endl;
return 0;
}
Ogtsn99