2016女生赛 HDU 5710 Digit-Sum(数学,思维题)
Digit-Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 782 Accepted Submission(s):
241
be digit-sum of N
, i.e S(109)=10,S(6)=6
.
If two positive integers a,b
are given, find the least positive integer n
satisfying the condition a×S(n)=b×S(2n)
.
If there is no such number then output 0.
.
The next T
lines contain two positive integers a,b(0<a,b<101)
.
case.
2 1
4 1
3 4
0
55899
#include<stdio.h>
#include<string.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstdio>
#include<time.h>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int d[];
int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b;
scanf("%d %d",&a,&b);
bool ff=;
bool f=;
int x=*b-a;
int y=*b; if(x==)
{
cout<<<<endl;
continue;
}
else if(x<||*x>y)
{
cout<<""<<endl;
continue;
}
int xx,yy;
xx=max(x,y);
yy=min(x,y);
int pp=gcd(xx,yy);
x=x/pp;
y=y/pp;
y=y-*x;
memset(d,,sizeof(d));
for(int i=;i<=x;i++) d[i]=;
int i=;
while(y>=)
{
y=y-;
d[i]+=;
i++;
}
x=max(x,i-);
if(y)
{
d[i]+=y;
if(x==i-) x++;
}
for(int j=x;j>=;j--)
cout<<d[j];
cout<<endl;
}
return ;
}
2016女生赛 HDU 5710 Digit-Sum(数学,思维题)的更多相关文章
- HDU 5710 Digit Sum
Let S(N)S(N) be digit-sum of NN, i.e S(109)=10,S(6)=6S(109)=10,S(6)=6. If two positive integers a,ba ...
- PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记
PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...
- 2014上海网络赛 HDU 5053 the Sum of Cube
水 #include <stdio.h> #include <stdlib.h> #include<math.h> #include<iostream> ...
- hdu 4710 Balls Rearrangement (数学思维)
意甲冠军:那是, 从数0-n小球进入相应的i%a箱号.然后买一个新的盒子. 今天的总合伙人b一个盒子,Bob试图把球i%b箱号. 求复位的最小成本. 每次移动的花费为y - x ,即移动前后盒子编号 ...
- HDU 1840 Equations (简单数学 + 水题)(Java版)
Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1840 ——每天在线,欢迎留言谈论. 题目大意: 给你一个一元二次方程组,a(X^2 ...
- hdu 5430 Reflect (数学推导题)
Problem Description We send a light from one point on a mirror material circle,it reflects N times a ...
- hdu 2710 Max Factor 数学(水题)
本来是不打算贴这道水题的,自己却WA了三次.. 要考虑1的情况,1的质因子为1 思路:先打表 ,然后根据最大质因子更新结果 代码: #include<iostream> #include& ...
- hdu 4091 数学思维题贪心
/* 参看博客地址:http://blog.csdn.net/oceanlight/article/details/7857713 重点是取完最优的后剩余的rest=n%lcm+lcm;中性价比小的数 ...
- 【CSP模拟赛】坏天平(数学&思维)
蹭兄弟学校的题目做还不用自己出题的感觉是真的爽 题目描述 nodgd有一架快要坏掉的天平,这架天平右边的支架有问题,如果右边的总重量比左边多太多,天平就彻底坏掉了.现在nodgd手上有n种砝码,质量分 ...
随机推荐
- postgresql centos6.5安装以及常用命令
今天在centos6.5下安装postgresql数据库,现在整理自己操作步骤. 一. Centos6.5 下安装postgresql9.4 1.1. 显示所有的有关postgresql安装包 yum ...
- spirng: srping mvc配置(访问路径配置)搭建SpringMVC——最小化配置
搭建SpringMVC——最小化配置 最开始接触网页的时候,是纯的html/css页面,那个时候还是用Dreamweaver来绘制页面. 随着网站开发的深入,开始学习servlet开发,记得最痛苦的就 ...
- SVN与Git优缺点比较
1.SVN优缺点优点: 1. 管理方便,逻辑明确,符合一般人思维习惯. 2. 易于管理,集中式服务器更能保证安全性. 3. 代码一致性非常高. 4. 适合开发人数不多的项目开发. 缺点: 1. 服务器 ...
- 三十四 Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy信号详解
信号一般使用信号分发器dispatcher.connect(),来设置信号,和信号触发函数,当捕获到信号时执行一个函数 dispatcher.connect()信号分发器,第一个参数信号触发函数,第二 ...
- 【Java】final关键字
1.final数据 (1)基本类型 数值恒定不变 (2)对象引用 引用恒定不变,初始化的时候指向一个对象后,无法改变为另一个对象,但是对象本身可以修改 2.final方法 可以把方 ...
- 013对象—— __clone __toString __call
<?php /** * */ //__clone()方法对一个对象实例进行的浅复制,对象内的基本数值类型进行的是传值复制 /*class a { public $uname; public $n ...
- python基础之面向对象(二)
面向对象对程序设计OOD 找对象---->找类(归纳对象相同的特征与技能,还有没和对象独有的特征)面向对象编程OOP 先定义类---->实例化出对象查看成绩,交作业 在python3中,所 ...
- New Concept English three (40)
23w/m 48 errors It has never been explained why university students seem to enjoy practical jokes mo ...
- [置顶]
Kubernetes1.7新特性:新增自动伸缩条件和参数
一.核心概念 Horizontal Pod Autoscaling,简称HPA,是Kubernetes中实现POD水平自动伸缩的功能.云计算具有水平弹性的特性,这个是云计算区别于传统IT技术架构的主要 ...
- 2017年国内已经开设机器人工程专业(080803T)高校名单
相关资料来源于教育部公布的2014年度和2016年度普通高等院校本科专业备案或审批结果的通知: 2014年批次 http://www.moe.edu.cn/publicfiles/business/h ...