题目链接->link
思路
- 这题输入输出即可以全部输入到数组中求导,再输出,又可以输入一对输出一对,两种都对,有点奇怪。
- 坑点有两处,一是当输入系数为0,指数为0时,直接输出0 0,因为按指数递减输入,故一定是第一组数据。
- 二是当系数不为0,指数不为0时,如果是第一组则输出0 0,如果是最后一组不输出。综上,在第一组和循环中都需要作判断,也是第三组数据老是不过的原因。
- 最后是注意输出格式即可。
代码
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
int main(){
int t,e;
cin>>t>>e;
if(e==0){
cout<<0<<' '<<0;
}
else cout<<t*e<<' '<<e-1;
while(cin>>t>>e){
if(e==0)break;
else cout<<' '<<t*e<<' '<<e-1;
}
return 0;
}