2 solutions

  • 2
    @ 2025-4-19 15:34:24
    #include<bits/stdc++.h>
    using namespace std;
    const int N=100010;
    int a[N],c[N];
    int main()
    {
    	string s;
    	cin>>s;
    	int b;
    	cin>>b;
    	for(int i=0;i<s.size();i++)
    	{
    		a[i]=s[i]-'0';
    	}
    	int t=0;
    	for(int i=0;i<s.size();i++)
    	{
    		t=t*10+a[i];
    		c[i]=t/b;
    		t%=b;
    	}
    	int lenc=s.size();
    	reverse(c,c+lenc);
    	while(lenc>0&&c[lenc]==0) lenc--;
    	for(int i=lenc;i>=0;i--) cout<<c[i];
    	cout<<endl;
    	cout<<t;
    	return 0;
    }
    
    
    • 0
      @ 2025-5-31 10:32:57
      #include<bits/stdc++.h>
      using namespace std;
      const int nm=100010;
      int a[nm],c[nm];
      string s;
      int main()
      {
      	cin>>s;
      	int b;
      	cin>>b;
      	for(int i=0;i<s.size();i++) a[i]=s[i]-'0';
      	int t=0;
      	for(int i=0;i<s.size();i++){
      		t=t*10+a[i];
      		c[i]=t/b;
      		t%=b;
      	}
      	int lc=s.size();
      	reverse(c,c+lc);
      	while(lc>0&&c[lc]==0) lc--;
      	for(int i=lc;i>=0;i--) cout<<c[i];
      	cout<<endl<<t;
      	return 0;
      }
      
      • 1

      Information

      ID
      146
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      3
      Tags
      (None)
      # Submissions
      45
      Accepted
      16
      Uploaded By