cf B. Little Dima and Equation
http://codeforces.com/contest/460/problem/B
- import java.util.*;
- import java.math.*;
- public class Main {
- public static void main(String []args)
- {
- Scanner cin=new Scanner(System.in);
- int a,b,c;
- BigInteger a1=new BigInteger("");
- BigInteger a10=new BigInteger("");
- BigInteger a3=new BigInteger("");
- BigInteger [][]cc=new BigInteger[][];
- BigInteger []f1=new BigInteger[];
- for(int i=; i<=; i++)
- {
- for(int j=; j<=; j++)
- {
- BigInteger sum=new BigInteger("");
- BigInteger h=new BigInteger(((Integer)i).toString());
- int k=;
- while(k<=j)
- {
- sum=sum.multiply(h);
- k++;
- }
- cc[i] [j] =sum;
- }
- }
- a=cin.nextInt(); b=cin.nextInt();c=cin.nextInt();
- BigInteger h1=new BigInteger(((Integer)b).toString());
- BigInteger h2=new BigInteger(((Integer)c).toString());
- int cnt=;
- for(int i=; i<=; i++)
- {
- BigInteger a2=new BigInteger("");
- BigInteger hh=new BigInteger(((Integer)i).toString());
- BigInteger ans,ans1;
- ans=cc[i] [a] .multiply(h1).add(h2);
- ans1=ans;
- if(ans.compareTo(a1)<=||ans.compareTo(a10)>) continue;
- while(!ans.equals(a1))
- {
- a2=a2.add(ans.mod(a3));
- ans=ans.divide(a3);
- }
- if(a2.equals(hh))
- {
- f1[cnt] =ans1;
- cnt++;
- }
- }
- System.out.println(cnt);
- for(int i=; i<cnt; i++)
- {
- if(i==) System.out.print(f1[i] );
- else System.out.print(" "+f1[i] );
- }
- System.out.print("\n");
- }
- }
cf B. Little Dima and Equation的更多相关文章
- CodeForces460B. Little Dima and Equation
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input s ...
- CF460B Little Dima and Equation (水题?
Codeforces Round #262 (Div. 2) B B - Little Dima and Equation B. Little Dima and Equation time limit ...
- Codeforces Little Dima and Equation 数学题解
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input s ...
- B. Little Dima and Equation
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- cf 366D D. Dima and Trap Graph (计算所有线段共同覆盖的某段区间)
http://codeforces.com/problemset/problem/366/D 题意:给出n个点,m条边,a,b,ll,rr分别代表点a,点b相连,点a和点b的区间范围(ll,rr),然 ...
- CF#214 C. Dima and Salad 01背包变形
C. Dima and Salad 题意 有n种水果,第i个水果有一个美味度ai和能量值bi,现在要选择部分水果做沙拉,假如此时选择了m个水果,要保证\(\frac{\sum_{i=1}^ma_i}{ ...
- cf 366C C. Dima and Salad(01背包)
http://codeforces.com/contest/366/problem/C 题意:给出n个水果的两种属性a属性和b属性,然后挑选苹果,选择的苹果必须要满足这样一个条件:,现在给出n,k,要 ...
- codeforces 460B Little Dima and Equation 解题报告
题目链接:http://codeforces.com/problemset/problem/460/B 题目意思:给出a, b, c三个数,要你找出所有在 1 ≤ x ≤ 1e9 范围内满足 x = ...
- codeforces #262 DIV2 B题 Little Dima and Equation
题目地址:http://codeforces.com/contest/460/problem/B 这题乍一看没思路.可是细致分析下会发现,s(x)是一个从1到81的数,不管x是多少.所以能够枚举1到8 ...
随机推荐
- Zookeeper,也要接触起来啦
分布式的东东,就是部署也方便,但管理,想法,大集群应用是要点...! 参考如下URL简单实现 ,以后应用时多留意. http://blog.csdn.net/shirdrn/article/detai ...
- Qt C++中的关键字explicit——防止隐式转换(也就是Java里的装箱),必须写清楚
最近在复习QT,准备做项目了,QT Creator 默认生成的代码 explicit Dialog(QWidget *parent = 0)中,有这么一个关键字explicit,用来修饰构造函数.以前 ...
- ECMAScript 5/6/7兼容性速查表
http://kangax.github.io/compat-table/es5/ 秒查ECMAScript在各大浏览器的兼容性,点击右上角按钮可以“在5/6/7/非标”之间切换.做JavaScrip ...
- 【Xamarin 开发 IOS --IOS ViewController生命周期】
ViewController ViewController是IOS开发中MVC模式中的C,ViewController是view的controller,ViewController的职责主要包括管理内 ...
- Android文件下载(实现断点续传)
本文将介绍在android平台下如何实现多线程下载,大家都知道,android平台使用java做为开发语言,所以java中支持的多线程下载方式在android平台下都支持,其中主要有两种方式可以实现多 ...
- centerOS安装rkhunter
rkhunter是专业检测系统是否感染rootkit的一个工具: rkhunter-1.4.2.tar.gz 解压后直接安装: #./installer.sh --layout defualt --i ...
- 图片实时预览JSP加js
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- CSS3 动画触发事件
@keyframes mymove { 0% {top:0px; left:0px; background:red;} 25% {top:0px; left:100px; background:blu ...
- Linux基本操作 1-----命令行BASH的基本操作
1 Shell(壳)是用户与操作系统底层(通常是内核)之间交互的中介程序,负责将用户指令.操作传递给操作系统底层 shell 分为两种 CUI : Command Line Interface Lin ...
- linux性能优化常用命令
作为一名linux系统管理员,最主要的工作是优化系统配置,使应用在系统上以最优的状态运行,但是由于硬件问题.软件问题.网络环境等的复杂性 和多变性,导致对系统的优化变得异常复杂,如何定位性能问题出在哪 ...