java在acm中常用基础技巧方法
java在acm中常用基础技巧方法
如果学到了新的技巧,本博客会更新~
input
input-std
@Frosero
import java.util.*;
public class Main {
static String a;
static int c;
static Scanner cin = new Scanner(System.in);
public static void main(String[] args) {
while(cin.hasNext()){ // while(scanf("%d",&a)!=EOF)
a = cin.next(); // input : %d
c = cin.nextInt(); // input : %s
}
}
}
input-file
@Frosero
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.*;
public class Main {
static int x,y;
public Main() throws FileNotFoundException{
Scanner cin = new Scanner(new File("test.in"));
PrintWriter cout = new PrintWriter(new File("test.out"));
x = cin.nextInt();
y = cin.nextInt();
cout.println(x + y);
cout.close();
}
public static void main(String[] args) throws FileNotFoundException {
new Main();
}
}
output
@Frosero
public class Main {
public static void main(String[] args) {
System.out.print("hello world !"); //printf("hello world !");
System.out.println("hello world !"); //printf("hello world !\n");
}
}
BigInteger
需要特别说明的就是BigInteger需要由String转化过来。如果是整数,直接toString就好了。
@Frosero
import java.math.BigInteger;
public class Main {
static BigInteger a = new BigInteger("9876543210");
static BigInteger b = new BigInteger("27");
static BigInteger m = new BigInteger("1000000007");
public static void main(String[] args) {
System.out.println(a.add(b)); // +
System.out.println(a.subtract(b)); // -
System.out.println(a.multiply(b)); // *
System.out.println(a.divide(b)); // /
System.out.println(a.mod(b)); // %
System.out.println(a.compareTo(b)); // a > b : 1 ; a < b : -1 ; a == b : 0 ;
System.out.println(a.equals(b)); // a == b : true ;
System.out.println(a.isProbablePrime(1)); // probable : true ;
System.out.println(a.gcd(b)); // gcd
System.out.println(a.modPow(b, m)); // pow + %
// max min or xor and .......
}
}
java在acm中常用基础技巧方法的更多相关文章
- 【Java】Java中常用的String方法
本文转载于:java中常用的String方法 1 length()字符串的长度 String a = "Hello Word!"; System.out.println(a.len ...
- ACM 中常用的算法有哪些? 2014-08-21 21:15 40人阅读 评论(0) 收藏
ACM 中常用的算法有哪些?作者: 张俊Michael 网络上流传的答案有很多,估计提问者也曾经去网上搜过.所以根据自己微薄的经验提点看法. 我ACM初期是训练编码能力,以水题为主(就是没有任何算法, ...
- Java在ACM中的应用
Java在ACM中的应用 —. 在java中的基本头文件(java中叫包) import java.io.*; import java.util.*; //输入Scanner import java. ...
- Google在情报搜集中的基础技巧
Google在情报搜集中的基础技巧 作者:王宇阳 时间:2019-06-06 作者笔记 Google Hacking 是指使用特定的高级的google搜索语法,收集渗透测试目标的信息,查找目标的配 ...
- jQuery中常用的函数方法
jQuery中常用的函数方法总结 Ajax处理 load(url,[data],[callback]) url (String) : 待装入 HTML 网页网址. data (Map) : (可选) ...
- 2019-2-20C#开发中常用加密解密方法解析
C#开发中常用加密解密方法解析 一.MD5加密算法 我想这是大家都常听过的算法,可能也用的比较多.那么什么是MD5算法呢?MD5全称是 message-digest algorithm 5[|ˈmes ...
- VB的一些项目中常用的通用方法-一般用于验证类
1.VB的一些项目中常用的通用方法: ' 设置校验键盘输入值,数字 Public Function kyd(key As Integer) As Integer Dim mychar mychar = ...
- php面向对象类中常用的魔术方法
php面向对象类中常用的魔术方法 1.__construct():构造方法,当类被实例化new $class时被自动调用的方法,在类的继承中可以继承与覆盖该方法,例: //__construct( ...
- Java && Python 算法面试常用类以及方法总结
数据结构 逻辑结构上: 包括集合,线性结构,非线性结构. 存储结构: 顺序存储,链式存储,索引存储,散列存储. Java 常见数据结构 大专栏 Java && Python 算法面试 ...
随机推荐
- jdbcTemplate查询结果为对象list
RowMapper<WmsExpensesSettleEntity> rowMapper1=new BeanPropertyRowMapper<WmsExpensesSettleEn ...
- Django学习笔记(三)视图
构建网页内容 视图函数的return具有多种响应类型: 上述函数主要来自django.http,该模块是实现响应功能的核心. 实际开发中可用此模块实现文件下载功能,在index的urls.py和vie ...
- spring在WEB中的应用。
1:创建IOC容器.在WEB应用程序启动的时候就创建.利用到监听器. ServletContextListener类的contextInitialized方法中 package com.struts2 ...
- 【Flutter学习】之Widget数据共享之InheritedWidget
一,概述 业务开发中经常会碰到这样的情况,多个Widget需要同步同一份全局数据,比如点赞数.评论数.夜间模式等等.在安卓中,一般的实现方式是观察者模式,需要开发者自行实现并维护观察者的列表.在flu ...
- Network基础(一):配置计算机名及工作组、TCP/IP地址配置、网络连通性测试
一.配置计算机名及工作组 目标: 本例要求为修改计算机名并加入工作组: 设置计算机名:姓名拼音 设置工作组名:TARENA-NETWORK 方案: 修改Windows 2008服务器的计算机名(可设为 ...
- Kubernetes 健康检查的两种机制:Liveness 探测和 Readiness 探测
Kubernetes 健康检查的两种机制:Liveness 探测和 Readiness 探测,并实践了健康检查在 Scale Up 和 Rolling Update 场景中的应用.kubelet使用启 ...
- rocketmq单点部署
下载地址:https://github.com/alibaba/RocketMQ 转载请注明来源:http://blog.csdn.net/loongshawn/article/details/510 ...
- express上传图片
var express = require('express') var app = express() var proxy = require('http-proxy-middleware') co ...
- layui表单提交使用form.on('submit(sub)',function (){}) 使用ajax请求时回调不执行的原因及解决方法
ayui使用官方的表单模块form.on('submit(sub)',function (){}) 提交,使用ajax请求向后台请求一个执行结果,根据结果进行处理,出现回调无法执行,并且页面出现了刷新 ...
- ylbtech-公司-滴滴出行:滴滴出行
ylbtech-公司-滴滴出行:滴滴出行 滴滴出行是涵盖出租车. 专车. 滴滴快车. 顺风车. 代驾及 大巴等多项业务在内的一站式出行平台,2015年9月9日由“滴滴打车”更名而来. 2月1日起, ...