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种砝码,质量分 ...
随机推荐
- Linux 实用指令之查看端口开启情况
netstat -ntlp 查看端口使用情况! netstat -ntlp | grep 80 查看具体的端口是否使用! # netstat -ntlp Active Internet connect ...
- bower 安装
安装Yeomannpm install --global yo搭建一个web应用脚手架,你将需要安装generator-webapp生成器:npm install -g generator-webap ...
- spring3: 基于Schema的AOP
6.3 基于Schema的AOP 基于Schema的AOP从Spring2.0之后通过“aop”命名空间来定义切面.切入点及声明通知. 在Spring配置文件中,所以AOP相关定义必须放在<a ...
- 【总结】对异步处理的http接口进行性能测试
以前对接口做性能测试,接口都是同步处理的,请求之后等待响应结果就知道处理结果了,这样只要看这个接口是否异常,如果无异常无报错记录这个接口的响应时间.TPS等性能指标进行分析就可以了,最近在工作中遇到了 ...
- 【poj2155】Matrix(二维树状数组区间更新+单点查询)
Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the ...
- Java8_01_新特性概述
一.前言 二.
- 剑指offer--26.顺时针打印矩阵
1,2,3,45,6,7,88,10,11,1213,14,15,16 每次输出第一行,然后删除第一行,逆时针旋转剩下的矩阵. ------------------------------------ ...
- L138
Research indicates that lifestyles are changing fast.The essay isn't even remotely relevant to the t ...
- CSS3盒模型display:box简述
display:box;box-flex是css3新添加的盒子模型属性,它的出现可以解决我们通过N多结构.css实现的布局方式.经典的一个布局应用就是布局的垂直等高.水平均分.按比例划分. box-f ...
- Developing on Windows Phone 8 Devices
Developing on Windows Phone 8 Deviceshttp://docs.madewithmarmalade.com/native/platformguides/wp8guid ...