結果

問題 No.219 巨大数の概算
コンテスト
ユーザー nksk38
提出日時 2017-07-27 16:59:20
言語 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  
実行時間 -
コード長 979 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 835 ms
コンパイル使用メモリ 98,768 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2026-04-26 03:54:19
合計ジャッジ時間 12,947 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other WA * 4 TLE * 1 -- * 46
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
                 from main.cpp:3:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:51:11:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:232:25: warning: 'x_mi' may be used uninitialized [-Wmaybe-uninitialized]
  232 |       { return _M_insert(__f); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:37:44: note: 'x_mi' was declared here
   37 |                 double mi = 1000000000,num,x_mi,y_mi,z_mi;
      |                                            ^~~~
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:51:26:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:232:25: warning: 'y_mi' may be used uninitialized [-Wmaybe-uninitialized]
  232 |       { return _M_insert(__f); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:37:49: note: 'y_mi' was declared here
   37 |                 double mi = 1000000000,num,x_mi,y_mi,z_mi;
      |                                                 ^~~~
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:51:41:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:232:25: warning: 'z_mi' may be used uninitialized [-Wmaybe-uninitialized]
  232 |       { return _M_insert(__f); }

ソースコード

diff #
raw source code

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

double logbase(double a, double base)
{
	return log(a) / log(base);
}

int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		double A, B; 
		cin >> A >> B;

		double mi = 1000000000,num,x_mi,y_mi,z_mi;
		for (int x = 1; x <= 9; x++) {
			for (int y = 1; y <= 9; y++) {
				for (int z = 1; z <= 100; z++) {
					num = abs(B - logbase(x+y*0.1,A)  - z/logbase(A,10));
					if (mi > num) {
						mi = num;
						x_mi = x;
						y_mi = y;
						z_mi = z;
					}
				}
			}
		}
		cout << x_mi << " " << y_mi << " " << z_mi << endl;
	}
	return 0;
}
0