結果

問題 No.219 巨大数の概算
ユーザー Kmcode1
提出日時 2015-05-29 23:48:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 47 ms / 1,500 ms
コード長 1,363 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 106,680 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-18 10:51:09
合計ジャッジ時間 4,898 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 51
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |         scanf("%lld%lld", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<random>
#define EPS 1e-8
using namespace std;
int n;
int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        long long int a, b;
        scanf("%lld%lld", &a, &b);
        long double ab = log((long double)a)*(long double)(b);
        long double abb = ab / log((long double)(10.0));
        long double z = floor(abb);
        int maxt = 0;
        long long int outt = z;
        for (int ii = 1; ii <= 9; ii++){
            for (int j = 0; j < 10; j++){
                long double num = log((long double)(ii*10.0 + j));
                long double want = z - 1.0;
                num += (long double)(log((long double)(10.0)))*want;
                if (num-EPS <= ab){
                    maxt = max(maxt, ii * 10 + j);
                }
            }
        }
        cout << maxt / 10 << " " << maxt % 10 << " " << outt << endl;
    }
    return 0;
}
0