A/B Problem_ny_803(大数).java

A/B Problem

时间限制: 1000 ms  |  内存限制: 65535 KB
难度: 3
描述

 做了A+B Problem,A/B Problem不是什么问题了吧!

输入
每组测试样例一行,首先一个号码A,中间一个或多个空格,然后一个符号( / 或者 % ),然后又是空格,后面又是一个号码B,A可能会很长,B是一个int范围的数。
输出
输出结果。
样例输入
110 / 100
99 % 10
2147483647 / 2147483647
2147483646 % 2147483647
样例输出
1
9
1
2147483646


import java.math.BigInteger;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		while(input.hasNext()){
			String a=input.next();
			String c=input.next();
			String b=input.next();
			BigInteger A=new BigInteger(a);
			BigInteger B=new BigInteger(b);
			if(c.equals("/")){
				System.out.println(A.divide(B));
			}else{
				System.out.println(A.mod(B));
			}
		}
	}
}



在 `fetchDataCft` 函数中, `resolve` 方法只接受一个参数,所以需要将 `data` 和 `total_count` 封装为一个对象传递。修改后的 `fetchDataCft` 函数如下: ``` export function fetchDataCft(query_dict) { return new Promise((resolve, reject) => { queryCft(query_dict) .then(response => { const data = response.data; const total_count = response['total_count']; resolve({ data, total_count }); }) .catch(error => { reject(error); }); }); } ``` 在 `getData` 函数中,当 `Object.keys(this.query_dict_mark).length === 0` 时,会调用 `fetchDataCft` 函数,但是这个函数返回的是一个 Promise,需要使用 `then` 方法来处理异步操作。修改后的代码如下: ``` getData() { if (Object.keys(this.query_dict_mark).length === 0) { // 初始化query_dict中problem_id__in的值 this.$delete(this.query_dict, 'problem_id__in'); fetchDataCft(this.query_dict) .then(({ data, total_count }) => { this.data_list = data; this.total_count1 = total_count; }) .catch(error => { console.error(error); }); } else { fetchDataMark(this.query_dict_mark) .then(data => { this.problem_id_list = data.map(item => item.problem_id); this.$set(this.query_dict, 'problem_id__in', this.problem_id_list); // this.query_dict['problem_id__in'] = this.problem_id_list fetchDataCft(this.query_dict) .then(({ data, total_count }) => { this.data_list = data; this.total_count1 = total_count; }) .catch(error => { console.error(error); }); }) .catch(error => { console.error(error); }); } // 获取当前用户的收藏列表(problem_id_favorite) fetchDataMark({ favorite: this.current_user_name }) .then(data => { this.problem_id_favorite = data.map(item => item.problem_id); }) .catch(error => { console.error(error); }); }, ``` 这样,无论是在 `fetchDataCft` 函数中还是在 `getData` 函数中,都能够正确地处理异步操作,避免出现不符合预期的结果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值