99我

P1480 A/B Problem

xuyangming @ 2024-08-06 11:55:40

#include<iostream>
using namespace std;
char a1[10001];
int b,c[100001],a[100001],len,k=1,cnt;
int main()
{
    cin>>a1>>b;
    len=strlen(a1);
    for(int i=1;i<=len;i++)
    {
        a[i]=a1[i-1]-'0';
    }
    for(int i=1;i<=len;i++)
    {
        cnt=cnt*10+a[i];
        c[i]=cnt/b;
        cnt%=b;
    }
    while (c[k]==0&&k<len)
    {
        k++;
    }
    for (int i=k;i<=len;++i) 
    {
        cout<<c[i];
    }
    return 0;
}

by xuyangming @ 2024-08-06 11:56:03

一个关注


by King_and_Grey @ 2024-08-06 12:01:52

@xuyangming

#include<bits/stdc++.h>
using namespace std;
const int Maxn = 1e6;
#define int long long
string str;
int a[Maxn + 5],b,c[Maxn + 5];
int len = 1,x;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin >> str;
    cin >> b;
    for(int i = 0;i < str.size();i++){
        a[i + 1] = str[i] - '0';
    }
    for(int i = 1;i <= str.size();i++){
        c[i] = (x * 10 + a[i]) / b;
        x = (x * 10 + a[i]) % b;
    }
    while(c[len] == 0 && len < str.size()){
        len++;
    }
    for(int i = len;i <= str.size();i++){
        cout << c[i];
    }
    cout << endl;
    return 0;
}

by LIONELMESSIYYDS @ 2024-08-06 12:03:45

@xuyangming 用python老简单了


a , b = int(input()),int(input())
print (a // b)

by Wyl20110306 @ 2024-08-06 12:04:38

@xuyangming


#include<bits/stdc++.h>
using namespace std;
string s1;
long long int a[5500],c[5500],b,yu,len;
int main(){
    cin>>s1>>b;
    len=s1.size();
    for(int i=1;i<=len;i++){
        a[i]=s1[len-i]-'0';
    }
    for(int i=len;i>=1;i--){
        long long t=yu*10+a[i];
        c[i]=t/b;
        yu=t%b;
    }
    while(len>1&&c[len]==0) len--;
    for(int i=len;i>=1;i--)
        cout<<c[i];
    return 0;
}

by Wyl20110306 @ 2024-08-06 12:05:07

@LIONELMESSIYYDS python自带高精


by Wyl20110306 @ 2024-08-06 12:05:39

@xuyangming 没开longlong是一点


by LIONELMESSIYYDS @ 2024-08-06 12:06:35

@Wyl20110306

我知道


|