求助

P1001 A+B Problem

Wildcxj @ 2020-06-21 20:14:39

本想来一个恶搞代码的,结果错了,希望大佬指教

#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll mi10(ll a)
{
    ll rtint = 1;
    for (ll i = 0; i < a; i++)
    {
        rtint *= 10;
    }
    return rtint;
}
ll toint(string s)
{
    ll ri = 0,fu=1;
    ll cnt = mi10(s.length() - 1);
    if (s[0] == '-')
    {
        fu = -1;
    }
    for (ll i = 0; i < s.length(); i++)
    {
        if (fu == 1)
        {
            ri += cnt * (s[i] - 48);
            cnt /= 10;
        }
        else
        {
            ri += cnt * (s[i+1] - 48);
            cnt /= 10;
        }
    }
    return ri*fu;
}
int main() {
    string a, b;
    cin >> a >> b;
    cout << toint(a) + toint(b);
    return 0;
}

by tangrunxi @ 2020-06-21 20:15:04

qpee


by critnos @ 2020-06-21 20:15:57

这啥啊,高精加吗


by DeepSkyBlue__ @ 2020-06-21 20:15:58

qpee


by critnos @ 2020-06-21 20:24:58

@yiayiayi 怎么了


by Wildcxj @ 2020-06-21 20:26:33

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mi10(ll a)
{
    ll rtint = 1;
    for (ll i = 0; i < a; i++)
    {
        rtint *= 10;
    }
    return rtint;
}
ll toint(string s)
{
    ll ri = 0,fu=1;
    ll cnt = mi10(s.length() - 1);
    if (s[0] == '-')
    {
        fu = -1;
        cnt = mi10(s.length() - 2);
        for (ll i = 1; i < s.length(); i++)
        {
            ri += cnt * (s[i] - 48);
            cnt /= 10;
        }
    }
    else
    {
        for (ll i = 0; i < s.length(); i++)
        {
            ri += cnt * (s[i] - 48);
            cnt /= 10;
        }
    }
    return ri*fu;
}

int main() {
    string a, b;
    cin >> a >> b;
    int temp = rand() % 2;
    if (temp == 1)
    {
        cout << toint(a) + toint(b);
    }
    else
    {
        ll aa, ab;
        cin >> aa >> ab;
        cout << aa * 100 - aa * 99 * 10 / 2 / 5 + ab * 12 - ab * (12 - 1);
    }
    return 0;
}

对了


by critnos @ 2020-06-21 20:27:23

话说这个不算恶搞的吧(


by Handsome·Dragon @ 2020-06-26 16:44:18

........

作死这得自负后果了,就一A+B problem 也要浪费时间


by BqtMtsZDnlpsT @ 2020-07-08 13:15:28

qpee


by 晨光万丈 @ 2020-07-19 12:40:14

T135254去试试


by 幸运小崽 @ 2020-08-14 14:26:50

主页双贴非常危


| 下一页