4分

P1480 A/B Problem

lym61 @ 2024-09-07 17:58:50

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char a[6000];
int c[6000], d[6000];
int b, x;
int main() {
    int la, lc = 1;
    gets(a);

    la = strlen(a);
    scanf("%d", &b);
    for (int i = 1; i <= la; i++) d[i] = a[i - 1] - '0';
    for (int i = 1; i <= la; i++) {
        c[i] = (x * 10 + d[i]) / b;
        x = (x * 10 + d[i]) % b;
    }
    while (c[lc] == 0 && lc < la) lc++;
    for (int i = lc; i <= la; i++) printf("%d", c[i]);

    return 0;
}

by 0_________0 @ 2024-09-07 18:15:17

#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#define int long long
using namespace std;
string a;
int c[6000], d[6000];
int b, x;
main() {
    int la, lc = 1;
    cin>>a;
    la = a.size();
    scanf("%d", &b);
    for (int i = 1; i <= la; i++) d[i] = a[i - 1] - '0';
    for (int i = 1; i <= la+1; i++) {
        c[i] = (x * 10 + d[i]) / b;
        x = (x * 10 + d[i]) % b;
    }
    while (c[lc] == 0 && lc < la) lc++;
    for (int i = lc; i <= la; i++) cout<<c[i];
    return 0;
}           

by 0_________0 @ 2024-09-07 18:15:36

求关


|