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?

paiza

Last updated at Posted at 2025-10-05

📚 学習日付

10月5日(日)

🕒 学習時間

16:20~18:00(01:40)

🧑‍💻 実施した学習内容

『C031:時差を求める』

🧠 学んだこと・理解したこと

✅問題要約
・世界に N 個の都市がある。
・各都市は「都市名」と「UTC(協定世界時)との差(時差)」を持っている。
・入力で、ある都市に住むユーザが日記を投稿した時刻 (現地時間) が与えられる。
・他の全都市の住民が見た時刻を求める。
✅解法の流れ
・都市ごとの UTC との差分を保持する。
・投稿都市の現地時刻を UTC に変換する。
・投稿時刻 (h, m) − 投稿都市の時差 = UTC時刻
・各都市について(UTC + 都市の時差 → その都市の現地時刻に変換。)
・24時間制で 00:00〜23:59に収めるようにする(mod 24)。
✅ ポイント
・LinkedHashMap を使って都市の出力順を「入力順」に揃えてる。
・投稿時刻は「UTC基準」に直してから、各都市の時差を加算。
・24時間制を % 24 で処理する。『0〜23』に収める
・printf("%02d") でゼロ埋めフォーマット。
・Mapで都市と時差を保持。
✅簡単な覚え方
・UTCとは何か。『UTC=世界の共通の時計』『日本時間=UTC+9時間』

💬 次に学習したい事のメモ・感想

・世界の時差を求める課題は難易度別に少しずつ理解したい。
・UTCを取り入れた課題にも挑戦したい

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?