QAQ 995!!!!!!!!!!!!!!!!!!

P1480 A/B Problem

MSJ2013 @ 2024-07-31 18:23:23


#include<iostream>
using namespace std;
int main()
{
    unsigned long long a,b;
    cin>>a>>b;
    cout<<a/b;
    return 0;
}

by Jerry20140101 @ 2024-08-18 22:25:22

我改C++党了 附赠52分代码:

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

int main () {
    string a,b;
    cin>>a>>b;
    long long c = stoll(a);
    long long d = stoll(b);
    cout<<c / d<<endl;
    return 0;
}

再微微改进一下就好了

虽然可能改进不了...


by MSJ2013 @ 2024-08-21 13:00:33

@Jerry20140101 好的


by Jerry20140101 @ 2024-08-25 15:25:08

@MSJ2013

我会高精了

给你AC代码 如下(高精):

#include <bits/stdc++.h>
using namespace std;
int const N = 5005;
struct bignum {
    int d[N];
    void read () {
        char s[N];
        cin>>s;
        int n = strlen(s);
        for(int i = 0;i < n;i++) d[i] = s[n-1-i] - '0';
        for(int i = n;i < N;i++) d[i] = 0;
    }
    void print () {
        int pos = N - 1;
        while(pos > 0 && !d[pos]) pos --;
        for(int i = pos;i >= 0;i--) cout<<d[i];
        putchar('\n');
    }
    bignum operator/ (int x) {
        long long res = 0;
        bignum tmp;
        for(int i = N - 1;i >= 0;i--) {
            res = res * 10 + d[i];
            tmp.d[i] = res / x;
            res = res % x;
        }
        return tmp;
    }
}i,j;
int main () {
    int b;
    i.read();
    cin>>b;
    j = i / b;
    j.print();
    return 0;
}

by MSJ2013 @ 2024-08-25 19:49:02

@Jerry20140101 谢谢,已AC,


上一页 |