Codeforces Olesya and Rodion
来源:互联网 发布:小型企业网络项目ppt 编辑:程序博客网 时间:2024/06/06 04:13
题目解析:大数问题,使用Java的BigInteger
import java.math.BigInteger;import java.util.Scanner;public class OlesyaAndRodion {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);//字符串转化为大数BigInteger k = new BigInteger(1+"");//设置为0BigInteger r = new BigInteger(0+"");//取第一个数BigInteger p = new BigInteger(10+"");int n = scanner.nextInt();int t = scanner.nextInt();if(n == 1 && t== 10) {System.out.println(-1);} else {n--;//求p的幂,p初始是10p = p.pow(n);for(int i = 1;; i++) {//求余,并和0比较if(p.mod(BigInteger.valueOf(t)).compareTo(r) == 0) {System.out.println(p);break;}//p+1p = p.add(k);}}}}
阅读全文
0 0
- Codeforces Olesya and Rodion
- Codeforces Round #324 A Olesya and Rodion
- Codeforces 584A Olesya and Rodion 【构造】
- A. Olesya and Rodion
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion
- Codeforces Round #324 (Div. 2) 584A. Olesya and Rodion
- Codeforces Round #324 (Div. 2)A. Olesya and Rodion
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion
- Codeforces--584A--Olesya and Rodion(水题)
- CodeForces - 584A Olesya and Rodion (模拟)水
- codeforces——584A——Olesya and Rodion
- Olesya and Rodion(模拟)
- Codeforces 584 A. Olesya and Rodion(Codeforces Round #324 (Div. 2))
- cf#324-A. Olesya and Rodion-水题
- Codeforces 584 A. Olesya and Rodion 数论+找规律(构造)
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion 构造数字 思维题
- 【Codeforces Round 324 (Div 2)A】【水题】Olesya and Rodion 构造数长度为n且是t的倍数
- cf#324 Div.2 Problem A Olesya and Rodion
- 本科回忆_序
- SDL2.0 写汉字
- 围观阿里云最会赚钱的人!价值2万元邀请码不限量发送
- JQuery toggle 转换事件
- HBuilder app 状态栏 颜色问题
- Codeforces Olesya and Rodion
- 从大四开始的职业生涯
- USB PM
- 书籍-Docker 容器与容器云
- Centos7配置JAVA_HOME
- 微信小程序里为什么我设置了数据却不显示
- CCM-ESPRIT,L型阵列二维角度配对算法
- gulp-用gulp做一个略完整的前端打包工作
- CAS 5.0.0的安装及配置