`
文章列表
Input Specification: Each input file contains one test case. Each case consists of two non-negative numbers N and b, where 0 <= N <= 109 is the decimal number and 2 <= b <= 109 is the base. The numbers are separated by a space. Output Specification: For each test case, first print i ...
#include<stdio.h> int main(){ int n, d; int reversiblePrime = 0; while(scanf("%d%d\n", &n,&d) == 2 && n >=0){ if(prime(n) && prime(reversPrime(n,d))) printf("Yes\n"); else printf("No\n"); } return 0; } int pri ...
Chinese Football Lottery provided a "Triple Winning" game. The rule of winning was simple: first select any three of the games. Then for each selected game, bet on one of the three possible results -- namely W for win, T for tie, and L for lose. There was an odd assigned to each result. T ...

PAT 1008. Elevator

    博客分类:
  • PAT
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will sta ...
Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (<= 10100). Output Specification: For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra sp ...
Input Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 ... NK aNK, where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1, 2, ..., K) are the exponents and coefficients, respectively. It i ...

PAT 1001. A+B Format (20)

    博客分类:
  • PAT
Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). Input Each input file contains one test case. Each case contains a pair of integers a and b where -1000000 <= a, b <= 10000 ...

JAVA Volatile 变量

    博客分类:
  • JAVA
学习并发的时候复习了下Volatile 变量,做个记录:   锁的两个特性 写道 锁提供了两种主要特性:互斥(mutual exclusion) 和可见性(visibility)。互斥即一次只允许一个线程持有某个特定的锁,因此可使用该特性实现对共享数据的协调访问协议,这样,一次就只有一个线程能够使用该共享数据。可见性要更加复杂一些,它必须确保释放锁之前对共享数据做出的更改对于随后获得该锁的另一个线程是可见的 —— 如果没有同步机制提供的这种可见性保证,线程看到的共享变量可能是修改前的值或不一致的值,这将引发许多严重问题。     写道 Java 语言中的 volatile 变量可 ...
1.Jakarta POI 是apache的子项目,目标是处理ol2对象。它提供了一组Windows文档操作的Java API。   2.EXCEL 结构 HSSFWorkbook excell 文档对象介绍 HSSFSheet excell的表单 HSSFRow excell的行 HSSFCell excell的格子单元 HSSFFont excell字体 HSSFName 名称 HSSFDataFormat 日期格式 在poi1.7中才有以下2项: HSSFHeader sheet头 HSSFFooter sheet尾 和这个样式 HSSFCellStyle ce ...
存在一个name.csv文件,内容如下   name birthday  place zhangsan 1988  hangzhou lisi 1989  hangzhou wangwu 1987  hangzhou wuliu 1988  Taizhou   csv文件的读 import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; ...
问题:   import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Scanner; public class MatchNumberGenerator { public static int[] matchNumberGenerator(int a){ int result[] = null; switch(a){ //"_"-->2 " "-->0 "|& ...
1.容器类添加一组数据 import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; public class AddingGroups { public static void main(String[] args) { Collection<Integer> collection = new ArrayList<Integer>(Ar ...
1.有关多态覆盖私有方法 public class PrivateOverride { private void f(){System.out.println("private f()");} public static void main(String[] args){ PrivateOverride po = new Derived(); po.f(); } } class Derived extends PrivateOverride{ public void f(){ System.out.println("p ...
今天整合spring和mybatis的时候有个错误一直出现,搞了半天才搞定。错误如下:   java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for     at org.mybatis.spring.SqlSessionTemplate.wrapException(SqlSessionTemplate.java:371)     at org.mybatis.spring.SqlSessionTemplate$7$1.doInSqlSession(S ...
最近一直在复习Java,发现最近一直对Java的hashCode和equals为什么一定要一起override不是很清楚,因此在复习的同时做下记录~~ API文件对有关hashCode()与equals有以下的相关规则: (1) 如果两个对象相等,则hashcode必须也是相等 (2) 如果两个对象相等,对其中一个对象调用equals()必须返回true.也就是说,若a.equals(b)则b.equals(a) (3) 如果两个对象有相同的hashcode值,它们也不一定是相等.但若两个对象相等,则hashcode值一定是相等的 原因: hashCode()所使用的杂凑算法可能会刚好 ...
Global site tag (gtag.js) - Google Analytics