为啥C++栈要用long long

P1001 A+B Problem

cygnus_beta @ 2021-02-26 18:31:43

栈用int40 用long long 就AC了


by Textbook_blasphemy @ 2021-02-26 18:34:26

???

缓缓打出3个问号


by Violet___Evergarden @ 2021-02-26 18:35:11

为啥a+b要用栈?是我太蒟蒻了


by Pecco @ 2021-02-26 18:37:05

int40是啥


by cygnus_beta @ 2021-02-26 18:37:45

@Pecco int 40分


by Textbook_blasphemy @ 2021-02-26 18:37:49

@beta_Cyg 用int也没问题啊(你的代码)

另:栈建议手写,不建议使用STL

验证码:jkqp


by yuchenren @ 2021-02-26 18:38:31

A+B 用栈???

int40 是啥???

请原谅我太蒟了 /kk


by hjxhjx @ 2021-02-26 18:39:34

显而易见您40pts的代码用的是double


by hjxhjx @ 2021-02-26 18:40:36

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

int main(){
    stack<double>ab; //这里
    double i; //这里
    for(int n=0;n<2;n++){cin>>i;
        ab.push(i);
    }
    i=0;
    i+=ab.top();
    ab.pop();
    i+=ab.top();
    ab.pop();
    cout<<i;

    return 0;
}

by cygnus_beta @ 2021-02-26 18:42:24

@hjxhjx 那double为啥就不对了呢


by t162 @ 2021-02-26 18:43:28

@beta_Cyg double计算有精度误差


| 下一页