Yandex.Algorithm 2011 Qualification 2
はい。
http://codeforces.com/contest/82
A. Double Cola
implementation,math
ざっくりと大意
・"Sheldon", "Leonard", "Penny", "Rajesh", "Howard" でコーラの自販機??で順番に飲みまくる
・1周目は1杯ずつ、2周目は2杯ずつ、3周目は4杯ずつ でドンドン2倍飲んでいく。
・n杯目を飲んでるのは誰か
方針のようなもの
・nを5周回2を引いていく。引くことが出来る=その周回は全員飲むことが出来て次の周回へ???
・全員が飲めなかったら周回2を、一人分が飲む量を引いていく
・なんかうまく説明できない。。。。
#!/usr/bin/env python # -*- coding: UTF-8 -*- import re, math k=int(raw_input()) l=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard'] cnt,ans=1,0 while k>cnt*5: k-=cnt*5 cnt*=2 while k>cnt: k-=cnt ans+=1 print l[ans]