[ABC 100] B-Ringo's Favorite Numbers
Posted fj-linhua
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[ABC 100] B-Ringo's Favorite Numbers相关的知识,希望对你有一定的参考价值。
B - Ringo‘s Favorite Numbers
Time limit : 2sec / Memory limit : 1000MB
Score: 200 points
Problem Statement
Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.
As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 exactly D times.
Find the N-th smallest integer that would make Ringo happy.
Constraints
- D is 0, 1 or 2.
- N is an integer between 1 and 100 (inclusive).
[题目解释]
给你两个数D和N,求第N个整除10D但不整除10D+1的数.
[题目解析]
我们可以先预处理出10D后直接乘上N,但是N=100时乘上的是N+1.
[代码]
/* Name: Ringo‘s Favorite Numbers Author: FZSZ-LinHua Date: 2018 06 16 Exec time: 1ms Memory usage: 128KB Score: 200 Algorithm: Brute-force */ # include "iostream" # include "cstdio" using namespace std; int d, n; long long mul=1ll; int main(){ scanf("%d%d",&d,&n); register int i; for(i=1;i<=d;i++){ //预处理出10^d mul*=100; } printf("%lld",(n+(n==100))*mul); //等价于n=100时乘101否则乘上n return 0; }
以上是关于[ABC 100] B-Ringo's Favorite Numbers的主要内容,如果未能解决你的问题,请参考以下文章