1. 程式人生 > >[ABC 100] B-Ringo's Favorite Numbers

[ABC 100] B-Ringo's Favorite Numbers

names like abc pac turn mes str hat gin

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