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 ...
随机推荐
- JavaScript对象基础知识
1.对象所包含的元素一组包含数据的属性.如人的名字.书的价格和手机型号等.允许对属性中所包含的数据进行操作的方法. 2.引用对象的途径一个对象真正地被使用,可以采用以下几种方式.引用Javascrip ...
- 自制单片机之七……RS232串口
在我的板子上其它的部分都已完成了,现在就剩下RS232串口了.串口对于单片机很重要,有了它就可以和PC通信了,可以用PC来控制你的单片机,也可以将你单片机上采集的数据传到PC上. 留的位置好像有点挤. ...
- 解决android4.0系统中菜单(Menu)添加Icon无效问题
本文转载自: http://blog.csdn.net/stevenhu_223/article/details/9705173 在Android4.0系统中,创建菜单Menu,通过setIcon方法 ...
- [VBA]根据身份证号码计算年龄的Excel函数
是的,昨天刚发表了一篇和Excel自定义函数有关的博客,今天又一篇,有凑数的嫌疑.但是,保存知识和传播知识本来就是写博客的初衷,所以也并不多余. 如果不知道什么是Excel自定义函数,请移步这里[1] ...
- python lcd 时间显示
#!/usr/bin/python # QStopWatch -- a very simple stop watch # Copyright (C) 2006 Dominic Battre <d ...
- Phoenix二级索引(Secondary Indexing)的使用
摘要 HBase只提供了一个基于字典排序的主键索引,在查询中你只能通过行键查询或扫描全表来获取数据,使用Phoenix提供的二级索引,可以避免在查询数据时全表扫描,提高查过性能,提升查询效率 测试 ...
- JSF标签大全详解
1. JSF入门 藉由以下的几个主题,可以大致了解JSF的轮廓与特性,我们来看看网页设计人员与应用程序设计人员各负责什么. 1.1简介JSF Web应用程序的开发与传统的单机程序开发在本质上存在着太多 ...
- javascript正則表達式 "\b"问题
preface 昨晚在看<javascript权威指南>后.看见作者自己封装一个兼容全部浏览器的山寨HTML5新API classLIst类.自己想了想认为自己也要去玩一下.可是能力还是有 ...
- js+css实现模态层效果
在做web前端的时候,有些时候会涉及到模态层,在此提供一种实现思路.希望对大家实用.先贴效果吧: 模态层效果 以下说说在写模态层的时候的思路:通过可配置的參数width,height,title以及c ...
- C/C++变量命名规则
变量命名规则是为了增强代码的可读性和easy维护性. 变量命名规则: 一.用最短字符表示最准确的意义. 二.使用变量前缀. 1. 整型前缀 int nId; ...