結果
問題 | No.428 小数から逃げる夢 |
ユーザー | ojisan_IT |
提出日時 | 2017-10-14 05:36:14 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 5,213 bytes |
コンパイル時間 | 1,254 ms |
コンパイル使用メモリ | 101,160 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-28 18:38:00 |
合計ジャッジ時間 | 3,934 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | WA | - |
testcase_98 | WA | - |
testcase_99 | WA | - |
ソースコード
#include<iostream> #include<cstdio> #include<vector> #include<map> #include<tuple> #include<string> #include<sstream> #include<cmath> #include<climits> #include<algorithm> #include<bitset> #include<set> #include<stack> #include<queue> #include<iomanip> #include<memory.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; #define rep(i,n) for(ll i=0;i<(n);i++) #define tii tuple<int,int> #define tiii tuple<int,int,int> #define mt make_tuple #define pb push_back #define ALL(a) (a).begin(),(a).end() #define FST first #define SEC second const int INF = (INT_MAX/2); const ll LLINF = (LLONG_MAX/2); const double eps = 1e-5; const double PI = M_PI; #define DEB cerr<<"!"<<endl #define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl #define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" ")) #define DIV 1000000007 inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;} inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;} const ll BigIntDig = 100; // BigIntDig*9-dig const ll Base = 1000000000; class BigInt{ public: int Num[BigIntDig]; bool sign; // 0 is positive,1 is negative - number int size; // how many using Num-Array BigInt(); BigInt(ll); BigInt(string); void Setstr(string); int Carry(int,int); void Deb(); }; BigInt operator-(BigInt x){ x.sign ^= 1; return x; } // you can use this func after setting "size" void BigInt::Setstr(string str){ int m = str.size() % 9; if(m == 0) m = 9; Num[size-1]=atoi(str.substr(0,m).c_str()); for(int i = size-2; i >= 0; i--) Num[i] = std::atoi(str.substr((size-i-1)*9-(9-m),9).c_str()); } ostream &operator<<(ostream &os, BigInt x) { if(x.sign) os << '-'; os << x.Num[x.size-1]; for (int i = x.size-2; i >= 0; --i) os << setw(9) << setfill('0') << x.Num[i]; return os; } BigInt::BigInt(){ memset(Num,0,sizeof(Num)); size = 1; sign = 0; } BigInt::BigInt(string str){ if(str[0] == '-'){sign = 1; str = str.substr(1);} else sign = 0; memset(Num,0,sizeof(Num)); if(str == "INF"){ size = BigIntDig; Num[size-1] = Base/10; }else{ size = (str.size()-1)/9 + 1; Setstr(str); } } BigInt::BigInt(ll num){ memset(Num,0,sizeof(Num)); if(num < 0) sign = 1; else sign = 0; num = llabs(num); Num[0] = num % Base; Num[1] = num / Base; if(Num[1] != 0) size = 2; else size = 1; } bool operator < (BigInt x,BigInt y){ if(x.sign && y.sign) return ((-y)<(-x)); if(x.sign && y.sign == 0) return true; if(x.sign == 0 && y.sign) return false; if(x.size != y.size) return x.size < y.size; for(int i=x.size-1; i >= 0; i--) if(x.Num[i] != y.Num[i]) return x.Num[i] < y.Num[i]; return false; // x == y } bool operator > (BigInt x,BigInt y){return y<x;} bool operator <= (BigInt x,BigInt y){return !(y<x);} bool operator >= (BigInt x,BigInt y){return !(x<y);} bool operator != (BigInt x,BigInt y){return x<y || y<x;} bool operator == (BigInt x,BigInt y){return !(x<y)&& !(y<x);} BigInt resize(BigInt x){ while(x.Num[x.size-1] == 0 && x.size != 1) x.size--; return x; } int BigInt::Carry(int nsize,int value){ // nsize:point of carrying, value: value of carrying if(value == 0)return 0; int index = nsize+1; if(index >= size){ size = index+1; Num[index] = value; }else{ int sum = Num[index] + value; if(sum >= Base){ Carry(index,sum/Base); sum %= Base; Num[index] = sum; }else{ Num[index] = sum; } } return 0; } BigInt operator-(BigInt x, BigInt y); BigInt operator+(BigInt x, BigInt y) { if(x.sign && y.sign) return (-(-x+(-y))); if(x.sign && y.sign == 0) return (y-(-x)); if(x.sign == 0 && y.sign) return (x-(-y)); if (x.size < y.size) x.size = y.size; for (int i = 0; i < y.size; ++i){ x.Num[i] += y.Num[i]; if(x.Num[i] >= Base){ x.Carry(i,x.Num[i]/Base); x.Num[i] %= Base; } } return x; } BigInt operator-(BigInt x, BigInt y) { if(x.sign && y.sign) return (-y)-(-x); if(x.sign == 0 && y.sign) return x+y; if(x.sign && y.sign == 0) return x+(-y); if (x < y) {swap(x,y); x.sign ^= 1;} for (int i = 0; i < y.size; ++i){ x.Num[i] -= y.Num[i]; if(x.Num[i] < 0){ x.Carry(i,-1); x.Num[i] += Base; } } return resize(x); } BigInt operator*(BigInt x,BigInt y){ int ys=y.size,xs = x.size; BigInt ret;ret.size = 1; ret.sign = (x.sign + y.sign)%2; for (int i = 0; i < xs; ++i){ for(int j = 0; j < ys; ++j){ ll mul = (ll)x.Num[i] * y.Num[j]; ret.Carry(i+j,mul/Base); ret.Carry(i+j-1,mul%Base); } } return ret; } void BigInt::Deb(){ for(int i = 0;i < size;i++) cout << Num[i] << " " << i << endl; } int main(){ string s = "1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991"; BigInt bi(s); int n; cin >> n; stringstream ss; ss << bi*n << endl; string ans = ss.str(); if(n < 9) ans = "0." + ans; else if(n < 82) ans.insert(1,"."); else ans.insert(2,"."); cout << ans << endl; }