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 算法面试 ...
随机推荐
- 搭建ELK和EFK
公司突然发下任务让我搭建elk和efk,于是做完之后写入了博客,生产环境下,亲测可用哦 搭建ELK 一共两台服务器,一个节点(logstash) 主服务器上 修改最大链接和最大打开的文件 1.临时修改 ...
- tomcat启动、停止和重启脚本
脚本名称:r.sh 脚本用途:启动.停止和重启tomcat 脚本参数:$1:[start|stop|restart] #!/bin/bash BIN_PATH="/tomcat_path/b ...
- Nginx加载多个CPU核心,worker_cpu_affinity
配置Nginx多核CPU,worker_cpu_affinity使用方法和范例1. 2核CPU,开启2个进程 worker_processes 2;worker_cpu_affinity 01 10; ...
- js与android原生交互
package com.liuhao.mysecond; import androidx.annotation.RequiresApi;import androidx.appcompat.app.Ap ...
- 分布式系统理论进阶7:Paxos变种和优化
本文转自:https://www.cnblogs.com/bangerlee/p/6189646.html 本系列文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到 ...
- postgreSQL执行计划
" class="wiz-editor-body wiz-readonly" contenteditable="false"> explain命 ...
- 8、数值分析与matlab
1.今天要拷matlab代码了,而且是很恶心的算法,估计也没几个人能看得懂,就连我自己都看不懂. 我也不知道这样做的意义何在,可能只是证明我在这世上曾经学过那么那么难的东西吧 首先是一个matlab版 ...
- PHP 图片裁切
PHP CLASS TO CREATE IMAGE THUMBANILS Some years ago, I wrote a PHP class to create image thumbnails ...
- 在不打开excel的情况下用python执行excel
import win32com.client import time path = r'absolute dir' #比如填文件的绝对路径,比如d:/file/stock.xlsx xl = win3 ...
- Excel解析工具POI
HSSFWorkbook:是操作Excel2003以前(包括2003)的版本,扩展名是.xls XSSFWorkbook:是操作Excel2007的版本,扩展名是.xlsx 对于不同版本的EXCEL文 ...