import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Date;import java.util.Scanner;import java.util.TimeZone;publicclassMain{publicstaticvoidmain(String[] args){
Scanner sc =newScanner(System.in);long x = sc.nextLong();
sc.close();
Date date =newDate(x);
DateFormat df =newSimpleDateFormat("HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(df.format(date));}}
G:最少砝码(Java)
import java.util.Scanner;publicclassMain{publicstaticvoidmain(String[] args){
Scanner sc =newScanner(System.in);long n = sc.nextLong();
sc.close();long w =1L;long i =1L;long s =1L;while(s < n){
w *=3;
s += w;
i++;}
System.out.println(i);}}
G:砝码称重(C++)
import java.util.Scanner;publicclassMain{staticint N =110;staticint M =200010;staticint B = M /2;publicstaticvoidmain(String[] args){
Scanner sc =newScanner(System.in);int n = sc.nextInt();int[] w =newint[N];int m =0;for(int i =1; i <= n; i++){
w[i]= sc.nextInt();
m += w[i];}
sc.close();boolean[][] f =newboolean[N][M];
f[0][B]=true;for(int i =1; i <= n; i++){for(int j =-m; j <= m; j++){
f[i][j + B]= f[i -1][j + B];if(j - w[i]>=-m){
f[i][j + B]|= f[i -1][j - w[i]+ B];}if(j + w[i]<= m){
f[i][j + B]|= f[i -1][j + w[i]+ B];}}}int res =0;for(int j =1; j <= m; j++){if(f[n][j + B]){
res++;}}
System.out.println(res);}}
H:杨辉三角形
import java.util.Scanner;publicclassMain{staticint n;publicstaticvoidmain(String[] args){
Scanner sc =newScanner(System.in);
n = sc.nextInt();
sc.close();for(int k =16;; k--){if(check(k)){break;}}}privatestaticbooleancheck(int k){long l = k *2;long r = Math.max((long) n, l);while(l < r){long mid = l + r >>1;if(C((int) mid, k)>= n){
r = mid;}else{
l = mid +1;}}if(C((int) r, k)!= n){returnfalse;}
System.out.println(r *(r +1)/2+ k +1);returntrue;}privatestaticlongC(int a,int b){long res =1;for(int i = a, j =1; j <= b; i--, j++){
res = res * i / j;}if(res > n){return res;}return res;}}
I:双向排序
待续
J:括号序列
import java.util.Scanner;publicclassMain{staticint N =5010;staticint MOD =(int)1e9+7;staticint n;staticchar[] str =newchar[N];staticlong[][] f;publicstaticvoidmain(String[] args){
Scanner sc =newScanner(System.in);
String s = sc.next();
sc.close();
str =(" "+ s).toCharArray();
n = s.length();long l =work();
str =(" "+reverse(s)).toCharArray();for(int i =1; i <= n; i++){if(str[i]=='('){
str[i]=')';}else{
str[i]='(';}}long r =work();
System.out.println(l * r % MOD);}privatestaticlongwork(){
f =newlong[N][N];
f[0][0]=1;for(int i =1; i <= n; i++){if(str[i]=='('){for(int j =1; j <= n; j++){
f[i][j]= f[i -1][j -1];}}else{
f[i][0]=(f[i -1][0]+ f[i -1][1])% MOD;for(int j =1; j <= n; j++){
f[i][j]=(f[i -1][j +1]+ f[i][j -1])% MOD;}}}for(int i =0; i <= n; i++){if(f[n][i]>0){return f[n][i];}}return-1;}privatestatic String reverse(String s){returnnewStringBuffer(s).reverse().toString();}}
杨辉三角形import java.util.Scanner;public class Main { static int n; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); sc.close(); for (int k = 16;; k--) { if (check(k)) { break; } } }