0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

A - Large Digits AtCoder 考察

Last updated at Posted at 2021-01-11

■問題
◉ ABC187 A - Large Digits
https://atcoder.jp/contests/abc187/tasks/abc187_a

■方針
この問題の一番のポイントは、入力数値の桁取得が実装できるかどうか。
考え方はビットシフトとほとんど同じで、取得桁への移動方法を考える。

■手法
1.取得する桁の位置決めは、切り捨て除算で行う。
2.位置決めされた値を取り出すのは、剰余算で行う。


以下の流れが思いつけば、とりあえずOK。

input 123

1の位の取得
123 % 10 = 3
123 / 10 = 12 ・・・ 次のループに渡す値:12

10の位の取得
12 % 10 = 2
12 / 10 = 1  ・・・ 次のループに渡す値:1

100の位の取得
1 % 10 = 1
1 / 10 = 0  ・・・ 次のループに渡す値:0 ループ終了

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?