java水题集
import java.io.*;
import java.util.*;
import java.math.*; public class Main {
public static int GetNum(char c)
{
if (Character.isDigit(c))return c-'0';
if (Character.isUpperCase(c))return c-'A'+10;
if (Character.isLowerCase(c))return c-'a'+36;
return '0';
}
public static char GetChar(int x)
{
if (x<10)return (char)(x+'0');
else if (x<=35) return (char)(x+'A'-10);
else return (char)(x+'a'-36);
}
public static void main(String[] args)
{
Scanner cin= new Scanner(new BufferedInputStream(System.in));
int T=cin.nextInt();
while(T--!=0)
{
BigInteger base1=cin.nextBigInteger();
BigInteger base2=cin.nextBigInteger();
BigInteger n=BigInteger.ZERO;
String s=cin.next();
for(int i=0;i<s.length();i++)
{
char c=s.charAt(i);
n=n.multiply(base1).add(BigInteger.valueOf(GetNum(c)));
}
String ans=new String();
while(!n.equals(BigInteger.ZERO))
{
ans=GetChar(n.mod(base2).intValue())+ans;
n=n.divide(base2);
}
if(ans.length()==0) ans+='0';
System.out.println(base1+" "+s);
System.out.println(base2+" "+ans);
if (T>0)System.out.println();
} } }
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { public static void main(String[] args)
{
Scanner cin=new Scanner(new BufferedInputStream(System.in));
BigDecimal b= new BigDecimal("8"),k,ans;
String s;
while(cin.hasNext())
{
ans=new BigDecimal(0);
k=new BigDecimal(1);
s=cin.nextLine();
for(int i=2;i<s.length();i++)
{
k=k.divide(b);
ans=ans.add( BigDecimal.valueOf(s.charAt(i)-'0').multiply(k));
}
System.out.println(s+" [8] = "+ans.toString()+" [10]");
//System.out.println(s+" [8] = "+ans.toString()+" [10]");
}
} }
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { public static void main(String[] args)
{
Scanner cin=new Scanner(new BufferedInputStream(System.in));
BigInteger f[]=new BigInteger[1005],Three=BigInteger.valueOf(3);
BigInteger tp[][]=new BigInteger[3][3],a[][]=new BigInteger[3][3];
a[1][1]=Three; a[1][2]=BigInteger.valueOf(-1);
a[2][1]=BigInteger.ONE; a[2][2]=BigInteger.ZERO;
f[0]=BigInteger.ZERO;
f[1]=BigInteger.ONE;
for(int i=2;i<=1000;i++)
f[i]=f[i-1].multiply(Three).subtract(f[i-2]);
while(cin.hasNext())
{
int n=cin.nextInt();
tp=MatrixPower(a,2,n-1);
System.out.println(tp[1][1].toString());
}
}
public static BigInteger[][] MatrixMultiply(BigInteger a[][],BigInteger b[][],int n,int p,int m)
{
BigInteger c[][]=new BigInteger[n+1][m+1];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
c[i][j]=BigInteger.ZERO;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
for(int k=1;k<=p;k++)
c[i][j]=c[i][j].add(a[i][k].multiply(b[k][j]));
return c;
}
public static BigInteger[][] MatrixPower(BigInteger a[][],int n,int p)
{
BigInteger ans[][]=new BigInteger[n+1][n+1];
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if (i==j)ans[i][j]=BigInteger.ONE;
else ans[i][j]=BigInteger.ZERO;
while(p>0)
{
if ((p&1)==1)ans=MatrixMultiply(ans,a,n,n,n);
p=p/2;
a=MatrixMultiply(a,a,n,n,n);
}
return ans;
}
}
java水题集的更多相关文章
- 【省选水题集Day1】一起来AK水题吧! 题目(更新到B)
题解:http://www.cnblogs.com/ljc20020730/p/6937954.html 水题A: [AHOI2001]质数和分解 题目网址: https://www.luogu.or ...
- 【省选水题集Day1】一起来AK水题吧! 题解(更新到B)
题目:http://www.cnblogs.com/ljc20020730/p/6937936.html 水题A:[AHOI2001]质数和分解 安徽省选OI原题!简单Dp. 一看就是完全背包求方案数 ...
- java错题集
解析:java中,JavaDoc注释以 /** 开头(中间写内容)以*/结尾 解析:A对象是类的实例,不是集合,其余正确 解析:创建一个对象的语法为: 类名 对象名=new 类名();,因此正确答案为 ...
- DP入门水题集
HDU 1087 Input contains multiple test cases. Each test case is described in a line as follow:N value ...
- java基础题集
1.什么是java虚拟机?为什么java被称作是“平台无关的编程语言”? java虚拟机是一个可以执行java字节码的虚拟机进程.java源文件被编译成能被java虚拟机执行的字节码文件. java被 ...
- JAVA 水题
纯粹是让我来掌握熟练度的. 1.金蝉素数 某古寺的一块石碑上依稀刻有一些神秘的自然数. 专家研究发现:这些数是由1,3,5,7,9 这5 个奇数字排列组成的5 位素数,且同时去掉它的最高位与最低位数字 ...
- 咸鱼的ACM之路:DFS水题集
DFS的核心就是从一种状态出发,转向任意的一个可行状态,直到达到结束条件为止.(个人理解) 下面全是洛谷题,毕竟能找到测试点数据的OJ我就找到这一个....在其他OJ上直接各种玄学问题... P159 ...
- 卡特兰数&&prufer序列&&BSGS水题集
首先说一下BSGS的一个坑点: 解方程A^x≡B(mod p) 需要特判一个东西=>A%p==B%p==0? 如果相等的话puts("1")反之则无解. 因为如果A%p=0, ...
- DP+贪心水题合集_C++
本文含有原创题,涉及版权利益问题,严禁转载,违者追究法律责任 本次是最后一篇免费的考试题解,以后的考试题目以及题解将会以付费的方式阅读,题目质量可以拿本次作为参考 本来半个月前就已经搞得差不多了,然后 ...
随机推荐
- DP(第一版)
序 任何一种具有递推或者递归形式的计算过程,都叫做动态规划 如果你一开始学的时候就不会DP,那么你在考试的时候就一定不会想到用动态规划! 需要进行掌握的内容 1)DP中的基本概念 2)状态 3)转移方 ...
- Maximum GCD(UVA 11827)
Problem:Given the N integers, you have to find the maximum GCD (greatest common divisor) of every po ...
- python位运算版的算术四则运算
#!/usr/bin/python # -*- coding: utf-8 -*- class ElementOperator: def add(self, num1, num2): # 32bits ...
- JAVA单元测试的用法和要点
2018年09月25日 10:11:18 琼歌 阅读数 5192 版权声明:禁止转载 https://blog.csdn.net/qq_36505948/article/details/827 ...
- 4.Java JSON使用
Java 中 JSON 的使用 分类 编程技术 本章节我们将为大家介绍如何在 Java 语言中使用 JSON. 类库选择 Java中并没有内置JSON的解析,因此使用JSON需要借助第三方类库. 下面 ...
- Permission权限大全
访问登记属性 android.permission.ACCESS_CHECKIN_PROPERTIES ,读取或写入登记check-in数据库属性表的权限 获取错略位置 android.permiss ...
- centos6 安装tensorflow
1.升级python2.6.6 至 python2.7.12+ 升级时./configure --prefix=/usr/local/python27 --enable-unicode=ucs4 2. ...
- 数学建模python matlab 编程(指派问题)
指派授课问题 现有A.B.C.D四门课程,需由甲.乙.丙.丁四人讲授,并且规定: 每人只讲且必须讲1门课:每门课必须且只需1人讲. 四人分别讲每门课的费用示于表中: 课 费用 人 A B C D 甲 ...
- linux定时脚本:删除linux/HDFS上过期文件
一.定时删除linux上定时的文件 显示20分钟前的文件 -exec ls -l {} \; 删除20分钟前的文件 -exec rm {} \; 显示20天前的文件 -exec ls -l {} \; ...
- Python之网络模型与图形绘制工具networkx
笔记 # https://www.jianshu.com/p/e543dc63454f import networkx as nx import matplotlib.pyplot as plt ## ...