思路:串的处理。
#include<map> #include<queue> #include<cmath> #include<cstdio> #include<stack> #include<iostream> #include<cstring> #include<algorithm> #define ll long long #define inf 0x3f3f3f3f #define eps 1e-8 #include<vector> #define ls l,mid,rt<<1 #define rs mid+1,r,rt<<1|1 using namespace std; int arr[1010]; int main(){ int n,m,i,j,k; string str; while(cin>>str>>n){ if(str.size()==1){ int tmp = str[0]-'0'; if(tmp < n){ printf("0 0\n"); } else{ printf("%d %d\n",tmp/n,tmp%n); } continue; } int tmp = 0; bool bj=false; for(i = 0;i <str.size() ;++ i){ tmp = (tmp*10+str[i]-'0'); if(tmp >= n){ printf("%d",tmp/n); tmp %= n;bj=true; } else if(bj) printf("0"); } printf(" %d\n",tmp); } return 0; }