結果

問題 No.544 Delete 7
コンテスト
ユーザー sora410_t
提出日時 2017-11-03 09:34:29
言語 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
結果
TLE  
実行時間 -
コード長 419 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 613 ms
コンパイル使用メモリ 78,064 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2026-05-16 16:40:37
合計ジャッジ時間 3,473 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 2 TLE * 1 -- * 45
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:23:22: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
   23 |         cout << a << " " << b << endl;
      |                      ^~~
main.cpp:15:16: note: 'a' was declared here
   15 |         int n, a, b;
      |                ^
main.cpp:23:29: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
   23 |         cout << a << " " << b << endl;
      |                             ^
main.cpp:15:19: note: 'b' was declared here
   15 |         int n, a, b;
      |                   ^

ソースコード

diff #
raw source code

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

bool have7(const int n) noexcept {
	int r = n;
	for (int i = 0; i < log10(n); ++i) {
		if (r % 10 == 7) { return true; }
		r = floor(r / 10);
	}
	return false;
} 

int main() {
	int n, a, b;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		if (have7(i)) { continue; }
		if (have7(n-i)) { continue; }
		a = i; b = n - i;
		break;
	}
	cout << a << " " << b << endl;
}
0