結果

問題 No.537 ユーザーID
コンテスト
ユーザー sora410_t
提出日時 2017-11-02 00:12:36
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 651 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 505 ms
コンパイル使用メモリ 79,576 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-16 16:26:21
合計ジャッジ時間 1,821 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:2: warning: '#import' is a deprecated GCC extension [-Wdeprecated]
    1 | #import <iostream>
      |  ^~~~~~
main.cpp:2:2: warning: '#import' is a deprecated GCC extension [-Wdeprecated]
    2 | #import <cmath>
      |  ^~~~~~
main.cpp: In function 'int main()':
main.cpp:39:17: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
   39 |         cout << x << endl;
      |                 ^
main.cpp:32:13: note: 'x' was declared here
   32 |         int x;
      |             ^

ソースコード

diff #
raw source code

#import <iostream>
#import <cmath>
using namespace std;

bool p(const int m, const int n) {

	const int d1 = m % 10;
	const int d2 = n % 10;
	if (d1 != d2) { return false; }

	const int m_d = floor(log10(m)+1);
	const int n_d = floor(log10(n)+1);

	int t1 {0};
	int t2 {0};
	
	for (int i = 0; i < m_d; ++i) {
		t1 += d1 * pow(10, i);
	}
	if (m != t1) { return false; }

	for (int i = 0; i < n_d; ++i) {
		t2 += d2 * pow(10, i);
	}
	if (n != t2) { return false; }

	return true; 
}

int main() {
	int n;
	int x;
	cin >> n;
	for (int i = 1; i <= sqrt(n); ++i) {
		if (n % i == 0) {
			x += p(i, n/i) || i == sqrt(n) ? 1 : 2;
		}
	}
	cout << x << endl;
}
0