PAT乙级 1017. A除以B
2018-03-31 13:37
316 查看
输入格式:
输入在1行中依次给出A和B,中间以1空格分隔。
输出格式:
在1行中依次输出Q和R,中间以1空格分隔。
输入样例:
1017. A除以B (20)
本题要求计算A/B,其中A是不超过1000位的正整数,B是1位正整数。你需要输出商数Q和余数R,使得A = B * Q + R成立。输入格式:
输入在1行中依次给出A和B,中间以1空格分隔。
输出格式:
在1行中依次输出Q和R,中间以1空格分隔。
输入样例:
123456789050987654321 7输出样例:17636684150141093474 3
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> int main(){ char a[2000]; scanf("%s",a); int b; scanf("%d",&b); int n = strlen(a); int temp=0; int flag = 0; for(int i=0;i<n;i++){ temp = (a[i]-'0')+temp*10; if(temp>=b){ printf("%d",temp/b); flag = 1; } else if(flag){ printf("0"); } temp = temp%b; } if(flag==0) printf("0"); printf(" %d",temp); }
相关文章推荐
- PAT乙级:1017. A除以B (C)
- [PAT-乙级]1017.A除以B
- PAT 乙级 1017. A除以B (20)
- PAT 乙级 1017. A除以B (20) Java版
- 1017. A除以B (20)-PAT乙级真题-PAT乙级真题-浙大PAT乙级真题java实现
- PAT乙级—1017. A除以B (20)-native
- 1017. A除以B (20) PAT乙级
- PAT乙级1017. A除以B(20)
- PAT乙级1017. A除以B (20)
- [PAT乙级]1017. A除以B (20)
- PAT乙级 1017. A除以B
- PAT 乙级 1017. A除以B
- PAT乙级1017 A除以B
- pat乙级1017. A除以B (20)
- PAT乙级1017. A除以B (20)&&1022. D进制的A+B (20)
- 浙江大学PAT_乙级_1017. A除以B (20)
- 1017. A除以B (20)--PAT乙级
- PAT乙级 1017. A除以B (20)--模拟大数除法
- PAT乙级1017. A除以B (20)
- 1017. A除以B (20)-PAT乙级真题