結果

問題 No.428 小数から逃げる夢
ユーザー 0w1
提出日時 2016-11-24 16:39:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 979 bytes
コンパイル時間 1,575 ms
コンパイル使用メモリ 171,032 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 10:34:04
合計ジャッジ時間 3,855 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

string v = "1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991";

string add( string a, string b ){
  if( not ( a.size() >= b.size() ) )
    swap( a, b );
  string res;
  int rmd = 0;
  for( int i = 0; i < a.size(); ++i ){
    rmd += a[ a.size() - 1 - i ] - '0';
    if( ( int ) b.size() - 1 - i >= 0 )
      rmd += b[ b.size() - 1 - i ] - '0';
    res += ( char ) ( '0' + rmd % 10 );
    rmd /= 10;
  }
  if( rmd )
    res += ( char ) ( '0' + rmd );
  reverse( res.begin(), res.end() );
  return res;
}

signed main(){
  int N; cin >> N;
  string ans = "0";
  for( int i = 0; i < N; ++i )
    ans = add( ans, v );
  if( ans.size() == 190 )
    cout << "0";
  for( int i = 0; i < ans.size(); ++i ){
    if( i + 190 == ans.size() )
      cout << ".";
    cout << ans[ i ];
  }
  return 0;
}

 
0